jiralert icon indicating copy to clipboard operation
jiralert copied to clipboard

Jiralert duplicates defects

Open Wojtek33 opened this issue 5 years ago • 4 comments

Thank you for your hard work and great project!

Unfortunately we have found an issue in 1.0.

In our case, when the JiraAlert is triggered by the Alertmanager, it creates new Jira defect, without adding additional Label. For example if the service is down Jira Alert uses the label like: ALERT{alertname="ServiceDown",namespace="",service_name=""} which should already be added to Defect.

Every time the JiraAlert is triggered before creating new defect it searches for existing ones. It uses query – which is the Label which should have been added during the creation of the defect. The query nothing returns, therefore JiraAlert creates new defect rather then updating it.

See the logs below:

•	I1017 15:19:32.510837       8 notify.go:115] Issue created: key=SPRINT-25234 ID=6505526
•	I1017 19:20:50.423961       8 notify.go:74] No issue matching ALERT{alertname="ServiceDown",namespace="***",service_name="***"} found, creating new issue
•	I1017 19:20:51.020082       8 notify.go:115] Issue created: key=SPRINT-25235 ID=6505716
•	I1017 23:22:13.671601       8 notify.go:74] No issue matching ALERT{alertname="ServiceDown",namespace="***",service_name="***"} found, creating new issue
•	I1017 23:22:14.337028       8 notify.go:115] Issue created: key=SPRINT-25238 ID=6505766
•	I1018 03:23:31.037384       8 notify.go:74] No issue matching ALERT{alertname="ServiceDown",namespace="***",service_name="***"} found, creating new issue
•	I1018 03:23:31.718012       8 notify.go:115] Issue created: key=SPRINT-25240 ID=6505911
•	I1018 07:25:00.828099       8 notify.go:74] No issue matching ALERT{alertname="ServiceDown",namespace="***",service_name="***"} found, creating new issue
•	I1018 07:25:01.558600       8 notify.go:115] Issue created: key=SPRINT-25241 ID=6506001
•	I1018 11:26:30.193346       8 notify.go:74] No issue matching ALERT{alertname="ServiceDown",namespace="***",service_name="***"} found, creating new issue
•	I1018 11:26:30.864185       8 notify.go:115] Issue created: key=SPRINT-25242 ID=6506149
•	I1018 15:27:30.113821       8 notify.go:74] No issue matching ALERT{alertname="ServiceDown",namespace="***",service_name="***"} found, creating new issue
•	I1018 15:27:31.282052       8 notify.go:115] Issue created: key=SPRINT-25244 ID=6506319
•	I1018 19:28:06.189205       8 notify.go:74] No issue matching ALERT{alertname="ServiceDown",namespace="***",service_name="***"} found, creating new issue
•	I1018 19:28:07.001398       8 notify.go:115] Issue created: key=SPRINT-25245 ID=6506630
•	I1018 23:28:54.166905       8 notify.go:74] No issue matching ALERT{alertname="ServiceDown",namespace="***",service_name="***"} found, creating new issue
•	I1018 23:28:54.728162       8 notify.go:115] Issue created: key=SPRINT-25247 ID=6506923
•	I1019 03:29:51.075680       8 notify.go:74] No issue matching ALERT{alertname="ServiceDown",namespace="***",service_name="***"} found, creating new issue

The issue causes that many duplicates is created as long as the Label is not added manually. Below, the part of code that should be checked.

notify.go

log.Infof("No issue matching %s found, creating new issue", issueLabel)
	issue = &jira.Issue{
		Fields: &jira.IssueFields{
			Project:     jira.Project{Key: project},
			Type:        jira.IssueType{Name: r.tmpl.Execute(r.conf.IssueType, data)},
			Description: r.tmpl.Execute(r.conf.Description, data),
			Summary:     r.tmpl.Execute(r.conf.Summary, data),
			Labels: []string{
				issueLabel,
			},
			Unknowns: tcontainer.NewMarshalMap(),
		},
	}

Thank you for help in advance!

Wojtek33 avatar Oct 23 '20 09:10 Wojtek33

I haved the same probleme,

try to add in prometheus conf group_by[...,namespace,service_name] and normaly, the probleme will by solved

Haazeel avatar Oct 26 '20 10:10 Haazeel

@Haazeel your solution didn't worked for us, but it helped to remove label configuration from jiralert config file. Looks like the custom label replaces the labels from alert instead of being added to them. We will now use some workaround to group issues in jira instead of that label and keep the original labels from alert untouched.

defaults:
  # [...]
  # Add custom fields to all alerts
  fields:
    # labels
    # labels: ["Custom_Label"] <-- this replaces original labels from alert instead of being added and is direct reason of the mentioned issue with searching for duplicates

TouDick avatar Nov 03 '20 16:11 TouDick

Looks like a valid bug, help wanted to fix it 🤗

bwplotka avatar Mar 05 '21 12:03 bwplotka

Just want to note here that the workaround here (https://github.com/prometheus-community/jiralert/issues/38#issuecomment-500214070) does not work with the new label generation.

I am not sure if there is a way to get the new JIRALERT{<hash>} label on the template level.

longtomjr avatar Feb 27 '23 10:02 longtomjr