prometheus

package
v0.0.0-...-83e2e3a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2025 License: Apache-2.0 Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataqueryConverter

func DataqueryConverter(input Dataquery) string

DataqueryConverter accepts a `Dataquery` object and generates the Go code to build this object using builders.

func VariantConfig

func VariantConfig() variants.DataqueryConfig

VariantConfig returns the configuration related to prometheus dataqueries. This configuration describes how to unmarshal it, convert it to code, …

Types

type Dataquery

type Dataquery struct {
	// The actual expression/query that will be evaluated by Prometheus
	Expr string `json:"expr"`
	// Returns only the latest value that Prometheus has scraped for the requested time series
	Instant *bool `json:"instant,omitempty"`
	// 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"`
	// Execute an additional query to identify interesting raw samples relevant for the given expr
	Exemplar *bool `json:"exemplar,omitempty"`
	// Specifies which editor is being used to prepare the query. It can be "code" or "builder"
	EditorMode *QueryEditorMode `json:"editorMode,omitempty"`
	// Query format to determine how to display data points in panel. It can be "time_series", "table", "heatmap"
	Format *PromQueryFormat `json:"format,omitempty"`
	// Series name override or template. Ex. {{hostname}} will be replaced with label value for hostname
	LegendFormat *string `json:"legendFormat,omitempty"`
	// @deprecated 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
	IntervalFactor *float64 `json:"intervalFactor,omitempty"`
	// A unique identifier for the query within the list of targets.
	// In server side expressions, the refId is used as a variable name to identify results.
	// By default, the UI will assign A->Z; however setting meaningful names may be useful.
	RefId string `json:"refId"`
	// If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel.
	Hide *bool `json:"hide,omitempty"`
	// Specify the query flavor
	// TODO make this required and give it a default
	QueryType *string `json:"queryType,omitempty"`
	// For mixed data sources the selected datasource is on the query level.
	// For non mixed scenarios this is undefined.
	// TODO find a better way to do this ^ that's friendly to schema
	// TODO this shouldn't be unknown but DataSourceRef | null
	Datasource *dashboard.DataSourceRef `json:"datasource,omitempty"`
	// An additional lower limit for the step parameter of the Prometheus query and for the
	// `$__interval` and `$__rate_interval` variables.
	Interval *string `json:"interval,omitempty"`
}

func NewDataquery

func NewDataquery() *Dataquery

NewDataquery creates a new Dataquery object.

func (Dataquery) DataqueryType

func (resource Dataquery) DataqueryType() string

func (Dataquery) Equals

func (resource Dataquery) Equals(otherCandidate variants.Dataquery) bool

Equals tests the equality of two dataqueries.

func (Dataquery) ImplementsDataqueryVariant

func (resource Dataquery) ImplementsDataqueryVariant()

func (*Dataquery) UnmarshalJSONStrict

func (resource *Dataquery) UnmarshalJSONStrict(raw []byte) error

UnmarshalJSONStrict implements a custom JSON unmarshalling logic to decode `Dataquery` from JSON. Note: the unmarshalling done by this function is strict. It will fail over required fields being absent from the input, fields having an incorrect type, unexpected fields being present, …

func (Dataquery) Validate

func (resource Dataquery) Validate() error

Validate checks all the validation constraints that may be defined on `Dataquery` fields for violations and returns them.

type DataqueryBuilder

type DataqueryBuilder struct {
	// contains filtered or unexported fields
}

func NewDataqueryBuilder

func NewDataqueryBuilder() *DataqueryBuilder

func (*DataqueryBuilder) Build

func (builder *DataqueryBuilder) Build() (variants.Dataquery, error)

func (*DataqueryBuilder) Datasource

func (builder *DataqueryBuilder) Datasource(datasource dashboard.DataSourceRef) *DataqueryBuilder

For mixed data sources the selected datasource is on the query level. For non mixed scenarios this is undefined. TODO find a better way to do this ^ that's friendly to schema TODO this shouldn't be unknown but DataSourceRef | null

func (*DataqueryBuilder) EditorMode

func (builder *DataqueryBuilder) EditorMode(editorMode QueryEditorMode) *DataqueryBuilder

Specifies which editor is being used to prepare the query. It can be "code" or "builder"

func (*DataqueryBuilder) Exemplar

func (builder *DataqueryBuilder) Exemplar(exemplar bool) *DataqueryBuilder

Execute an additional query to identify interesting raw samples relevant for the given expr

func (*DataqueryBuilder) Expr

func (builder *DataqueryBuilder) Expr(expr string) *DataqueryBuilder

The actual expression/query that will be evaluated by Prometheus

func (*DataqueryBuilder) Format

func (builder *DataqueryBuilder) Format(format PromQueryFormat) *DataqueryBuilder

Query format to determine how to display data points in panel. It can be "time_series", "table", "heatmap"

func (*DataqueryBuilder) Hide

func (builder *DataqueryBuilder) Hide(hide bool) *DataqueryBuilder

If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel.

func (*DataqueryBuilder) Instant

func (builder *DataqueryBuilder) Instant() *DataqueryBuilder

Returns only the latest value that Prometheus has scraped for the requested time series

func (*DataqueryBuilder) Interval

func (builder *DataqueryBuilder) Interval(interval string) *DataqueryBuilder

An additional lower limit for the step parameter of the Prometheus query and for the `$__interval` and `$__rate_interval` variables.

func (*DataqueryBuilder) IntervalFactor

func (builder *DataqueryBuilder) IntervalFactor(intervalFactor float64) *DataqueryBuilder

@deprecated 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

func (*DataqueryBuilder) LegendFormat

func (builder *DataqueryBuilder) LegendFormat(legendFormat string) *DataqueryBuilder

Series name override or template. Ex. {{hostname}} will be replaced with label value for hostname

func (*DataqueryBuilder) QueryType

func (builder *DataqueryBuilder) QueryType(queryType string) *DataqueryBuilder

Specify the query flavor TODO make this required and give it a default

func (*DataqueryBuilder) Range

func (builder *DataqueryBuilder) Range() *DataqueryBuilder

Returns a Range vector, comprised of a set of time series containing a range of data points over time for each time series

func (*DataqueryBuilder) RangeAndInstant

func (builder *DataqueryBuilder) RangeAndInstant() *DataqueryBuilder

func (*DataqueryBuilder) RefId

func (builder *DataqueryBuilder) RefId(refId string) *DataqueryBuilder

A unique identifier for the query within the list of targets. In server side expressions, the refId is used as a variable name to identify results. By default, the UI will assign A->Z; however setting meaningful names may be useful.

type PromQueryFormat

type PromQueryFormat string
const (
	PromQueryFormatTimeSeries PromQueryFormat = "time_series"
	PromQueryFormatTable      PromQueryFormat = "table"
	PromQueryFormatHeatmap    PromQueryFormat = "heatmap"
)

type QueryEditorMode

type QueryEditorMode string
const (
	QueryEditorModeCode    QueryEditorMode = "code"
	QueryEditorModeBuilder QueryEditorMode = "builder"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL