Skip to content

Dataquery🔗

Constructor🔗

Dataquery()

Methods🔗

build🔗

Builds the object.

def build() -> prometheus.Dataquery

adhoc_filters🔗

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

def adhoc_filters(adhoc_filters: list[cogbuilder.Builder[prometheus.AdhocFilters]]) -> typing.Self

datasource🔗

The datasource

def datasource(datasource: common.DataSourceRef) -> typing.Self

editor_mode🔗

what we should show in the editor

Possible enum values:

  • "builder"

  • "code"

def editor_mode(editor_mode: prometheus.QueryEditorMode) -> typing.Self

exemplar🔗

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

def exemplar(exemplar: bool) -> typing.Self

expr🔗

The actual expression/query that will be evaluated by Prometheus

def expr(expr: str) -> typing.Self

format_val🔗

The response format

Possible enum values:

  • "time_series"

  • "table"

  • "heatmap"

def format_val(format_val: prometheus.PromQueryFormat) -> typing.Self

group_by_keys🔗

Group By parameters to apply to aggregate expressions in the query

def group_by_keys(group_by_keys: list[str]) -> typing.Self

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)

def hide(hide: bool) -> typing.Self

instant🔗

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

def instant() -> typing.Self

interval🔗

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

$__interval and $__rate_interval variables.

def interval(interval: str) -> typing.Self

interval_factor🔗

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

def interval_factor(interval_factor: int) -> typing.Self

interval_ms🔗

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

def interval_ms(interval_ms: float) -> typing.Self

legend_format🔗

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

def legend_format(legend_format: str) -> typing.Self

max_data_points🔗

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

def max_data_points(max_data_points: int) -> typing.Self

query_type🔗

QueryType is an optional identifier for the type of query.

It can be used to distinguish different types of queries.

def query_type(query_type: str) -> typing.Self

range_val🔗

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

def range_val() -> typing.Self

range_and_instant🔗

def range_and_instant() -> typing.Self

ref_id🔗

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

def ref_id(ref_id: str) -> typing.Self

result_assertions🔗

Optionally define expected query result behavior

def result_assertions(result_assertions: cogbuilder.Builder[prometheus.ResultAssertions]) -> typing.Self

scopes🔗

A set of filters applied to apply to the query

def scopes(scopes: list[cogbuilder.Builder[prometheus.Scopes]]) -> typing.Self

time_range🔗

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

def time_range(time_range: cogbuilder.Builder[prometheus.TimeRange]) -> typing.Self

See also🔗