Fix Alerts Integration custom field mapping
Summary
Certain fields of the GitLab alert key are not reflected properly in the the Alert list and the Alert Details page even if they are parsed and mapped properly.
Steps to reproduce
Steps to reproduce:
-
Go to any project -> Settings -> Alerts
-
Click "Create new integration" and choose an integration of type "HTTP Endpoint".
-
Give the integration the name "test" and enable the integration
-
Set the mapping "Environment" == alerts[0].labels.environment
-
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://gitlab.com/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)