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:
@@ -13,8 +13,8 @@
|
||||
"refId": "B",
|
||||
"maxDataPoints": 1000,
|
||||
"intervalMs": 5,
|
||||
"type": "math",
|
||||
"expression": "$A - $B"
|
||||
"expression": "$A - $B",
|
||||
"type": "math"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
@@ -31,11 +31,11 @@
|
||||
"refId": "D",
|
||||
"maxDataPoints": 1000,
|
||||
"intervalMs": 5,
|
||||
"upsampler": "pad",
|
||||
"type": "resample",
|
||||
"downsampler": "last",
|
||||
"expression": "$A",
|
||||
"window": "1d",
|
||||
"downsampler": "last"
|
||||
"type": "resample",
|
||||
"upsampler": "pad",
|
||||
"window": "1d"
|
||||
},
|
||||
{
|
||||
"refId": "E",
|
||||
@@ -68,7 +68,6 @@
|
||||
"refId": "F",
|
||||
"maxDataPoints": 1000,
|
||||
"intervalMs": 5,
|
||||
"expression": "A",
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
@@ -79,13 +78,13 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"expression": "A",
|
||||
"type": "threshold"
|
||||
},
|
||||
{
|
||||
"refId": "G",
|
||||
"maxDataPoints": 1000,
|
||||
"intervalMs": 5,
|
||||
"expression": "B",
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
@@ -134,6 +133,7 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"expression": "B",
|
||||
"type": "threshold"
|
||||
},
|
||||
{
|
||||
@@ -141,6 +141,7 @@
|
||||
"maxDataPoints": 1000,
|
||||
"intervalMs": 5,
|
||||
"expression": "SELECT * FROM A limit 1",
|
||||
"format": "",
|
||||
"type": "sql"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user