Documentation ¶
Index ¶
- Constants
- Variables
- func SetupFillmode(query *backend.DataQuery, interval time.Duration, fillmode string) error
- type DBDataResponse
- type DataPluginConfiguration
- type DataSourceHandler
- type DataSourceInfo
- type JsonData
- type QueryJson
- type SQLMacroEngine
- type SQLMacroEngineBase
- type SqlQueryResultTransformer
Constants ¶
View Source
const MetaKeyExecutedQueryString = "executedQueryString"
MetaKeyExecutedQueryString is the key where the executed query should get stored
Variables ¶
View Source
var Interpolate = func(query backend.DataQuery, timeRange backend.TimeRange, timeInterval string, sql string) string { interval := query.Interval sql = strings.ReplaceAll(sql, "$__interval_ms", strconv.FormatInt(interval.Milliseconds(), 10)) sql = strings.ReplaceAll(sql, "$__interval", gtime.FormatInterval(interval)) sql = strings.ReplaceAll(sql, "$__unixEpochFrom()", fmt.Sprintf("%d", timeRange.From.UTC().Unix())) sql = strings.ReplaceAll(sql, "$__unixEpochTo()", fmt.Sprintf("%d", timeRange.To.UTC().Unix())) return sql }
Interpolate provides global macros/substitutions for all sql datasources.
Functions ¶
Types ¶
type DBDataResponse ¶
type DBDataResponse struct {
// contains filtered or unexported fields
}
type DataPluginConfiguration ¶
type DataPluginConfiguration struct { DSInfo DataSourceInfo TimeColumnNames []string MetricColumnTypes []string RowLimit int64 }
type DataSourceHandler ¶
type DataSourceHandler struct {
// contains filtered or unexported fields
}
func NewQueryDataHandler ¶
func NewQueryDataHandler(userFacingDefaultError string, db *sql.DB, config DataPluginConfiguration, queryResultTransformer SqlQueryResultTransformer, macroEngine SQLMacroEngine, log log.Logger) (*DataSourceHandler, error)
func (*DataSourceHandler) Dispose ¶
func (e *DataSourceHandler) Dispose()
func (*DataSourceHandler) Ping ¶
func (e *DataSourceHandler) Ping() error
func (*DataSourceHandler) QueryData ¶
func (e *DataSourceHandler) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
func (*DataSourceHandler) TransformQueryError ¶
func (e *DataSourceHandler) TransformQueryError(logger log.Logger, err error) error
type DataSourceInfo ¶
type JsonData ¶
type JsonData struct { MaxOpenConns int `json:"maxOpenConns"` MaxIdleConns int `json:"maxIdleConns"` ConnMaxLifetime int `json:"connMaxLifetime"` ConnectionTimeout int `json:"connectionTimeout"` Timescaledb bool `json:"timescaledb"` Mode string `json:"sslmode"` ConfigurationMethod string `json:"tlsConfigurationMethod"` TlsSkipVerify bool `json:"tlsSkipVerify"` RootCertFile string `json:"sslRootCertFile"` CertFile string `json:"sslCertFile"` CertKeyFile string `json:"sslKeyFile"` Timezone string `json:"timezone"` Encrypt string `json:"encrypt"` Servername string `json:"servername"` TimeInterval string `json:"timeInterval"` Database string `json:"database"` SecureDSProxy bool `json:"enableSecureSocksProxy"` SecureDSProxyUsername string `json:"secureSocksProxyUsername"` AllowCleartextPasswords bool `json:"allowCleartextPasswords"` AuthenticationType string `json:"authenticationType"` }
type SQLMacroEngine ¶
type SQLMacroEngine interface {
Interpolate(query *backend.DataQuery, timeRange backend.TimeRange, sql string) (string, error)
}
SQLMacroEngine interpolates macros into sql. It takes in the Query to have access to query context and timeRange to be able to generate queries that use from and to.
type SQLMacroEngineBase ¶
type SQLMacroEngineBase struct{}
func NewSQLMacroEngineBase ¶
func NewSQLMacroEngineBase() *SQLMacroEngineBase
func (*SQLMacroEngineBase) ReplaceAllStringSubmatchFunc ¶
type SqlQueryResultTransformer ¶
type SqlQueryResultTransformer interface { // TransformQueryError transforms a query error. TransformQueryError(logger log.Logger, err error) error GetConverterList() []sqlutil.StringConverter }
SqlQueryResultTransformer transforms a query result row to RowValues with proper types.
Click to show internal directories.
Click to hide internal directories.