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

Jiralert duplicates defects #73

Open
Wojtek33 opened this issue Oct 23, 2020 · 4 comments
Open

Jiralert duplicates defects #73

Wojtek33 opened this issue Oct 23, 2020 · 4 comments

Comments

@Wojtek33
Copy link

Wojtek33 commented Oct 23, 2020

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 Wojtek33 changed the title Duplicated Jira defects Jiralert duplicates defects Oct 23, 2020
@Haazeel
Copy link

Haazeel commented Oct 26, 2020

I haved the same probleme,

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

@TouDick
Copy link

TouDick commented Nov 3, 2020

@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

@bwplotka
Copy link
Member

bwplotka commented Mar 5, 2021

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

@longtomjr
Copy link
Contributor

Just want to note here that the workaround here (#38 (comment)) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants