diff --git a/custom/dashboard/variable.libsonnet b/custom/dashboard/variable.libsonnet index 91ca33f3..b4ce4d38 100644 --- a/custom/dashboard/variable.libsonnet +++ b/custom/dashboard/variable.libsonnet @@ -259,6 +259,15 @@ local d = import 'github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet'; if metric == '' then var.withQuery('label_values(%s)' % label) else var.withQuery('label_values(%s, %s)' % [metric, label]), + + '#withQueryResult':: d.func.new( + 'Construct a Prometheus template variable using `query_result()`.', + args=[ + d.arg('query', d.T.string), + ] + ), + withQueryResult(query): + var.withQuery('query_result(%s)' % query), }, // Deliberately undocumented, use `refresh` below diff --git a/docs/API/dashboard/variable.md b/docs/API/dashboard/variable.md index d12cdd9c..e5114eaf 100644 --- a/docs/API/dashboard/variable.md +++ b/docs/API/dashboard/variable.md @@ -120,6 +120,7 @@ g.dashboard.new('my dashboard') * [`fn withValueOnly()`](#fn-querygeneraloptionsshowondashboardwithvalueonly) * [`obj queryTypes`](#obj-queryquerytypes) * [`fn withLabelValues(label, metric="")`](#fn-queryquerytypeswithlabelvalues) + * [`fn withQueryResult(query)`](#fn-queryquerytypeswithqueryresult) * [`obj refresh`](#obj-queryrefresh) * [`fn onLoad()`](#fn-queryrefreshonload) * [`fn onTime()`](#fn-queryrefreshontime) @@ -898,6 +899,17 @@ PARAMETERS: - default value: `""` Construct a Prometheus template variable using `label_values()`. +##### fn query.queryTypes.withQueryResult + +```jsonnet +query.queryTypes.withQueryResult(query) +``` + +PARAMETERS: + +* **query** (`string`) + +Construct a Prometheus template variable using `query_result()`. #### obj query.refresh diff --git a/gen/grafonnet-v11.0.0/custom/dashboard/variable.libsonnet b/gen/grafonnet-v11.0.0/custom/dashboard/variable.libsonnet index 91ca33f3..b4ce4d38 100644 --- a/gen/grafonnet-v11.0.0/custom/dashboard/variable.libsonnet +++ b/gen/grafonnet-v11.0.0/custom/dashboard/variable.libsonnet @@ -259,6 +259,15 @@ local d = import 'github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet'; if metric == '' then var.withQuery('label_values(%s)' % label) else var.withQuery('label_values(%s, %s)' % [metric, label]), + + '#withQueryResult':: d.func.new( + 'Construct a Prometheus template variable using `query_result()`.', + args=[ + d.arg('query', d.T.string), + ] + ), + withQueryResult(query): + var.withQuery('query_result(%s)' % query), }, // Deliberately undocumented, use `refresh` below diff --git a/gen/grafonnet-v11.0.0/docs/dashboard/variable.md b/gen/grafonnet-v11.0.0/docs/dashboard/variable.md index d12cdd9c..e5114eaf 100644 --- a/gen/grafonnet-v11.0.0/docs/dashboard/variable.md +++ b/gen/grafonnet-v11.0.0/docs/dashboard/variable.md @@ -120,6 +120,7 @@ g.dashboard.new('my dashboard') * [`fn withValueOnly()`](#fn-querygeneraloptionsshowondashboardwithvalueonly) * [`obj queryTypes`](#obj-queryquerytypes) * [`fn withLabelValues(label, metric="")`](#fn-queryquerytypeswithlabelvalues) + * [`fn withQueryResult(query)`](#fn-queryquerytypeswithqueryresult) * [`obj refresh`](#obj-queryrefresh) * [`fn onLoad()`](#fn-queryrefreshonload) * [`fn onTime()`](#fn-queryrefreshontime) @@ -898,6 +899,17 @@ PARAMETERS: - default value: `""` Construct a Prometheus template variable using `label_values()`. +##### fn query.queryTypes.withQueryResult + +```jsonnet +query.queryTypes.withQueryResult(query) +``` + +PARAMETERS: + +* **query** (`string`) + +Construct a Prometheus template variable using `query_result()`. #### obj query.refresh