Ga naar inhoud

Monitoring

graph TD
  subgraph Data Sources
    DS1([Firewall])
    DS2([Synology])
    DS3([Kubernetes])
    DS4([Core switches])
    DS5([Unifi])
    DS6([smartmeter])
  end

  subgraph Collect and Process
    CP1([Grafana Alloy])
    CP2([telegraf])
    CP3([Unifi Poller])
    CP4([pfsense internal])
    CP5([mqtt])
    CP6([nodered])
  end

  subgraph Storage
    STG1[Loki]
    STG2[(mysql)]
    STG3[(postgres)]
    STG4[(InfluxDB)]

  end

  subgraph Alerting
    ALERT1([Alert Manager])
    ALERT2([pushover])
  end

  subgraph Visualization
    VIS1([Grafana])
  end

  DS1 sys1@-- syslog --> CP1
  DS1 alert1@==> ALERT2

  DS2 snmp1@-- snmp --> CP2
  DS3 snmp2@-- snmp --> CP2
  DS4 snmp3@-- snmp --> CP2
  DS5 unifi1@--> CP3
  DS6 mqtt1@--> CP5

  CP1 e2@--> STG1
  CP2 --> STG4
  CP3 --> STG4
  CP4 --> STG4
  CP5 --> CP6
  CP6 --> STG4

  STG1 --- VIS1
  STG2 --- VIS1
  STG3 --- VIS1
  STG4 --- VIS1

  VIS1 --> ALERT1
  VIS1 --> ALERT2

sys1@{ animate: true }
alert1@{ animate: true }
snmp1@{ animate: true }
snmp2@{ animate: true }
snmp3@{ animate: true }
unifi1@{ animate: true }

click DS1 "#firewall"
click DS2 "#synology"
click DS3 "#kubernetes"
click DS4 "#core-switches"
click DS5 "#unifi"
click CP1 "#grafana-alloy"
click CP2 "#telegraf"
click CP3 "#unifi-poller"
click STG1 "#loki"
click STG2 "#mysql"
click STG3 "#postgres"
click STG4 "#influxdb"
click ALERT1 "#alert-manager"
click ALERT2 "#pushover"
click VIS1 "#grafana"

Data Sources

Data sources zijn alle verschillende componenten die gemonitored moeten worden.

Firewall

Het hart van het netwerk, de firewall zorgt voor een veilig netwerk, ik monitor alle firewall regels en de systeemstatus. Firewall regels worden op dit moment gelogd door middel van Syslog en door een directe config naar influxDB.

Pfsense heeft een interne telegraf plugin die direct naar influxDB schrijft:

pfsense-internal
[[outputs.influxdb_v2]]
  urls = ["https://influxdb.loevencloud.nl"]
  token = "<influxdbtoken>"
  organization = "loevencloud"
  bucket = "pfsense"

[[inputs.exec]]
    commands = [
        "/usr/local/bin/telegraf_pfifgw.php",
        "sh /usr/local/bin/telegraf_temperature.sh"
    ]
    data_format = "influx"

[[inputs.tail]]
    files = ["/var/log/pfblockerng/dnsbl.log"]
    data_format = "grok"
    from_beginning = false
    name_suffix = "_dnsbl_log"
    grok_timezone = "Local"
    grok_patterns = ["^%{WORD:blocktype}-%{WORD:blocksubtype},%{SYSLOGTIMESTAMP:timestamp:ts-syslog},%{IPORHOST:domain},%{IPORHOST:src_ip:tag},%{GREEDYDATA:req_agent},%{WORD:blockmethod},%{WORD:blocklist:tag},%{IPORHOST:tld:tag},%{WORD:feed_name:tag},%{GREEDYDATA:duplicateeventstatus}"]

[[inputs.tail]]
    files = ["/var/log/pfblockerng/ip_block.log"]
    data_format = "grok"
    from_beginning = false
    name_suffix = "_ip_block_log"
    grok_timezone = "Local"
    grok_patterns = ["^%{SYSLOGTIMESTAMP:timestamp:ts-syslog},%{NUMBER:rulenum},%{DATA:interface},%{WORD:friendlyname},%{WORD:action},%{NUMBER:ip_version},%{NUMBER:protocolid},%{DATA:protocol:tag},%{IPORHOST:src_ip:tag},%{IPORHOST:dest_ip:tag},%{WORD:src_port:tag},%{NUMBER:dest_port:tag},%{WORD:direction},%{WORD:geoip_code:tag},%{DATA:ip_alias_name},%{DATA:ip_evaluated},%{DATA:feed_name:tag},%{HOSTNAME:resolvedhostname},%{GREEDYDATA:clienthostname},%{GREEDYDATA:ASN},%{GREEDYDATA:duplicateeventstatus}"]

