Skip to content

DataqueryBuilder🔗

Constructor🔗

func NewDataqueryBuilder() *DataqueryBuilder

Methods🔗

Build🔗

Builds the object.

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

AdhocFilters🔗

Additional Ad-hoc filters that take precedence over Scope on conflict.

func (builder *DataqueryBuilder) AdhocFilters(adhocFilters []cog.Builder[prometheus.AdhocFilters]) *DataqueryBuilder

Datasource🔗

The datasource

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

EditorMode🔗

what we should show in the editor

Possible enum values:

  • "builder"

  • "code"

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

Exemplar🔗

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

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

Expr🔗

The actual expression/query that will be evaluated by Prometheus

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

Format🔗

The response format

Possible enum values:

  • "time_series"

  • "table"

  • "heatmap"

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

GroupByKeys🔗

Group By parameters to apply to aggregate expressions in the query

func (builder *DataqueryBuilder) GroupByKeys(groupByKeys []string) *DataqueryBuilder

Hide🔗

true if query is disabled (ie should not be returned to the dashboard)

NOTE: this does not always imply that the query should not be executed since

the results from a hidden query may be used as the input to other queries (SSE etc)

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

Instant🔗

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

func (builder *DataqueryBuilder) Instant() *DataqueryBuilder

Interval🔗

An additional lower limit for the step parameter of the Prometheus query and for the

$__interval and $__rate_interval variables.

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

IntervalFactor🔗

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

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

IntervalMs🔗

Interval is the suggested duration between time points in a time series query.

NOTE: the values for intervalMs is not saved in the query model. It is typically calculated

from the interval required to fill a pixels in the visualization

func (builder *DataqueryBuilder) IntervalMs(intervalMs float64) *DataqueryBuilder

LegendFormat🔗

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

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

MaxDataPoints🔗

MaxDataPoints is the maximum number of data points that should be returned from a time series query.

NOTE: the values for maxDataPoints is not saved in the query model. It is typically calculated

from the number of pixels visible in a visualization

func (builder *DataqueryBuilder) MaxDataPoints(maxDataPoints int64) *DataqueryBuilder

QueryType🔗

QueryType is an optional identifier for the type of query.

It can be used to distinguish different types of queries.

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

Range🔗

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

func (builder *DataqueryBuilder) Range() *DataqueryBuilder

RangeAndInstant🔗

func (builder *DataqueryBuilder) RangeAndInstant() *DataqueryBuilder

RefId🔗

RefID is the unique identifier of the query, set by the frontend call.

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

ResultAssertions🔗

Optionally define expected query result behavior

func (builder *DataqueryBuilder) ResultAssertions(resultAssertions cog.Builder[prometheus.ResultAssertions]) *DataqueryBuilder

Scopes🔗

A set of filters applied to apply to the query

func (builder *DataqueryBuilder) Scopes(scopes []cog.Builder[prometheus.Scopes]) *DataqueryBuilder

TimeRange🔗

TimeRange represents the query range

NOTE: unlike generic /ds/query, we can now send explicit time values in each query

NOTE: the values for timeRange are not saved in a dashboard, they are constructed on the fly

func (builder *DataqueryBuilder) TimeRange(timeRange cog.Builder[prometheus.TimeRange]) *DataqueryBuilder

See also🔗