Documentation ¶
Index ¶
- func AlignTimeRange(t time.Time, step time.Duration, offset int64) time.Time
- func ApplyQueryFilters(rawExpr string, scopeFilters, adHocFilters []ScopeFilter) (string, error)
- func QueryTypeDefinitionsJSON() (json.RawMessage, error)
- type Exemplar
- type FilterOperator
- type PromQueryFormat
- type PrometheusQueryProperties
- type Query
- type QueryEditorMode
- type QueryModel
- type ResultType
- type Scope
- type ScopeFilter
- type ScopeSpec
- type TimeRange
- type TimeSeriesQueryType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlignTimeRange ¶
AlignTimeRange aligns query range to step and handles the time offset. It rounds start and end down to a multiple of step. Prometheus caching is dependent on the range being aligned with the step. Rounding to the step can significantly change the start and end of the range for larger steps, i.e. a week. In rounding the range to a 1w step the range will always start on a Thursday.
func ApplyQueryFilters ¶ added in v0.0.5
func ApplyQueryFilters(rawExpr string, scopeFilters, adHocFilters []ScopeFilter) (string, error)
func QueryTypeDefinitionsJSON ¶ added in v0.0.5
func QueryTypeDefinitionsJSON() (json.RawMessage, error)
QueryTypeDefinitionsJSON returns the query type definitions
Types ¶
type FilterOperator ¶ added in v0.0.5
type FilterOperator string
FilterOperator is a hand copy of the ScopeFilter struct from pkg/apis/scope/v0alpha1/types.go
const ( FilterOperatorEquals FilterOperator = "equals" FilterOperatorNotEquals FilterOperator = "not-equals" FilterOperatorRegexMatch FilterOperator = "regex-match" FilterOperatorRegexNotMatch FilterOperator = "regex-not-match" )
Hand copy of enum from pkg/apis/scope/v0alpha1/types.go
type PromQueryFormat ¶
type PromQueryFormat string
PromQueryFormat defines model for PromQueryFormat. +enum
const ( PromQueryFormatTimeSeries PromQueryFormat = "time_series" PromQueryFormatTable PromQueryFormat = "table" PromQueryFormatHeatmap PromQueryFormat = "heatmap" )
type PrometheusQueryProperties ¶
type PrometheusQueryProperties struct { // The response format Format PromQueryFormat `json:"format,omitempty"` // The actual expression/query that will be evaluated by Prometheus Expr string `json:"expr"` // Returns a Range vector, comprised of a set of time series containing a range of data points over time for each time series Range bool `json:"range,omitempty"` // Returns only the latest value that Prometheus has scraped for the requested time series Instant bool `json:"instant,omitempty"` // Execute an additional query to identify interesting raw samples relevant for the given expr Exemplar bool `json:"exemplar,omitempty"` // what we should show in the editor EditorMode QueryEditorMode `json:"editorMode,omitempty"` // Used to specify how many times to divide max data points by. We use max data points under query options // See https://github.com/grafana/grafana/issues/48081 // Deprecated: use interval IntervalFactor int64 `json:"intervalFactor,omitempty"` // Series name override or template. Ex. {{hostname}} will be replaced with label value for hostname LegendFormat string `json:"legendFormat,omitempty"` // A set of filters applied to apply to the query Scope *ScopeSpec `json:"scope,omitempty"` // Additional Ad-hoc filters that take precedence over Scope on conflict. AdhocFilters []ScopeFilter `json:"adhocFilters,omitempty"` }
PrometheusQueryProperties defines the specific properties used for prometheus
type Query ¶
type Query struct { Expr string Step time.Duration LegendFormat string Start time.Time End time.Time RefId string InstantQuery bool RangeQuery bool ExemplarQuery bool UtcOffsetSec int64 Scope *ScopeSpec }
The internal query object
func (*Query) Type ¶
func (query *Query) Type() TimeSeriesQueryType
type QueryEditorMode ¶
type QueryEditorMode string
QueryEditorMode defines model for QueryEditorMode. +enum
const ( QueryEditorModeBuilder QueryEditorMode = "builder" QueryEditorModeCode QueryEditorMode = "code" )
type QueryModel ¶
type QueryModel struct { PrometheusQueryProperties `json:",inline"` sdkapi.CommonQueryProperties `json:",inline"` // The following properties may be part of the request payload, however they are not saved in panel JSON // Timezone offset to align start & end time on backend UtcOffsetSec int64 `json:"utcOffsetSec,omitempty"` Interval string `json:"interval,omitempty"` }
QueryModel includes both the common and specific values
type ResultType ¶
type ResultType string
+enum
const ( ResultTypeMatrix ResultType = "matrix" ResultTypeExemplar ResultType = "exemplar" ResultTypeVector ResultType = "vector" ResultTypeUnknown ResultType = "" )
func ResultTypeFromFrame ¶
func ResultTypeFromFrame(frame *data.Frame) ResultType
func (ResultType) String ¶
func (r ResultType) String() string
type ScopeFilter ¶ added in v0.0.4
type ScopeFilter struct { Key string `json:"key"` Value string `json:"value"` Operator FilterOperator `json:"operator"` }
ScopeFilter is a hand copy of the ScopeFilter struct from pkg/apis/scope/v0alpha1/types.go to avoid import (temp fix)
type ScopeSpec ¶ added in v0.0.4
type ScopeSpec struct { Title string `json:"title"` Type string `json:"type"` Description string `json:"description"` Category string `json:"category"` Filters []ScopeFilter `json:"filters"` }
ScopeSpec is a hand copy of the ScopeSpec struct from pkg/apis/scope/v0alpha1/types.go to avoid import (temp fix)
type TimeSeriesQueryType ¶
type TimeSeriesQueryType string
const ( RangeQueryType TimeSeriesQueryType = "range" InstantQueryType TimeSeriesQueryType = "instant" ExemplarQueryType TimeSeriesQueryType = "exemplar" UnknownQueryType TimeSeriesQueryType = "unknown" )