Skip to content

Alert without annotation "description" doesn't send to discord without throwing errors #15

@thanatchakromsang

Description

@thanatchakromsang

I found this problem while setting up alertmanager-discord in my cluster and tested that It doesn't send to discord and silent leading to investigation consider following Aleart rules

groups:
- name: customized.container.rules
  rules:
  - alert: containerRestarted
    annotations:
      runbook_url: ''
      summary: "More than 2 restarts in a pod {{ $labels.pod }}"
    expr: delta(kube_pod_container_status_restarts_total[5m]) > 2
    for: 5m
    labels:
      severity: critical

It does trigger discord webhook with annotation description not empty though

groups:
- name: customized.container.rules
  rules:
  - alert: containerRestarted
    annotations:
      runbook_url: ''
      summary: "More than 2 restarts in a pod {{ $labels.pod }}"
      description: "{{ $labels.container }} restarted (current value: {{ $value }}s) times in pod {{ $labels.namespace }}/{{ $labels.pod }}"
    expr: delta(kube_pod_container_status_restarts_total[5m]) > 2
    for: 5m
    labels:
      severity: critical

It doesn't have description then when the rules triggered alertmanager firing to webhooks but It does nothing

consider this example alert output from alertmanager to alertmanager-discord. This example doesn't send to discord because It lack annotation description but It does send after alert rules to send description though

{
  "receiver": "webhook",
  "status": "firing",
  "alerts": [
    {
      "status": "firing",
      "labels": {
        "alertname": "Test",
        "dc": "eu-west-1",
        "instance": "localhost:9090",
        "job": "prometheus24"
      },
      "annotations": {
        "summary": "hello",
+       "description": "test"
      },
      "startsAt": "2018-08-03T09:52:26.739266876+02:00",
      "endsAt": "0001-01-01T00:00:00Z",
      "generatorURL": "http://simon-laptop:9090/graph?g0.expr=go_memstats_alloc_bytes+%3E+0\u0026g0.tab=1"                                                                                  
    }
  ],
  "groupLabels": {
    "alertname": "Test",
    "job": "prometheus24"
  },
  "commonLabels": {
    "alertname": "Test",
    "dc": "eu-west-1",
    "instance": "localhost:9090",
    "job": "prometheus24"
  },
  "commonAnnotations": {
    "summary": "hello",
    "description": "some description"
  },
  "externalURL": "http://simon-laptop:9093",
  "version": "4",
  "groupKey": "{}:{alertname=\"Test\", job=\"prometheus24\"}"
}

My question is how should we fix this? Should we just thrown an error when no description or send empty string to discord instead?

Or should we just Update README.md to have a required annotation for alertmanager-discord?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions