Skip to content

Commit 9c3fb80

Browse files
authored
Merge pull request #397 from grafana/grafana_builder_status_label
Grafana builder: make status code label name override able
2 parents dec1e4f + beff80e commit 9c3fb80

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

grafana-builder/grafana.libsonnet

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@
367367
},
368368
],
369369

370-
qpsPanel(selector):: {
370+
qpsPanel(selector, statusLabelName='status_code'):: {
371371
aliasColors: {
372372
'1xx': '#EAB839',
373373
'2xx': '#7EB26D',
@@ -379,9 +379,13 @@
379379
},
380380
targets: [
381381
{
382-
expr: 'sum by (status) (label_replace(label_replace(rate(' + selector + '[$__interval]),'
383-
+ ' "status", "${1}xx", "status_code", "([0-9]).."),'
384-
+ ' "status", "${1}", "status_code", "([a-z]+)"))',
382+
expr:
383+
|||
384+
sum by (status) (
385+
label_replace(label_replace(rate(%s[$__interval]),
386+
"status", "${1}xx", "%s", "([0-9]).."),
387+
"status", "${1}", "%s", "([a-z]+)"))
388+
||| % [selector, statusLabelName, statusLabelName],
385389
format: 'time_series',
386390
intervalFactor: 2,
387391
legendFormat: '{{status}}',

0 commit comments

Comments
 (0)