Prometheus: Update schema with legendFormat and intervalFactor (#68687)

add legendFormat and intervalFactor to the schema
This commit is contained in:
ismail simsek
2023-05-22 17:20:15 +03:00
committed by GitHub
parent 26c59ddc70
commit 670c987409
5 changed files with 36 additions and 14 deletions

View File

@@ -15,18 +15,20 @@ title: PrometheusDataQuery kind
It extends [DataQuery](#dataquery).
| Property | Type | Required | Default | Description |
|--------------|---------|----------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `expr` | string | **Yes** | | The actual expression/query that will be evaluated by Prometheus |
| `refId` | string | **Yes** | | *(Inherited from [DataQuery](#dataquery))*<br/>A unique identifier for the query within the list of targets.<br/>In server side expressions, the refId is used as a variable name to identify results.<br/>By default, the UI will assign A->Z; however setting meaningful names may be useful. |
| `datasource` | | No | | *(Inherited from [DataQuery](#dataquery))*<br/>For mixed data sources the selected datasource is on the query level.<br/>For non mixed scenarios this is undefined.<br/>TODO find a better way to do this ^ that's friendly to schema<br/>TODO this shouldn't be unknown but DataSourceRef &#124; null |
| `editorMode` | string | No | | Possible values are: `code`, `builder`. |
| `exemplar` | boolean | No | | Execute an additional query to identify interesting raw samples relevant for the given expr |
| `format` | string | No | | Possible values are: `time_series`, `table`, `heatmap`. |
| `hide` | boolean | No | | *(Inherited from [DataQuery](#dataquery))*<br/>true if query is disabled (ie should not be returned to the dashboard)<br/>Note this does not always imply that the query should not be executed since<br/>the results from a hidden query may be used as the input to other queries (SSE etc) |
| `instant` | boolean | No | | Returns only the latest value that Prometheus has scraped for the requested time series |
| `queryType` | string | No | | *(Inherited from [DataQuery](#dataquery))*<br/>Specify the query flavor<br/>TODO make this required and give it a default |
| `range` | boolean | No | | Returns a Range vector, comprised of a set of time series containing a range of data points over time for each time series |
| Property | Type | Required | Default | Description |
|------------------|---------|----------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `expr` | string | **Yes** | | The actual expression/query that will be evaluated by Prometheus |
| `refId` | string | **Yes** | | *(Inherited from [DataQuery](#dataquery))*<br/>A unique identifier for the query within the list of targets.<br/>In server side expressions, the refId is used as a variable name to identify results.<br/>By default, the UI will assign A->Z; however setting meaningful names may be useful. |
| `datasource` | | No | | *(Inherited from [DataQuery](#dataquery))*<br/>For mixed data sources the selected datasource is on the query level.<br/>For non mixed scenarios this is undefined.<br/>TODO find a better way to do this ^ that's friendly to schema<br/>TODO this shouldn't be unknown but DataSourceRef &#124; null |
| `editorMode` | string | No | | Possible values are: `code`, `builder`. |
| `exemplar` | boolean | No | | Execute an additional query to identify interesting raw samples relevant for the given expr |
| `format` | string | No | | Possible values are: `time_series`, `table`, `heatmap`. |
| `hide` | boolean | No | | *(Inherited from [DataQuery](#dataquery))*<br/>true if query is disabled (ie should not be returned to the dashboard)<br/>Note this does not always imply that the query should not be executed since<br/>the results from a hidden query may be used as the input to other queries (SSE etc) |
| `instant` | boolean | No | | Returns only the latest value that Prometheus has scraped for the requested time series |
| `intervalFactor` | number | No | | @deprecated Used to specify how many times to divide max data points by. We use max data points under query options<br/>See https://github.com/grafana/grafana/issues/48081 |
| `legendFormat` | string | No | | Series name override or template. Ex. {{hostname}} will be replaced with label value for hostname |
| `queryType` | string | No | | *(Inherited from [DataQuery](#dataquery))*<br/>Specify the query flavor<br/>TODO make this required and give it a default |
| `range` | boolean | No | | Returns a Range vector, comprised of a set of time series containing a range of data points over time for each time series |
### DataQuery

View File

@@ -66,6 +66,13 @@ type PrometheusDataQuery struct {
// Returns only the latest value that Prometheus has scraped for the requested time series
Instant *bool `json:"instant,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 *float32 `json:"intervalFactor,omitempty"`
// Series name override or template. Ex. {{hostname}} will be replaced with label value for hostname
LegendFormat *string `json:"legendFormat,omitempty"`
// Specify the query flavor
// TODO make this required and give it a default
QueryType *string `json:"queryType,omitempty"`

View File

@@ -44,6 +44,11 @@ composableKinds: DataQuery: {
editorMode?: #QueryEditorMode
// Query format to determine how to display data points in panel. It can be "time_series", "table", "heatmap"
format?: #PromQueryFormat
// Series name override or template. Ex. {{hostname}} will be replaced with label value for hostname
legendFormat?: string
// @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?: number
#QueryEditorMode: "code" | "builder" @cuetsy(kind="enum")
#PromQueryFormat: "time_series" | "table" | "heatmap" @cuetsy(kind="type")

View File

@@ -40,6 +40,15 @@ export interface Prometheus extends common.DataQuery {
* Returns only the latest value that Prometheus has scraped for the requested time series
*/
instant?: boolean;
/**
* @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?: number;
/**
* Series name override or template. Ex. {{hostname}} will be replaced with label value for hostname
*/
legendFormat?: string;
/**
* Returns a Range vector, comprised of a set of time series containing a range of data points over time for each time series
*/

View File

@@ -11,13 +11,11 @@ export interface PromQuery extends GenPromQuery, DataQuery {
* Timezone offset to align start & end time on backend
*/
utcOffsetSec?: number;
legendFormat?: string;
valueWithRefId?: boolean;
showingGraph?: boolean;
showingTable?: boolean;
hinting?: boolean;
interval?: string;
intervalFactor?: number;
// store the metrics modal additional settings
useBackend?: boolean;
disableTextWrap?: boolean;
@@ -31,6 +29,7 @@ export enum PrometheusCacheLevel {
High = 'High',
None = 'None',
}
export interface PromOptions extends DataSourceJsonData {
timeInterval?: string;
queryTimeout?: string;