diff options
Diffstat (limited to 'docs/node-mixin/lib/promgrafonnet/gauge.libsonnet')
-rw-r--r-- | docs/node-mixin/lib/promgrafonnet/gauge.libsonnet | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/docs/node-mixin/lib/promgrafonnet/gauge.libsonnet b/docs/node-mixin/lib/promgrafonnet/gauge.libsonnet new file mode 100644 index 0000000..43640b6 --- /dev/null +++ b/docs/node-mixin/lib/promgrafonnet/gauge.libsonnet | |||
@@ -0,0 +1,60 @@ | |||
1 | local grafana = import 'grafonnet/grafana.libsonnet'; | ||
2 | local singlestat = grafana.singlestat; | ||
3 | local prometheus = grafana.prometheus; | ||
4 | |||
5 | { | ||
6 | new(title, query):: | ||
7 | singlestat.new( | ||
8 | title, | ||
9 | datasource='$datasource', | ||
10 | span=3, | ||
11 | format='percentunit', | ||
12 | valueName='current', | ||
13 | colors=[ | ||
14 | 'rgba(245, 54, 54, 0.9)', | ||
15 | 'rgba(237, 129, 40, 0.89)', | ||
16 | 'rgba(50, 172, 45, 0.97)', | ||
17 | ], | ||
18 | thresholds='50, 80', | ||
19 | valueMaps=[ | ||
20 | { | ||
21 | op: '=', | ||
22 | text: 'N/A', | ||
23 | value: 'null', | ||
24 | }, | ||
25 | ], | ||
26 | ) | ||
27 | .addTarget( | ||
28 | prometheus.target( | ||
29 | query | ||
30 | ) | ||
31 | ) + { | ||
32 | gauge: { | ||
33 | maxValue: 100, | ||
34 | minValue: 0, | ||
35 | show: true, | ||
36 | thresholdLabels: false, | ||
37 | thresholdMarkers: true, | ||
38 | }, | ||
39 | withTextNullValue(text):: self { | ||
40 | valueMaps: [ | ||
41 | { | ||
42 | op: '=', | ||
43 | text: text, | ||
44 | value: 'null', | ||
45 | }, | ||
46 | ], | ||
47 | }, | ||
48 | withSpanSize(size):: self { | ||
49 | span: size, | ||
50 | }, | ||
51 | withLowerBeingBetter():: self { | ||
52 | colors: [ | ||
53 | 'rgba(50, 172, 45, 0.97)', | ||
54 | 'rgba(237, 129, 40, 0.89)', | ||
55 | 'rgba(245, 54, 54, 0.9)', | ||
56 | ], | ||
57 | thresholds: '80, 90', | ||
58 | }, | ||
59 | }, | ||
60 | } | ||