Alle pfsense systeem logs worden naar Alloy verzonden waar ze verwerkt worden tot bruikbare logentries en opgeslagen in Loki. In grafana is een [pfsense dashboard](https:// welke alle data samenbrengt.

graph TD
    FW1[firewall]
    FW2[internal processing]
    PC1([Alloy])
    PC2([Telegraf])
    DS1[(InfluxDB)]
    DS2[(Loki)]
    VS1([Grafana])

    FW1 --> FW2
    FW1 --> PC1
    FW1 --> PC2
    FW2 --> DS1
    PC1 --> DS2 
    PC2 --> DS1
    DS1 --- VS1
    DS2 --- VS1

Synology

De synology apparatuur wordt gemonitored door middel van een snmp scraper in telegraf, deze stuurt alle informatie door naar influxDB, in grafana is een Synology dashboard welke alle data samenbrengt.

graph LR
    SY1[Synology]
    PC1([Telegraf])
    DS1[(InfluxDB)]
    VS1([Grafana])

    SY1 --> PC1
    PC1 --> DS1
    DS1 --> VS1

Kubernetes

Het kubernetes cluster en alle nodes worden gemonitored door middel van een telegraf scraper Kubernetes inventory deze verzamelt alle relevante data en stuurt dit naar influxDB in grafana is een Kubernetes dashboard welke de juiste inzichten geeft.

graph LR
    SY1[Kubernetes]
    PC1([Telegraf])
    DS1[(InfluxDB)]
    VS1([Grafana])

    SY1 --> PC1
    PC1 --> DS1
    DS1 --> VS1

Core switches

De netwerk apparatuur wordt gemonitored door middel van een snmp scraper in telegraf, deze stuurt alle informatie door naar influxDB, in grafana is een network dashboard welke alle data samenbrengt.

graph LR
    SY1[C-MK-01]
    SY2[C-ZK-01]
    PC1([Telegraf])
    DS1[(InfluxDB)]
    VS1([Grafana])

    SY1 --> PC1
    SY2 --> PC1
    PC1 --> DS1
    DS1 --> VS1

    click SY1 "../Networking/c-mk-01.md"
    click SY2 "../Networking/c-zk-01.md"

Unifi

De netwerk apparatuur wordt gemonitored door middel van een poller container, deze stuurt alle informatie door naar influxDB, in grafana zijn meerdere unifi dashboards beschikbaar die alle data samenbrengt.

graph LR
    SY1[Unifi]
    PC1([unifi poller])
    DS1[(InfluxDB)]
    VS1([Grafana])

    SY1 --> PC1
    PC1 --> DS1
    DS1 --> VS1

    click SY1 "../Networking/unifi.md"

SmartMeter

De smartmeter wordt uitgelezen door middel van een Raspberry Pi documentatie is hier te vinden.

graph LR
    SY1[Smartmeter]
    PC1([mqtt])
    PC2([nodered])
    DS1[(InfluxDB)]
    VS1([Grafana])

    SY1 --> PC1
    PC1 --> PC2
    PC2 --> DS1
    DS1 --> VS1

    click SY1 "../Networking/unifi.md"

nodered polt de mqtt omgeving voor nieuwe berichten en plaatst deze in de influxDB database.

mqtt flow

Collect and process

Log data moet verzameld en opgeschoond worden voordat deze opgeslagen kan worden, hiervoor zijn een aantal collectors en processors aangemaakt.

Unifi Poller

Een specifieke collector voor unifi controllers, deze kan data naar verschillende storage sturen. Informatie en configuratie : unifi poller

Telegraf

Telegraf is een scraper gemaakt door influxdata, een algemene beschrijving en documentatie is hier te vinden. De volgende outputs zijn actief, deze verwijzen allemaal naar dezelfde influxdb instantie en er wordt gefiltert op een naam om de juiste bucket toe te wijzen.

telegraf.conf
 [[outputs.influxdb_v2]]
  urls = ["https://influxdb.loevencloud.nl"]
  token = "<token>"
  organization = "Loevencloud"
  bucket = "snmp"
  namepass = ["snmp.*"]

 [[outputs.influxdb_v2]]
  urls = ["https://influxdb.loevencloud.nl"]
  token = "<token>"
  organization = "Loevencloud"
  bucket = "networking"
  namepass = ["networking.*"]

 [[outputs.influxdb_v2]]
  urls = ["https://influxdb.loevencloud.nl"]
  token = "<token>"
  organization = "Loevencloud"
  bucket = "aks"
  namepass = ["kubernetes*"]

Omdat snmp gebruikt wordt moeten er MIBs beschikbaar zijn in de telegraf container. er is een mountpoint /mib beschikbaar waar ik alle MIB bestanden (standaard SNMP + IP + SYNOLOGY) beschikbaar stel. In zowel de input als in /etc/snmp/snmp.conf

snmp.conf
1
2
3
4
5
6
mibdirs +/usr/share/snmp/mibs
mibdirs +/usr/share/snmp/mibs/iana
mibdirs +/usr/share/snmp/mibs/ietf
mibdirs +/mib

mibs +ALL

De volgende inputs zijn geconfigureerd, deze bestanden worden geplaatst in /etc/telegraf/telegraf.d

kubernetes.conf
1
2
3
4
5
6
7
# Read metrics from the Kubernetes api
[[inputs.kube_inventory]]
  ## URL for the Kubernetes API.
  ## If empty in-cluster config with POD's service account token will be used.
  url = "https://jarvis.loevencloud.nl/k8s/clusters/local"
  namespace = ""
  bearer_token = "/configdata/token"
networking.conf
[[inputs.snmp]]
  agents = ["10.0.0.2", "10.0.0.3"]  # 
  interval = "30s"
  timeout = "30s"
  retries = 3
  max_repetitions = 10
  version = 3
  sec_name = ""  # Replace with your security username
  auth_protocol = "SHA512"    # Or MD5, depending on your setup
  auth_password = ""  # Replace with your auth password
  sec_level = "authPriv"
  priv_protocol = "AES"    # Or AES, depending on your setup
  priv_password = ""  # Replace with your privacy password
  name = "networking.core"
  path = ["/mib"]

  [[inputs.snmp.field]]
  name = "sysName"
  oid = "SNMPv2-MIB::sysName.0"

  [[inputs.snmp.field]]
  name = "sysLocation"
  oid = "SNMPv2-MIB::sysLocation.0"

  [[inputs.snmp.field]]
  name = "sysUpTime"
  oid = "DISMAN-EVENT-MIB::sysUpTimeInstance"

  [[inputs.snmp.field]]
  name = "sysDescr"
  oid = "SNMPv2-MIB::sysDescr.0"

  [[inputs.snmp.table]]
  name = "networking.interface"
  oid = "IF-MIB::ifTable"

    [[inputs.snmp.table.field]]
    name = "ifIndex"
    oid = "IF-MIB::ifIndex"
    is_tag = true

    [[inputs.snmp.table.field]]
    name = "ifDescr"
    oid = "IF-MIB::ifDescr"

    [[inputs.snmp.table.field]]
    name = "ifType"
    oid = "IF-MIB::ifType"

    [[inputs.snmp.table.field]]
    name = "ifMtu"
    oid = "IF-MIB::ifMtu"

    [[inputs.snmp.table.field]]
    name = "ifSpeed"
    oid = "IF-MIB::ifSpeed"

    [[inputs.snmp.table.field]]
    name = "ifPhysAddress"
    oid = "IF-MIB::ifPhysAddress"

    [[inputs.snmp.table.field]]
    name = "ifAdminStatus"
    oid = "IF-MIB::ifAdminStatus"

    [[inputs.snmp.table.field]]
    name = "ifOperStatus"
    oid = "IF-MIB::ifOperStatus"

    [[inputs.snmp.table.field]]
    name = "ifLastChange"
    oid = "IF-MIB::ifLastChange"

    [[inputs.snmp.table.field]]
    name = "ifInOctets"
    oid = "IF-MIB::ifInOctets"

    [[inputs.snmp.table.field]]
    name = "ifInUcastPkts"
    oid = "IF-MIB::ifInUcastPkts"

    [[inputs.snmp.table.field]]
    name = "ifInNUcastPkts"
    oid = "IF-MIB::ifInNUcastPkts"

    [[inputs.snmp.table.field]]
    name = "ifInDiscards"
    oid = "IF-MIB::ifInDiscards"

    [[inputs.snmp.table.field]]
    name = "ifInErrors"
    oid = "IF-MIB::ifInErrors"

    [[inputs.snmp.table.field]]
    name = "ifOutOctets"
    oid = "IF-MIB::ifOutOctets"

    [[inputs.snmp.table.field]]
    name = "ifOutUcastPkts"
    oid = "IF-MIB::ifOutUcastPkts"

    [[inputs.snmp.table.field]]
    name = "ifOutNUcastPkts"
    oid = "IF-MIB::ifOutNUcastPkts"

    [[inputs.snmp.table.field]]
    name = "ifOutDiscards"
    oid = "IF-MIB::ifOutDiscards"

    [[inputs.snmp.table.field]]
    name = "ifName"
    oid = "IF-MIB::ifName"
synology.conf
  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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
[[inputs.snmp]]
  agents = ["syn04.loevencloud.nl"]  # Replace with your Synology IP address
  interval = "30s"
  timeout = "30s"
  retries = 3
  max_repetitions = 10
  version = 3
  sec_name = ""  # Replace with your security username
  auth_protocol = "SHA"      # Or MD5, depending on your setup
  auth_password = ""  # Replace with your auth password
  sec_level = "authPriv"
  priv_protocol = "DES"      # Or AES, depending on your setup
  priv_password = ""  # Replace with your privacy password
  name = "snmp.Synology"
  path = ["/mib"]

  [[inputs.snmp.field]]
    name = "sysName"
    oid = "SNMPv2-MIB::sysName.0"
    is_tag = true

  [[inputs.snmp.field]]
    name = "sysDescr"
    oid = "SNMPv2-MIB::sysDescr.0"

  [[inputs.snmp.field]]
    name = "sysContact"
    oid = "SNMPv2-MIB::sysContact.0"

  [[inputs.snmp.field]]
    name = "sysLocation"
    oid = "SNMPv2-MIB::sysLocation.0"

  [[inputs.snmp.field]]
    name = "sysUpTime"
    oid = "SNMPv2-MIB::sysUpTime.0"

#
# UCD-SNMP-MIB::systemStats
# -------------------------
#

    [[inputs.snmp.field]]
        name = "systemStats.ssSwapIn"
        oid = "UCD-SNMP-MIB::ssSwapIn.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssSwapOut"
        oid = "UCD-SNMP-MIB::ssSwapOut.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssIOSent"
        oid = "UCD-SNMP-MIB::ssIOSent.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssIOReceive"
        oid = "UCD-SNMP-MIB::ssIOReceive.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssSysInterrupts"
        oid = "UCD-SNMP-MIB::ssSysInterrupts.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssSysContext"
        oid = "UCD-SNMP-MIB::ssSysContext.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuUser"
        oid = "UCD-SNMP-MIB::ssCpuUser.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuSystem"
        oid = "UCD-SNMP-MIB::ssCpuSystem.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuIdle"
        oid = "UCD-SNMP-MIB::ssCpuIdle.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawUser"
        oid = "UCD-SNMP-MIB::ssCpuRawUser.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawNice"
        oid = "UCD-SNMP-MIB::ssCpuRawNice.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawSystem"
        oid = "UCD-SNMP-MIB::ssCpuRawSystem.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawIdle"
        oid = "UCD-SNMP-MIB::ssCpuRawIdle.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawWait"
        oid = "UCD-SNMP-MIB::ssCpuRawWait.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawKernel"
        oid = "UCD-SNMP-MIB::ssCpuRawKernel.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawInterrupt"
        oid = "UCD-SNMP-MIB::ssCpuRawInterrupt.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssIORawSent"
        oid = "UCD-SNMP-MIB::ssIORawSent.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssIORawReceived"
        oid = "UCD-SNMP-MIB::ssIORawReceived.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssRawInterrupts"
        oid = "UCD-SNMP-MIB::ssRawInterrupts.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssRawContexts"
        oid = "UCD-SNMP-MIB::ssRawContexts.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawSoftIRQ"
        oid = "UCD-SNMP-MIB::ssCpuRawSoftIRQ.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssRawSwapIn"
        oid = "UCD-SNMP-MIB::ssRawSwapIn.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssRawSwapOut"
        oid = "UCD-SNMP-MIB::ssRawSwapOut.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawSteal"
        oid = "UCD-SNMP-MIB::ssCpuRawSteal.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawGuest"
        oid = "UCD-SNMP-MIB::ssCpuRawGuest.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuRawGuestNice"
        oid = "UCD-SNMP-MIB::ssCpuRawGuestNice.0"

    [[inputs.snmp.field]]
        name = "systemStats.ssCpuNumCpus"
        oid = "UCD-SNMP-MIB::ssCpuNumCpus.0"

#
# UCD-SNMP-MIB::memory
# --------------------

  [[inputs.snmp.field]]
    name = "memory.memTotalSwap"
    oid = "UCD-SNMP-MIB::memTotalSwapX.0"

  [[inputs.snmp.field]]
    name = "memory.memAvailSwap"
    oid = "UCD-SNMP-MIB::memAvailSwapX.0"

  [[inputs.snmp.field]]
    name = "memory.memTotalReal"
    oid = "UCD-SNMP-MIB::memTotalRealX.0"

  [[inputs.snmp.field]]
    name = "memory.memAvailReal"
    oid = "UCD-SNMP-MIB::memAvailRealX.0"

  [[inputs.snmp.field]]
    name = "memory.memTotalFree"
    oid = "UCD-SNMP-MIB::memTotalFreeX.0"

  [[inputs.snmp.field]]
    name = "memory.memMinimumSwap"
    oid = "UCD-SNMP-MIB::memMinimumSwapX.0"

  [[inputs.snmp.field]]
    name = "memory.memShared"
    oid = "UCD-SNMP-MIB::memSharedX.0"

  [[inputs.snmp.field]]
    name = "memory.memBuffer"
    oid = "UCD-SNMP-MIB::memBufferX.0"

  [[inputs.snmp.field]]
    name = "memory.memCached"
    oid = "UCD-SNMP-MIB::memCachedX.0"

#
# HOST-RESOURCES-MIB::hrSystem
# ----------------------------
#

  [[inputs.snmp.field]]
    name = "hrSystem.hrSystemUptime"
    oid = "HOST-RESOURCES-MIB::hrSystemUptime.0"

  [[inputs.snmp.field]]
    name = "hrSystem.hrSystemNumUsers"
    oid = "HOST-RESOURCES-MIB::hrSystemNumUsers.0"

  [[inputs.snmp.field]]
    name = "hrSystem.hrSystemProcesses"
    oid = "HOST-RESOURCES-MIB::hrSystemProcesses.0"

#
# SYNOLOGY-SYSTEM-MIB::synoSystem
# -------------------------------
#

  [[inputs.snmp.field]]
    name = "synoSystem.systemStatus"
    oid = "SYNOLOGY-SYSTEM-MIB::systemStatus.0"

  [[inputs.snmp.field]]
    name = "synoSystem.temperature"
    oid = "SYNOLOGY-SYSTEM-MIB::temperature.0"

  [[inputs.snmp.field]]
    name = "synoSystem.powerStatus"
    oid = "SYNOLOGY-SYSTEM-MIB::powerStatus.0"

  [[inputs.snmp.field]]
    name = "synoSystem.systemFanStatus"
    oid = "SYNOLOGY-SYSTEM-MIB::systemFanStatus.0"

  [[inputs.snmp.field]]
    name = "synoSystem.cpuFanStatus"
    oid = "SYNOLOGY-SYSTEM-MIB::cpuFanStatus.0"

  [[inputs.snmp.field]]
    name = "synoSystem.modelName"
    oid = "SYNOLOGY-SYSTEM-MIB::modelName.0"

  [[inputs.snmp.field]]
    name = "synoSystem.serialNumber"
    oid = "SYNOLOGY-SYSTEM-MIB::serialNumber.0"

  [[inputs.snmp.field]]
    name = "synoSystem.version"
    oid = "SYNOLOGY-SYSTEM-MIB::version.0"

  [[inputs.snmp.field]]
    name = "synoSystem.upgradeAvailable"
    oid = "SYNOLOGY-SYSTEM-MIB::upgradeAvailable.0"


# Load average
[[inputs.snmp.table]]
  oid = "UCD-SNMP-MIB::laTable"
  name = "snmp.Synology.load"
  [[inputs.snmp.table.field]]
    oid = "UCD-SNMP-MIB::laNames"
    is_tag = true

# Network interface
[[inputs.snmp.table]]
  oid = "IF-MIB::ifTable"
  name = "snmp.Synology.network"
  [[inputs.snmp.table.field]]
    oid = "IF-MIB::ifDescr"
    is_tag = true

[[inputs.snmp.table]]
  oid = "IF-MIB::ifXTable"
  name = "snmp.Synology.network"
  [[inputs.snmp.table.field]]
    oid = "IF-MIB::ifName"
    is_tag = true

# System volume
[[inputs.snmp.table]]
  oid = "HOST-RESOURCES-MIB::hrStorageTable"
  name = "snmp.Synology.volume"
  [[inputs.snmp.table.field]]
    oid = "HOST-RESOURCES-MIB::hrStorageDescr"
    is_tag = true

# Disk
[[inputs.snmp.table]]
    oid = "SYNOLOGY-DISK-MIB::diskTable"
    name = "snmp.Synology.disk"

    [[inputs.snmp.table.field]]
        oid = "SYNOLOGY-DISK-MIB::diskID"
        is_tag = true

# RAID
[[inputs.snmp.table]]
  oid = "SYNOLOGY-RAID-MIB::raidTable"
  name = "snmp.Synology.raid"
  [[inputs.snmp.table.field]]
    oid = "SYNOLOGY-RAID-MIB::raidName"
    is_tag = true

# SSD cache
[[inputs.snmp.table]]
  oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheTable"
  name = "snmp.Synology.cache"
  [[inputs.snmp.table.field]]
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheSpaceDev"
    is_tag = true

# S.M.A.R.T.
[[inputs.snmp.table]]
  oid = "SYNOLOGY-SMART-MIB::diskSMARTTable"
  name = "snmp.Synology.smart"
  [[inputs.snmp.table.field]]
    oid = "SYNOLOGY-SMART-MIB::diskSMARTInfoDevName"
    is_tag = true
  [[inputs.snmp.table.field]]
    oid = "SYNOLOGY-SMART-MIB::diskSMARTAttrName"
    is_tag = true

# Space IO
[[inputs.snmp.table]]
  oid = "SYNOLOGY-SPACEIO-MIB::spaceIOTable"
  name = "snmp.Synology.spaceIO"
  [[inputs.snmp.table.field]]
    oid = "SYNOLOGY-SPACEIO-MIB::spaceIODevice"
    is_tag = true

# Storage IO
[[inputs.snmp.table]]
  oid = "SYNOLOGY-STORAGEIO-MIB::storageIOTable"
  name = "snmp.Synology.storageIO"
  [[inputs.snmp.table.field]]
    oid = "SYNOLOGY-STORAGEIO-MIB::storageIODevice"
    is_tag = true

# eBox Information from SYNOLOGY-EBOX-MIB
[[inputs.snmp.table]]
  name = "snmp.Synology.ebox"
  oid = "SYNOLOGY-EBOX-MIB::eboxTable"

  [[inputs.snmp.table.field]]
    name = "snmp.Synology.ebox.eboxIndex"
    oid = "SYNOLOGY-EBOX-MIB::eboxIndex"

  [[inputs.snmp.table.field]]
    name = "snmp.Synology.ebox.eboxModel"
    oid = "SYNOLOGY-EBOX-MIB::eboxModel"

  [[inputs.snmp.table.field]]
    name = "snmp.Synology.ebox.eboxPower"
    oid = "SYNOLOGY-EBOX-MIB::eboxPower"

  [[inputs.snmp.table.field]]
    name = "snmp.Synology.ebox.eboxRedundantPower"
    oid = "SYNOLOGY-EBOX-MIB::eboxRedundantPower"

# Flash Cache Information from SYNOLOGY-FLASHCACHE-MIB
[[inputs.snmp.table]]
  name = "snmp.Synology.flashcache"
  oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheTable"

  # Index
  [[inputs.snmp.table.field]]
    name = "flashCacheIndex"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheIndex"

  # SSD Device
  [[inputs.snmp.table.field]]
    name = "flashCacheSSDDev"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheSSDDev"

  # Space Device
  [[inputs.snmp.table.field]]
    name = "flashCacheSpaceDev"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheSpaceDev"

  # Read Hits
  [[inputs.snmp.table.field]]
    name = "flashCacheReadHits"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheReadHits"

  # Write Hits
  [[inputs.snmp.table.field]]
    name = "flashCacheWriteHits"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheWriteHits"

  # Total Read
  [[inputs.snmp.table.field]]
    name = "flashCacheTotalRead"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheTotalRead"

  # Total Write
  [[inputs.snmp.table.field]]
    name = "flashCacheTotalWrite"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheTotalWrite"

  # Read Hit Rate
  [[inputs.snmp.table.field]]
    name = "flashCacheReadHitRate"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheReadHitRate"

  # Write Hit Rate
  [[inputs.snmp.table.field]]
    name = "flashCacheWriteHitRate"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheWriteHitRate"

  # SSD UUID
  [[inputs.snmp.table.field]]
    name = "flashCacheSsdUuid"
    oid = "SYNOLOGY-FLASHCACHE-MIB::flashCacheSsdUuid"

# GPU Information from SYNOLOGY-GPUINFO-MIB
[[inputs.snmp.table]]
  name = "snmp.Synology.gpu"

  # GPU Utilization
  [[inputs.snmp.table.field]]
    name = "gpuUtilization"
    oid = "SYNOLOGY-GPUINFO-MIB::gpuUtilization"

  # GPU Memory Utilization
  [[inputs.snmp.table.field]]
    name = "gpuMemoryUtilization"
    oid = "SYNOLOGY-GPUINFO-MIB::gpuMemoryUtilization"

  # GPU Free Memory
  [[inputs.snmp.table.field]]
    name = "gpuMemoryFree"
    oid = "SYNOLOGY-GPUINFO-MIB::gpuMemoryFree"

  # GPU Used Memory
  [[inputs.snmp.table.field]]
    name = "gpuMemoryUsed"
    oid = "SYNOLOGY-GPUINFO-MIB::gpuMemoryUsed"

  # GPU Total Memory
  [[inputs.snmp.table.field]]
    name = "gpuMemoryTotal"
    oid = "SYNOLOGY-GPUINFO-MIB::gpuMemoryTotal"

# iSCSI LUN Information from SYNOLOGY-ISCSILUN-MIB
[[inputs.snmp.table]]
  name = "snmp.Synology.iscsilun"
  oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNTable"

  # LUN Index
  [[inputs.snmp.table.field]]
    name = "iSCSILUNInfoIndex"
    oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNInfoIndex"

  # LUN UUID
  [[inputs.snmp.table.field]]
    name = "iSCSILUNUUID"
    oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNUUID"

  # LUN Name
  [[inputs.snmp.table.field]]
    name = "iSCSILUNName"
    oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNName"

  # LUN Read Throughput (High and Low for 64-bit counter)
  [[inputs.snmp.table.field]]
    name = "iSCSILUNThroughputReadHigh"
    oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNThroughputReadHigh"
  [[inputs.snmp.table.field]]
    name = "iSCSILUNThroughputReadLow"
    oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNThroughputReadLow"

  # LUN Write Throughput (High and Low for 64-bit counter)
  [[inputs.snmp.table.field]]
    name = "iSCSILUNThroughputWriteHigh"
    oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNThroughputWriteHigh"
  [[inputs.snmp.table.field]]
    name = "iSCSILUNThroughputWriteLow"
    oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNThroughputWriteLow"

  # LUN IOPS for Read and Write
  [[inputs.snmp.table.field]]
    name = "iSCSILUNIopsRead"
    oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNIopsRead"
  [[inputs.snmp.table.field]]
    name = "iSCSILUNIopsWrite"
    oid = "SYNOLOGY-ISCSILUN-MIB::iSCSILUNIopsWrite"

# iSCSI Target Information from SYNOLOGY-ISCSITarget-MIB
[[inputs.snmp.table]]
  name = "snmp.Synology.iscsitarget"
  oid = "SYNOLOGY-ISCSITarget-MIB::iSCSITargetTable"

  # iSCSI Target Name
  [[inputs.snmp.table.field]]
    name = "iSCSITargetName"
    oid = "SYNOLOGY-ISCSITarget-MIB::iSCSITargetName"

  # iSCSI Target IQN
  [[inputs.snmp.table.field]]
    name = "iSCSITargetIQN"
    oid = "SYNOLOGY-ISCSITarget-MIB::iSCSITargetIQN"

  # iSCSI Target Connection Status
  [[inputs.snmp.table.field]]
    name = "iSCSITargetConnectionStatus"
    oid = "SYNOLOGY-ISCSITarget-MIB::iSCSITargetConnectionStatus"

# Synology Services Monitoring
[[inputs.snmp.table]]
  name = "snmp.Synology.services"
  oid = "SYNOLOGY-SERVICES-MIB::serviceTable"

  [[inputs.snmp.table.field]]
    name = "serviceName"
    oid = "SYNOLOGY-SERVICES-MIB::serviceName"
    is_tag = true

  [[inputs.snmp.table.field]]
    name = "serviceUsers"
    oid = "SYNOLOGY-SERVICES-MIB::serviceUsers"

# Synology High-Availability (SHA) Monitoring

  [[inputs.snmp.field]]
    name = "ha.activeNodeName"
    oid = "SYNOLOGY-SHA-MIB::activeNodeName"

  [[inputs.snmp.field]]
    name = "ha.passiveNodeName"
    oid = "SYNOLOGY-SHA-MIB::passiveNodeName"

  [[inputs.snmp.field]]
    name = "ha.clusterAutoFailover"
    oid = "SYNOLOGY-SHA-MIB::clusterAutoFailover"

  [[inputs.snmp.field]]
    name = "ha.clusterName"
    oid = "SYNOLOGY-SHA-MIB::clusterName"

  [[inputs.snmp.field]]
    name = "ha.clusterStatus"
    oid = "SYNOLOGY-SHA-MIB::clusterStatus"

  [[inputs.snmp.field]]
    name = "ha.heartbeatStatus"
    oid = "SYNOLOGY-SHA-MIB::heartbeatStatus"

  [[inputs.snmp.field]]
    name = "ha.heartbeatTxRate"
    oid = "SYNOLOGY-SHA-MIB::heartbeatTxRate"

  [[inputs.snmp.field]]
    name = "ha.heartbeatLatency"
    oid = "SYNOLOGY-SHA-MIB::heartbeatLatency"

Grafana Alloy

Alloy is de "opvolger" van promtail en dient als een globale collector en processor van bijvoorbeeld syslog content. Alloy documentatie is hier te vinden. Op dit moment verzamelt alloy alleen firewall regels en pushed deze richting loki.

config.alloy
logging {
  level  = "info"
  format = "logfmt"
}
loki.write "local" {
  endpoint {
    url = "http://loki.loevencloud.svc.cluster.local:3100/loki/api/v1/push"
  }
}
loki.source.syslog "pfsenseListener" {
  listener {
    address  = "0.0.0.0:51893"
    labels   = { component = "pfSense", protocol = "tcp" }
  }
  forward_to = [loki.process.pf_sense_firewall_rules.receiver]
}

loki.process "pf_sense_firewall_rules" {
  stage.json {
    expressions = {
      rule_number = "rule_number",
      action = "action",
      protocol = "protocol",
      direction = "direction",
      src_ip = "src_ip",
      src_port = "src_port",
      dst_ip = "dst_ip",
      dst_port = "dst_port",
      tcp_flags = "tcp_flags",
      interface = "interface",
    }
  }
  stage.labels {
    values = {
      rule_number = "",
      action = "",
      protocol = "",
      direction = "",
      src_ip = "",
      src_port = "",
      dst_ip = "",
      dst_port = "",
      tcp_flags = "",
      interface = "",
      time = "",
    }
  }
  forward_to = [loki.write.local.receiver]
}

MQTT

MQTT (Message Queuing Telemetry Transport) wordt gebruikt om berichten van IoT devices op te slaan, hiervoor wordt een eclipse-mosquitto container gebruikt.

Node-red

nodered is een automation tool, documentatie is hier te vinden.

Storage

Logs moeten uiteraard opgeslagen worden, hiervoor zijn een aantal opslag locaties aanwezig.

InfluxDB

InfluxDB is een time series database (TSDB) welke het mogelijk maakt grote hoeveelheden time series data snel en accuraat beschikbaar te stellen.
loevencloud influxDB

Implementatie en documentatie

Binnen influxDB worden buckets aangemaakt welke de time series data bevatten:

bucket retentie omschrijving
default 5 dagen default bucket
aks forever Kubernetes logdata
influx-metrics forever Influxdb metrics
mqtt forever mqtt data (nodered / smartmeter)
networking forever switch logs
pfsense 365 dagen pfsense system en firewall logs
snmp forever snmp scraper logs (switches/synology)
syslog forever pure syslog
unifi forever unifi controller logs
weer forever weer data (via nodered)

Postgres

Postgres database beschikbaar voor logging, op dit moment niet in gebruik voor logs. Documentatie is hier te vinden.

MySql

Mysql database beschikbaar voor logging, op dit moment worden hier alleen joblogs vanuit Azure functions opgeslagen. Documentatie is hier te vinden.

Loki

Loki is een storage locatie voor syslog logs. Documentatie is hier te vinden.

Visualization

Nadat alle data is verzameld moet deze uiteraard ook weergegeven worden in een dashboard.

Grafana

Grafana is een visualisatie tool waarmee data inzichten verkregen kunnen worden.

loevencloud dashboards
grafana documentatie

Alerting

Alert Manager

NNI

Pushover

pushover wordt gebruikt om meldingen door te zetten naar de mobiele app.

pushover docs