maxwo/snmp_notifier

How to get label when the alert is resolved ?

PetitCedric opened this issue · 1 comments

What did you do?
{{- if .Alerts -}}
{{- range $severity, $alerts := (groupAlertsByLabel .Alerts "severity") -}}
Status: {{ $severity }}
{{- range $index, $alert := $alerts }}

  • Alert: {{ $alert.Labels.alertname }}
    Category: {{ $alert.Labels.category }}
    Data environment: {{ $alert.Labels.source_environment }}
    Topic: {{ $alert.Labels.topic }}
    Index: {{ $alert.Labels.index }}
    Source: {{ $alert.Labels.source }}
    NODE: {{ $alert.Labels.node }}
    Source Environment: {{ $alert.Labels.env }}
    Severity: {{ $alert.Labels.severity }}
    MetricName: {{ $alert.Labels.metricname }}
    CI_ID: {{ $alert.Labels.ci }}
    SUMMARY: {{ $alert.Annotations.summary }}
    {{ end }}
    {{ end }}
    {{ else -}}
    Status: Ok
    {{- end -}}
    What did you expect to see?
    "SNMPv2-SMI::enterprises.4445.1.4978.3": "Status: resolved
  • Alert: logstash_monitoring_down
    Category: instances
    Source: prometheus
    NODE: server
    Source Environment: lab
    Severity: error
    MetricName: logstash_monitoring_down
    CI_ID: logstash_server
    SUMMARY: lab: Service of monitoring logstash-exporter is down on server on port 9651.",
    What did you see instead? Under which circumstances?
    "SNMPv2-SMI::enterprises.4445.1.4978.3": "Status: resolved
    Environment
    lab
  • System information:

    Linux 3.10.0-1062.4.3.el7.x86_64 x86_64

  • SNMP notifier version:

    snmp_notifier, version 1.2.1 (branch: HEAD, revision: 73773b7)
    build user: root@4c095c7fad1b
    build date: 20210820-08:20:04
    go version: go1.16
    platform: linux/amd64

  • Alertmanager version:

    alertmanager, version 0.20.0 (branch: HEAD, revision: f74be0400a6243d10bb53812d6fa408ad71ff32d)
    build user: root@00c3106655f8
    build date: 20191211-14:13:14
    go version: go1.13.5

  • Prometheus version:

    prometheus, version 2.14.0 (branch: HEAD, revision: edeb7a44cbf745f1d8be4ea6f215e79e651bfe19)
    build user: root@df2327081015
    build date: 20191111-14:27:12
    go version: go1.13.4

maxwo commented

This may indeed be useful. A PR is available, but it may require a bit more to ensure all cases are taken into account.