-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathsignals.libsonnet
119 lines (116 loc) · 3.08 KB
/
signals.libsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
local g = import './g.libsonnet';
local commonlib = import 'common-lib/common/main.libsonnet';
{
new(this): {
local vars = this.grafana.variables,
local config = this.config,
// define signals
local s = commonlib.signals.init(
datasource='${datasource}',
groupLabels=this.config.groupLabels,
instanceLabels=this.config.instanceLabels,
filteringSelector=[this.config.filteringSelector],
aggLevel='group', // group metrics by 'instance', 'group', or 'none'
),
//prepare Grafana templated variables aligned with queriesSelector generated:
variables: s.getVariablesMultiChoice(),
logsErrors: s.addSignal(
name='Errors in logs',
type='raw',
description='Errors in logs.',
sourceMaps=[
{
expr: '{%(queriesSelector)s, level=~"error|Error"} |= "searchstring"',
aggKeepLabels: [],
legendCustomTemplate: null,
rangeFunction: null,
},
],
),
info: s.addSignal(
name='Info version metric',
type='info',
infoLabel='version',
description='Version of the system',
sourceMaps=[
{
expr: 'metric_info{%(queriesSelector)s}',
aggKeepLabels: [],
legendCustomTemplate: null,
rangeFunction: null,
},
],
),
uptime1: s.addSignal(
name='Uptime Annotation signals',
type='raw',
description='Signal for annotation',
sourceMaps=[
{
expr: 'uptime{%(queriesSelector)s}*1000 > $__from < $__to',
aggKeepLabels: [],
legendCustomTemplate: null,
rangeFunction: null,
},
],
),
metric1: s.addSignal(
name='Sample gauge metric',
type='gauge',
unit='bytes',
description='Some description.',
sourceMaps=[
{
expr: 'gauge{%(queriesSelector)s}',
aggKeepLabels: [],
legendCustomTemplate: null,
rangeFunction: null,
},
],
),
metric2: s.addSignal(
name='Sample counter metric',
type='counter',
unit='requests',
description='Some description.',
sourceMaps=[
{
expr: 'counter_total{%(queriesSelector)s}',
aggKeepLabels: [],
legendCustomTemplate: null,
rangeFunction: 'rate',
},
],
),
metric3: s.addSignal(
name='Sample histogram metric',
type='histogram',
unit='',
description='Some description.',
sourceMaps=[
{
expr: 'counter_bucket_seconds{%(queriesSelector)s}',
aggKeepLabels: [],
legendCustomTemplate: null,
rangeFunction: 'rate',
},
],
),
metric4: s.addSignal(
name='Sample raw metric',
type='raw',
unit='',
description='Some description.',
sourceMaps=[
{
expr: |||
%(aggFunction)s by %(agg) (counter_bucket_seconds{%(queriesSelector)s})
|||,
aggKeepLabels: [],
legendCustomTemplate: null,
rangeFunction: null,
},
],
),
},
}