Documentation ¶
Index ¶
- Constants
- func BuildConnectorSchema(metadata *Metadata) (*schema.SchemaResponse, error)
- func EncodeQueryName(name string, queryType QueryType) string
- func FindNativeQueryVariableNames(query string) []string
- func ReplaceNativeQueryVariable(query string, name string, value string) string
- type Configuration
- type ExcludeLabelsSetting
- type GeneratorSettings
- type LabelInfo
- type Metadata
- type MetricInfo
- type MetricsGenerationBehavior
- type MetricsGeneratorSettings
- type NativeOperations
- type NativeQuery
- type NativeQueryArgumentInfo
- type PromQLFunctionName
- type QueryType
- type RuntimeFormatSettings
- type RuntimeSettings
- type ScalarName
- type State
- type TimestampFormat
- type ValueFormat
Constants ¶
const ( MetricsGenerationMerge = "merge" MetricsGenerationReplace = "replace" )
const ( Equal = "_eq" NotEqual = "_neq" In = "_in" NotIn = "_nin" Regex = "_regex" NotRegex = "_nregex" Least = "_lt" LeastOrEqual = "_lte" Greater = "_gt" GreaterOrEqual = "_gte" )
const ( TimestampKey = "timestamp" ValueKey = "value" ValuesKey = "values" LabelsKey = "labels" )
const ( ArgumentKeyFlat = "flat" ArgumentKeyTime = "time" ArgumentKeyTimeout = "timeout" ArgumentKeyStart = "start" ArgumentKeyEnd = "end" ArgumentKeyStep = "step" ArgumentKeyOffset = "offset" ArgumentKeyQuery = "query" ArgumentKeyFunctions = "fn" )
const (
FunctionPromQLQuery = "promql_query"
)
Variables ¶
This section is empty.
Functions ¶
func BuildConnectorSchema ¶
func BuildConnectorSchema(metadata *Metadata) (*schema.SchemaResponse, error)
BuildConnectorSchema builds the schema for the data connector from metadata
func EncodeQueryName ¶
EncodeQueryName build the query name with a query type
func FindNativeQueryVariableNames ¶
FindNativeQueryVariableNames find possible variables in the native query
Types ¶
type Configuration ¶
type Configuration struct { // Connection settings to connect the Prometheus server ConnectionSettings client.ClientSettings `json:"connection_settings" yaml:"connection_settings"` // Settings to generate metrics metadata Generator GeneratorSettings `json:"generator" yaml:"generator"` // The metadata of metrics and native queries Metadata Metadata `json:"metadata" yaml:"metadata"` // Runtime settings Runtime RuntimeSettings `json:"runtime" yaml:"runtime"` }
Configuration the configuration of Prometheus connector
func ReadConfiguration ¶
func ReadConfiguration(configurationDir string) (*Configuration, error)
ReadConfiguration reads the configuration from file
type ExcludeLabelsSetting ¶ added in v0.0.3
type ExcludeLabelsSetting struct { // The regular expression pattern of metric names Pattern string `json:"pattern" yaml:"pattern"` // List of labels to be excluded Labels []string `json:"labels" yaml:"labels"` }
ExcludeLabelsSetting the setting to exclude labels
type GeneratorSettings ¶
type GeneratorSettings struct {
Metrics MetricsGeneratorSettings `json:"metrics" yaml:"metrics"`
}
GeneratorSettings contain settings for the configuration generator
type LabelInfo ¶
type LabelInfo struct { // Description of the label Description *string `json:"description,omitempty" yaml:"description,omitempty"` }
LabelInfo the information of a Prometheus label
type Metadata ¶
type Metadata struct { Metrics map[string]MetricInfo `json:"metrics" yaml:"metrics"` NativeOperations NativeOperations `json:"native_operations" yaml:"native_operations"` }
Metadata the metadata configuration
type MetricInfo ¶
type MetricInfo struct { // A metric type Type model.MetricType `yaml:"type" json:"type"` // Description of the metric Description *string `yaml:"description,omitempty" json:"description,omitempty"` // Labels returned by the metric Labels map[string]LabelInfo `json:"labels" yaml:"labels"` }
MetricInfo the metadata information of a metric
type MetricsGenerationBehavior ¶ added in v0.0.3
type MetricsGenerationBehavior string
MetricsGenerationBehavior the behavior of metrics generation
type MetricsGeneratorSettings ¶
type MetricsGeneratorSettings struct { // Enable the metrics generation Enabled bool `json:"enabled" yaml:"enabled"` Behavior MetricsGenerationBehavior `json:"behavior" yaml:"behavior" jsonschema:"enum=merge,enum=replace"` // Include metrics with regular expression matching. Include all metrics by default Include []string `json:"include" yaml:"include"` // Exclude metrics with regular expression matching. // Note: exclude is higher priority than include Exclude []string `json:"exclude" yaml:"exclude"` // Exclude unnecessary labels ExcludeLabels []ExcludeLabelsSetting `json:"exclude_labels" yaml:"exclude_labels"` // The minimum timestamp that the plugin uses to query metadata StartAt time.Time `json:"start_at" yaml:"start_at"` }
MetricsGeneratorSettings contain settings for the metrics generation
type NativeOperations ¶
type NativeOperations struct { // The definition map of native queries Queries map[string]NativeQuery `json:"queries" yaml:"queries"` }
NativeOperations the list of native query and mutation definitions
type NativeQuery ¶
type NativeQuery struct { // The PromQL query string to use for the Native Query. // We can interpolate values using `${<varname>}` syntax, // such as http_requests_total{job=~"${<varname>}"} Query string `json:"query" yaml:"query"` // Description of the query Description *string `json:"description,omitempty" yaml:"description,omitempty"` // Labels returned by the native query Labels map[string]LabelInfo `json:"labels" yaml:"labels"` // Information of input arguments Arguments map[string]NativeQueryArgumentInfo `json:"arguments" yaml:"arguments"` }
NativeQuery contains the information a native query
type NativeQueryArgumentInfo ¶
type NativeQueryArgumentInfo struct { // Description of the argument Description *string `json:"description,omitempty" yaml:"description,omitempty"` Type string `json:"type" yaml:"type" jsonschema:"enum=Int64,enum=Float64,enum=String,enum=Duration"` }
NativeQueryArgumentInfo the input argument
type PromQLFunctionName ¶
type PromQLFunctionName string
const ( Sum PromQLFunctionName = "sum" Min PromQLFunctionName = "min" Max PromQLFunctionName = "max" Avg PromQLFunctionName = "avg" Count PromQLFunctionName = "count" CountValues PromQLFunctionName = "count_values" Stddev PromQLFunctionName = "stddev" Stdvar PromQLFunctionName = "stdvar" TopK PromQLFunctionName = "topk" BottomK PromQLFunctionName = "bottomk" Quantile PromQLFunctionName = "quantile" LimitK PromQLFunctionName = "limitk" LimitRatio PromQLFunctionName = "limit_ratio" Group PromQLFunctionName = "group" Absolute PromQLFunctionName = "abs" Absent PromQLFunctionName = "absent" AbsentOverTime PromQLFunctionName = "absent_over_time" Ceil PromQLFunctionName = "ceil" Changes PromQLFunctionName = "changes" Clamp PromQLFunctionName = "clamp" ClampMax PromQLFunctionName = "clamp_max" ClampMin PromQLFunctionName = "clamp_min" DayOfMonth PromQLFunctionName = "day_of_month" DayOfWeek PromQLFunctionName = "day_of_week" DayOfYear PromQLFunctionName = "day_of_year" DaysInMonth PromQLFunctionName = "days_in_month" Delta PromQLFunctionName = "delta" Derivative PromQLFunctionName = "deriv" Exponential PromQLFunctionName = "exp" Floor PromQLFunctionName = "floor" HistogramAvg PromQLFunctionName = "histogram_avg" HistogramCount PromQLFunctionName = "histogram_count" HistogramSum PromQLFunctionName = "histogram_sum" HistogramFraction PromQLFunctionName = "histogram_fraction" HistogramQuantile PromQLFunctionName = "histogram_quantile" HistogramStddev PromQLFunctionName = "histogram_stddev" HistogramStdvar PromQLFunctionName = "histogram_stdvar" HoltWinters PromQLFunctionName = "holt_winters" Hour PromQLFunctionName = "hour" IDelta PromQLFunctionName = "idelta" Increase PromQLFunctionName = "increase" IRate PromQLFunctionName = "irate" LabelJoin PromQLFunctionName = "label_join" LabelReplace PromQLFunctionName = "label_replace" Ln PromQLFunctionName = "ln" Log2 PromQLFunctionName = "log2" Log10 PromQLFunctionName = "log10" Minute PromQLFunctionName = "minute" Month PromQLFunctionName = "month" PredictLinear PromQLFunctionName = "predict_linear" Rate PromQLFunctionName = "rate" Resets PromQLFunctionName = "resets" Round PromQLFunctionName = "round" Scalar PromQLFunctionName = "scalar" Sgn PromQLFunctionName = "sgn" Sort PromQLFunctionName = "sort" SortDesc PromQLFunctionName = "sort_desc" SortByLabel PromQLFunctionName = "sort_by_label" SortByLabelDesc PromQLFunctionName = "sort_by_label_desc" Sqrt PromQLFunctionName = "sqrt" Time PromQLFunctionName = "time" Timestamp PromQLFunctionName = "timestamp" Year PromQLFunctionName = "year" AvgOverTime PromQLFunctionName = "avg_over_time" MinOverTime PromQLFunctionName = "min_over_time" MaxOverTime PromQLFunctionName = "max_over_time" SumOverTime PromQLFunctionName = "sum_over_time" CountOverTime PromQLFunctionName = "count_over_time" QuantileOverTime PromQLFunctionName = "quantile_over_time" StddevOverTime PromQLFunctionName = "stddev_over_time" StdvarOverTime PromQLFunctionName = "stdvar_over_time" LastOverTime PromQLFunctionName = "last_over_time" PresentOverTime PromQLFunctionName = "present_over_time" MadOverTime PromQLFunctionName = "mad_over_time" Acos PromQLFunctionName = "acos" Acosh PromQLFunctionName = "acosh" Asin PromQLFunctionName = "asin" Asinh PromQLFunctionName = "asinh" Atan PromQLFunctionName = "atan" Atanh PromQLFunctionName = "atanh" Cos PromQLFunctionName = "cos" Cosh PromQLFunctionName = "cosh" Sin PromQLFunctionName = "sin" Sinh PromQLFunctionName = "sinh" Tan PromQLFunctionName = "tan" Tanh PromQLFunctionName = "tanh" Deg PromQLFunctionName = "deg" Rad PromQLFunctionName = "rad" )
type QueryType ¶
type QueryType string
QueryType the enum of a query type
func DecodeQueryName ¶
DecodeQueryName extracts the query name and query type from string
func ParseQueryType ¶
ParseQueryType parses the QueryType from a raw string
type RuntimeFormatSettings ¶ added in v0.0.5
type RuntimeFormatSettings struct { // The serialization format for timestamp Timestamp TimestampFormat `json:"timestamp" yaml:"timestamp" jsonschema:"enum=rfc3339,enum=unix,enum=unix_ms,enum=unix_us,enum=unix_ns,default=unix"` // The serialization format for value Value ValueFormat `json:"value" yaml:"value" jsonschema:"enum=string,enum=float64,default=string"` // The serialization format for not-a-number values NaN any `json:"nan" yaml:"nan" jsonschema:"oneof_type=string;number;null"` // The serialization format for infinite values Inf any `json:"inf" yaml:"inf" jsonschema:"oneof_type=string;number;null"` // The serialization format for negative infinite values NegativeInf any `json:"negative_inf" yaml:"negative_inf" jsonschema:"oneof_type=string;number;null"` }
RuntimeFormatSettings format settings for timestamps and values in runtime
type RuntimeSettings ¶
type RuntimeSettings struct { // Flatten value points to the root array Flat bool `json:"flat" yaml:"flat"` // The default unit for unix timestamp UnixTimeUnit client.UnixTimeUnit `json:"unix_time_unit" yaml:"unix_time_unit" jsonschema:"enum=s,enum=ms,enum=us,enum=ns,default=s"` // The serialization format for response fields Format RuntimeFormatSettings `json:"format" yaml:"format"` // The concurrency limit of queries if there are many variables in a single query ConcurrencyLimit int `json:"concurrency_limit,omitempty" yaml:"concurrency_limit,omitempty"` }
RuntimeSettings contain settings for the runtime engine
type ScalarName ¶
type ScalarName string
const ( ScalarBoolean ScalarName = "Boolean" ScalarInt64 ScalarName = "Int64" ScalarFloat64 ScalarName = "Float64" ScalarString ScalarName = "String" ScalarDecimal ScalarName = "Decimal" ScalarTimestamp ScalarName = "Timestamp" ScalarLabelSet ScalarName = "LabelSet" ScalarDuration ScalarName = "Duration" ScalarJSON ScalarName = "JSON" )
type TimestampFormat ¶ added in v0.0.5
type TimestampFormat string
TimestampFormat the format for timestamp serialization
const ( // Represents the timestamp as a Unix timestamp in RFC3339 string. TimestampRFC3339 TimestampFormat = "rfc3339" // Represents the timestamp as a Unix timestamp in seconds. TimestampUnix TimestampFormat = "unix" // Represents the timestamp as a Unix timestamp in milliseconds. TimestampUnixMilli TimestampFormat = "unix_ms" // Represents the timestamp as a Unix timestamp in microseconds. TimestampUnixMicro TimestampFormat = "unix_us" // Represents the timestamp as a Unix timestamp in nanoseconds. TimestampUnixNano TimestampFormat = "unix_ns" )
type ValueFormat ¶ added in v0.0.5
type ValueFormat string
ValueFormat the format for value serialization
const ( ValueString ValueFormat = "string" ValueFloat64 ValueFormat = "float64" )