SQL Expressions: Make SQL Expressions work with Alerting (#101820)
Initial support for alerting with SQL expressions - When `format` is set to `alerting`, SQL expressions output in a format suitable for alerting evaluation. - Outstanding TODOs: - Deduplicate output rows - Add more tests - Fix broken alerting UI rendering (likely due to shape change to undocumented full-long format) - Basic usage: - SQL must return one numeric column and one or more string columns. - Each row may become an alert. - The alert fires if the numeric value is non-zero. - String columns are treated as labels. --------- Co-authored-by: Konrad Lalik <konradlalik@gmail.com> Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com> Co-authored-by: Sam Jewell <sam.jewell@grafana.com>
This commit is contained in:
@@ -552,7 +552,7 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "sql",
|
||||
"resourceVersion": "1709915973363",
|
||||
"resourceVersion": "1743431268321",
|
||||
"creationTimestamp": "2024-02-29T00:58:00Z"
|
||||
},
|
||||
"spec": {
|
||||
@@ -573,10 +573,14 @@
|
||||
],
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"format": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"expression"
|
||||
"expression",
|
||||
"format"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
@@ -584,11 +588,12 @@
|
||||
{
|
||||
"name": "Select the first row from A",
|
||||
"saveModel": {
|
||||
"expression": "SELECT * FROM A limit 1"
|
||||
"expression": "SELECT * FROM A limit 1",
|
||||
"format": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user