[v9.3.x] Expressions: Fixes the issue showing expressions editor (#62627)

Expressions: Fixes the issue showing expressions editor (#62510)

* Use suggested value for uid

* update the snapshot

* use __expr__

* replace all -100 with __expr__

* update snapshot

* more changes

* revert redundant change

* Use expr.DatasourceUID where it's possible

* generate files

(cherry picked from commit 91221bc436)
This commit is contained in:
ismail simsek
2023-01-31 14:31:33 -05:00
committed by GitHub
parent 4d450ab910
commit ead3a002df
52 changed files with 235 additions and 224 deletions
@@ -69,7 +69,7 @@ groups:
# evaluation - should be obtained trough the API
data:
- refId: A
datasourceUid: '-100'
datasourceUid: '__expr__'
model:
conditions:
- evaluator:
@@ -86,7 +86,7 @@ groups:
type: query
datasource:
type: __expr__
uid: '-100'
uid: '__expr__'
expression: 1==0
intervalMs: 1000
maxDataPoints: 43200
@@ -282,7 +282,7 @@ resource "grafana_rule_group" "my_rule_group" {
// The query was configured to obtain data from the last 60 seconds. Let's alert on the average value of that series using a Reduce stage.
data {
datasource_uid = "-100"
datasource_uid = "__expr__"
// You can also create a rule in the UI, then GET that rule to obtain the JSON.
// This can be helpful when using more complex reduce expressions.
model = <<EOT
@@ -298,7 +298,7 @@ EOT
// Now, let's use a math expression as our threshold.
// We want to alert when the value of stage "B" above exceeds 70.
data {
datasource_uid = "-100"
datasource_uid = "__expr__"
ref_id = "C"
relative_time_range {
from = 0
@@ -821,36 +821,36 @@ Status: Bad Request
**Properties**
| Name | Type | Go type | Required | Default | Description | Example |
| --------------------------------------------------------- | ----------------------------------------- | ------------------- | :------: | ------- | -------------------------------------------------------------------------------------------------- | ------- |
| DatasourceUID | string | `string` | | | Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation. | |
| Model | object | `interface{}` | | | JSON is the raw JSON query and includes the above properties as well as custom properties. | |
| QueryType | string | `string` | | | QueryType is an optional identifier for the type of query. |
| Name | Type | Go type | Required | Default | Description | Example |
| --------------------------------------------------------- | ----------------------------------------- | ------------------- | :------: | ------- | ------------------------------------------------------------------------------------------------------ | ------- |
| DatasourceUID | string | `string` <br/> | | | Grafana data source unique identifier; it should be '**expr**' for a Server Side Expression operation. | |
| Model | object | `interface{}` | | | JSON is the raw JSON query and includes the above properties as well as custom properties. | |
| QueryType | string | `string` | | | QueryType is an optional identifier for the type of query. |
| It can be used to distinguish different types of queries. | |
| RefID | string | `string` | | | RefID is the unique identifier of the query, set by the frontend call. | |
| relativeTimeRange | [RelativeTimeRange](#relative-time-range) | `RelativeTimeRange` | | | | |
| RefID | string | `string` | | | RefID is the unique identifier of the query, set by the frontend call. | |
| relativeTimeRange | [RelativeTimeRange](#relative-time-range) | `RelativeTimeRange` | | | | |
### <span id="alert-rule"></span> AlertRule
**Properties**
| Name | Type | Go type | Required | Default | Description | Example |
| ------------ | ---------------------------- | ------------------- | :------: | ------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Annotations | map of string | `map[string]string` | | | | `{"runbook_url":"https://supercoolrunbook.com/page/13"}` |
| Condition | string | `string` | ✓ | | | `A` |
| Data | [][alertquery](#alert-query) | `[]*AlertQuery` | ✓ | | | `[{"datasourceUid":"-100","model":{"conditions":[{"evaluator":{"params":[0,0],"type":"gt"},"operator":{"type":"and"},"query":{"params":[]},"reducer":{"params":[],"type":"avg"},"type":"query"}],"datasource":{"type":"__expr__","uid":"__expr__"},"expression":"1 == 1","hide":false,"intervalMs":1000,"maxDataPoints":43200,"refId":"A","type":"math"},"queryType":"","refId":"A","relativeTimeRange":{"from":0,"to":0}}]` |
| ExecErrState | string | `string` | ✓ | | Allowed values: "OK", "Alerting", "Error" | |
| FolderUID | string | `string` | ✓ | | | `project_x` |
| ID | int64 (formatted integer) | `int64` | | | | |
| Labels | map of string | `map[string]string` | | | | `{"team":"sre-team-1"}` |
| NoDataState | string | `string` | ✓ | | Allowed values: "OK", "NoData", "Error" | |
| OrgID | int64 (formatted integer) | `int64` | ✓ | | | |
| RuleGroup | string | `string` | ✓ | | | `eval_group_1` |
| Title | string | `string` | ✓ | | | `Always firing` |
| UID | string | `string` | | | | |
| Updated | date-time (formatted string) | `strfmt.DateTime` | | | | |
| for | [Duration](#duration) | `Duration` | ✓ | | | |
| provenance | string | `Provenance` | | | | |
| Name | Type | Go type | Required | Default | Description | Example |
| ------------ | ---------------------------- | ------------------- | :------: | ------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Annotations | map of string | `map[string]string` | | | | `{"runbook_url":"https://supercoolrunbook.com/page/13"}` |
| Condition | string | `string` | ✓ | | | `A` |
| Data | [][alertquery](#alert-query) | `[]*AlertQuery` | ✓ | | <br/><br/> | `[{"datasourceUid":"__expr__","model":{"conditions":[{"evaluator":{"params":[0,0],"type":"gt"},"operator":{"type":"and"},"query":{"params":[]},"reducer":{"params":[],"type":"avg"},"type":"query"}],"datasource":{"type":"__expr__","uid":"__expr__"},"expression":"1 == 1","hide":false,"intervalMs":1000,"maxDataPoints":43200,"refId":"A","type":"math"},"queryType":"","refId":"A","relativeTimeRange":{"from":0,"to":0}}]` |
| ExecErrState | string | `string` | ✓ | | Allowed values: "OK", "Alerting", "Error" | |
| FolderUID | string | `string` | ✓ | | | `project_x` |
| ID | int64 (formatted integer) | `int64` | | | | |
| Labels | map of string | `map[string]string` | | | | `{"team":"sre-team-1"}` |
| NoDataState | string | `string` | ✓ | | Allowed values: "OK", "NoData", "Error" | |
| OrgID | int64 (formatted integer) | `int64` | ✓ | | | |
| RuleGroup | string | `string` | ✓ | | | `eval_group_1` |
| Title | string | `string` | ✓ | | | `Always firing` |
| UID | string | `string` | | | | |
| Updated | date-time (formatted string) | `strfmt.DateTime` | | | | |
| for | [Duration](#duration) | `Duration` | ✓ | | | |
| provenance | string | `Provenance` | | | | |
### <span id="alert-rule-group"></span> AlertRuleGroup