Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prom2teams parses only the first received alarm #26

Closed
jnogol opened this issue Nov 3, 2017 · 0 comments
Closed

Prom2teams parses only the first received alarm #26

jnogol opened this issue Nov 3, 2017 · 0 comments
Assignees
Labels

Comments

@jnogol
Copy link
Collaborator

jnogol commented Nov 3, 2017

A JSON sent by Prometheus could have this format, with more than one alert:

{
  "receiver": "test_webhook",
  "status": "resolved",
  "alerts": [
    {
      "status": "resolved",
      "labels": {
        "alertname": "DiskSpace",
        "device": "rootfs",
        "fstype": "rootfs",
        "instance": "cs30.evilcorp",
        "job": "fsociety",
        "mountpoint": "/",
        "severity": "severe"
      },
      "annotations": {
        "description": "disk usage 73% on rootfs device",
        "summary": "Disk usage alert on CS30.evilcorp"
      },
      "startsAt": "2015-05-09T07:01:37.803Z",
      "endsAt": "2015-05-09T07:08:37.818278068Z",
      "generatorURL": "my.prometheusserver.url"
    },
    {
      "status": "resolved",
      "labels": {
        "alertname": "DiskSpace",
        "device": "/dev/mapper/vg1-lv1",
        "fstype": "ext4",
        "instance": "cs30.evilcorp",
        "job": "fsociety",
        "mountpoint": "/whiterose",
        "severity": "severe"
      },
      "annotations": {
        "description": "disk usage 52% on /dev/mapper/vg1-lv1 device",
        "summary": "Disk usage alert on cs30.evilcorp"
      },
      "startsAt": "2015-05-09T07:01:37.803Z",
      "endsAt": "2015-05-09T07:08:37.818278068Z",
      "generatorURL": "my.prometheus.url"
    }
  ],
  "groupLabels": {
    "alertname": "DiskSpace",
    "instance": "cs30.evilcorp",
    "severity": "severe"
  },
  "commonLabels": {
    "alertname": "DiskSpace",
    "instance": "cs30.evilcorp",
    "job": "fsociety",
    "severity": "severe"
  },
  "commonAnnotations": {
    "summary": "Disk usage alert on cs30.evilcorp"
  },
  "externalURL": "my.prometheusalertmanager.url",
  "version": "4",
  "groupKey": "{}/{severity=~\"^(?:severe)$\"}:{alertname=\"DiskSpace\", instance=\"cs30.evilcorp\", severity=\"severe\"}"
}

Problem is that prom2teams, in this line https://github.com/idealista/prom2teams/blob/master/prom2teams/message/parser.py#L13 (and I take the blame for that one, didn't expect Prometheus to send more than one alert per JSON) just parses the first alarm.

So parser.py has to be changed, parse more than one alert and then prom2teams should send these alarms (changes needed as well in server.py, I think)

@jnogol jnogol added the bug label Nov 3, 2017
jnogol pushed a commit that referenced this issue Nov 7, 2017
@jnogol jnogol closed this as completed Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant