PromQL Variable builder

The PromQL Variable builder helps creating prometheus promQL variables in the format expected by Perses.

Usage

package myDaC

import (
	promQLVarBuilder "github.com/perses/perses/cue/dac-utils/prometheus/variable/promql"
)

promQLVarBuilder & {} // input parameters expected

Parameters

ParameterTypeMandatory/OptionalDefaultDescription
#namestringMandatoryThe name of this variable.
#displayDisplayOptionalDisplay object to tune the display name, description and visibility (show/hide).
#allowAllValuebooleanOptionalfalseWhether to append the “All” value to the list.
#allowMultiplebooleanOptionalfalseWhether to allow multi-selection of values.
#customAllValuestringOptionalCustom value that will be used if #allowAllValue is true and if All is selected.
#capturingRegexpstringOptionalRegexp used to catch and filter the results of the query. If empty, then nothing is filtered (equivalent of setting it to (.*)).
#sortSortOptionalSort method to apply when rendering the list of values.
#datasourceNamestringMandatoryThe name of the datasource to query.
#metricstringOptionalThe name of the source metric to be used. /!\ Mandatory if you want to rely on the standard query pattern, thus didn’t provide a value to the #query parameter.
#labelstringMandatoryto name parameterThe label from which to retrieve the list of values. /!\ The filter library does NOT rely on this parameter to build the corresponding matcher, only #name is used.
#querystringOptionalCustom query to be used for this variable. /!\ Mandatory if you didn’t provide a value to the #metric parameter.

Output

FieldTypeDescription
variableVariableThe final variable object, to be passed to the dashboard.

Example

package myDaC

import (
	promQLVarBuilder "github.com/perses/perses/cue/dac-utils/prometheus/variable/promql"
)

{promQLVarBuilder & {
	#name:           "container"
	#metric:         "kube_pod_container_info"
	#allowAllValue:  true
	#allowMultiple:  true
	#datasourceName: "promDemo"
}}.variable