Skip to content

Commit 158cec7

Browse files
authored
Update version signal for snmp-observ-lib(cisco) (#1405)
* Remove duplicated uids from alerts/dashboards * Update version signal for cisco * Fix combining info metrics. * make alertInterfaceDownSeverity configurable * Fix SNMPInterfaceDown query
1 parent 8948a8a commit 158cec7

9 files changed

+46
-23
lines changed

common-lib/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 0.3.2
2+
- [Signal] Fix combining info metrics.
3+
14
# 0.3.1
25
- [Signal] Fix optional signals (type=stub).
36
- [Signal] Add optional signals documentation.

common-lib/common/signal/base.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
2525
sourceMaps:: sourceMaps,
2626
combineUniqueExpressions(expressions)::
2727
std.join(
28-
'\nor\n',
28+
if type == 'info' then '\nor ignoring(%s)\n' % std.join(',', this.combineUniqueInfoLabels(sourceMaps)) else '\nor\n',
2929
std.uniq( // keep unique only
3030
std.sort(expressions)
3131
)

common-lib/common/signal/test_info_combined.libsonnet

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,39 @@ local m1 = signal.init(
3333
{
3434

3535
asTarget: {
36-
raw:: m1.asTarget(),
36+
local raw = m1.asTarget(),
3737
testResult: test.suite({
3838
testExpression: {
39-
actual: m1.asTarget().expr,
39+
actual: raw.expr,
4040
expect: 'go_info{job="abc",job=~"$job",instance=~"$instance"}',
4141
},
4242
}),
4343
},
4444
asStat:
4545
{
46-
raw:: m1.asStat(),
46+
local raw = m1.asStat(),
4747
testResult: test.suite({
4848
testTStitle: {
49-
actual: m1.asStat().title,
49+
actual: raw.title,
5050
expect: 'Go version',
5151
},
5252
testType: {
53-
actual: m1.asStat().type,
53+
actual: raw.type,
5454
expect: 'stat',
5555
},
5656
testTSversion: {
57-
actual: m1.asStat().pluginVersion,
57+
actual: raw.pluginVersion,
5858
expect: 'v11.0.0',
5959
},
6060
testTSUid: {
61-
actual: m1.asStat().datasource,
61+
actual: raw.datasource,
6262
expect: {
6363
uid: '${datasource}',
6464
type: 'prometheus',
6565
},
6666
},
6767
testInfoLabel: {
68-
actual: m1.asStat().options.reduceOptions.fields,
68+
actual: raw.options.reduceOptions.fields,
6969
expect: '/^' + '(version|version2)' + '$/',
7070
},
7171
}),

common-lib/common/signal/test_marshall_json_multi_combined.libsonnet

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ local jsonSignals =
5151
sources: {
5252
otel: {
5353
expr: 'foo_info{%(queriesSelector)s}',
54-
5554
infoLabel: 'version',
5655
},
57-
prometheus: {},
56+
prometheus: {
57+
expr: 'foo_info2{%(queriesSelector)s}',
58+
infoLabel: 'version2',
59+
},
5860
},
5961
},
6062
status: {
@@ -138,6 +140,15 @@ local signals = signal.unmarshallJsonMulti(jsonSignals, ['otel', 'prometheus']);
138140
},
139141
}),
140142
},
143+
asTargetInfo: {
144+
local raw = signals.foo_info.asTarget(),
145+
testResult: test.suite({
146+
testExpression: {
147+
actual: raw.expr,
148+
expect: 'avg by (job,xxx,version) (\n foo_info{job="integrations/agent",job=~"$job",instance=~"$instance"}\n)\nor ignoring(version,version2)\navg by (job,xxx,version2) (\n foo_info2{job="integrations/agent",job=~"$job",instance=~"$instance"}\n)',
149+
},
150+
}),
151+
},
141152
asStatusHistory:
142153
{
143154
local panel = signals.bar.asStatusHistory(),

snmp-observ-lib/alerts.libsonnet

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
66
local groupLabel = xtd.array.slice(this.config.groupLabels, -1)[0],
77
groups+: [
88
{
9-
name: this.config.uid + '-fc-snmp-alerts',
9+
name: this.config.uid + '-fc-alerts',
1010
rules:
1111
[
1212
{
@@ -152,7 +152,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
152152
],
153153
},
154154
{
155-
name: this.config.uid + '-snmp-alerts',
155+
name: this.config.uid + '-alerts',
156156
rules:
157157
[
158158
{
@@ -233,14 +233,14 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
233233
expr: |||
234234
(%s) == 2
235235
# only alert if interface is adminatratively up:
236-
and (%s) != 1
236+
and (%s) != 2
237237
|||
238238
% [
239239
this.signals.interface.ifOperStatus.withFilteringSelectorMixin(this.config.alertInterfaceDownSelector).asRuleExpression(),
240240
this.signals.interface.ifAdminStatus.asRuleExpression(),
241241
],
242242
labels: {
243-
severity: 'warning',
243+
severity: this.config.alertInterfaceDownSeverity,
244244
},
245245
annotations: {
246246
summary: 'Network interface is down on SNMP device.',
@@ -321,7 +321,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
321321
],
322322
},
323323
{
324-
name: this.config.uid + '-snmp-exporter-alerts',
324+
name: this.config.uid + '-exporter-alerts',
325325
rules:
326326
[
327327
{

snmp-observ-lib/config.libsonnet

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
metricsSource: ['generic', 'cisco', 'mikrotik', 'juniper'],
1717

1818
//only fire alerts 'interface is down' for the following selector:
19-
alertInterfaceDownSelector: 'ifAlias=~".*(?i:(uplink|internet|WAN)).*"',
19+
alertInterfaceDownSelector: 'ifAlias=~".*(?i:(uplink|internet|WAN)|ISP).*"',
20+
alertInterfaceDownSeverity: 'warning',
21+
2022
// cpuSelector for metricsSources with HOST-RESOURCE-MIB:
2123
cpuSelector: 'hrDeviceType="1.3.6.1.2.1.25.3.1.3"',
2224
// memorySelector for metricsSources with HOST-RESOURCE-MIB:

snmp-observ-lib/dashboards.libsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ local logslib = import 'logs-lib/logs/main.libsonnet';
2929
this.signals.system.getVariablesSingleChoice(),
3030
keyF=function(x) x.name
3131
),
32-
uid + '-snmp-fleet',
32+
uid + '-fleet',
3333
tags,
3434
links { backToFleet+:: {} },
3535
annotations,
@@ -58,7 +58,7 @@ local logslib = import 'logs-lib/logs/main.libsonnet';
5858
this.signals.interface.getVariablesMultiChoice(),
5959
keyF=function(x) x.name
6060
),
61-
uid + '-snmp-overview',
61+
uid + '-overview',
6262
tags,
6363
links,
6464
annotations,

snmp-observ-lib/signals/memory.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function(this)
7171
(ciscoMemoryPoolUsed{ciscoMemoryPoolType="1", %(queriesSelector)s} + ciscoMemoryPoolFree{ciscoMemoryPoolType="1", %(queriesSelector)s}) * 100)
7272
|||,
7373
// keeping this label for now for future improvements
74-
// aggKeepLabels: ['ciscoMemoryPoolName', cempMemPoolName'],
74+
// aggKeepLabels: ['ciscoMemoryPoolName', 'cempMemPoolName'],
7575
},
7676
dell_network: {
7777
expr: 'dellNetCpuUtilMemUsage{%(queriesSelector)s}',

snmp-observ-lib/signals/system.libsonnet

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,20 @@ function(this)
103103
|||,
104104
type: 'info',
105105
sources: {
106-
generic: self.cisco,
106+
generic: {
107+
expr: 'label_replace(sysDescr{%(queriesSelector)s}, "version", "$1", "sysDescr", ".*Version ([0-9a-zA-Z\\\\.\\\\(\\\\)]+).*")',
108+
infoLabel: 'version',
109+
},
107110
arista_sw: self.generic,
108111
brocade_fc: self.generic,
109112
brocade_foundry: self.generic,
110113
cisco: {
111-
expr: 'label_replace(sysDescr{%(queriesSelector)s}, "sysDescr", "$1", "sysDescr", ".*Version ([0-9a-zA-Z\\\\.\\\\(\\\\)]+).*")',
112-
infoLabel: 'sysDescr',
114+
expr: |||
115+
label_replace(
116+
ciscoImageString{ciscoImageString=~"CW_VERSION.+", %(queriesSelector)s}, "version", "$1", "ciscoImageString", "CW_VERSION\\$(.+)\\$"
117+
)
118+
|||,
119+
infoLabel: 'version',
113120
},
114121
dell_network: self.generic,
115122
dlink_des: self.generic,

0 commit comments

Comments
 (0)