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

search for existing issue in multiple projects #162

Merged

Conversation

twotired
Copy link
Contributor

@twotired twotired commented May 8, 2023

If a JIRAlert-created issue is moved to another project, and the alert fires again, JIRAlert doesn't find the issue because it only searches within the target JIRA project.

This can be a problem if issues are assigned to another team's JIRA project due to the nature of the failure. If the alert fires again, the updates should still go to the existing JIRA, instead of creating a new issue that may also need to be moved.

resolves #159

@holger-waschke
Copy link
Contributor

I tested this and it works just fine. Its non breaking change too, if you dont have other_projects: [] in your config nothing changes.

Could you merge this @bwplotka

@mattb18
Copy link

mattb18 commented Jan 30, 2024

Any chance on getting this merged?

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Not sure if this feature is intuitive, but if you feel it's useful, I'm fine (with some better commentary). LGTM mod suggestions, sorry for lag!

pkg/notify/notify.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
examples/jiralert.yml Outdated Show resolved Hide resolved
@@ -107,7 +107,7 @@ func (f *fakeJira) Create(issue *jira.Issue) (*jira.Issue, *jira.Response, error

// Assuming single label.
query := fmt.Sprintf(
"project=\"%s\" and labels=%q order by resolutiondate desc",
"project in('%s') and labels=%q order by resolutiondate desc",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must use an "in" JQL expression to compare "project" to a list of projects instead of testing equality with a single project. It works fine if list length is 1.

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Jason Wells <spinmaster@gmail.com>
@twotired
Copy link
Contributor Author

approved suggestions @bwplotka

@bwplotka bwplotka merged commit 15cff9b into prometheus-community:master Jan 30, 2024
2 checks passed
@bwplotka
Copy link
Member

Thanks!

rufusnufus pushed a commit to KazanExpress/jiralert that referenced this pull request May 13, 2024
)

* search for existing issue in multiple projects

Signed-off-by: Jason Wells <spinmaster@gmail.com>

* Apply suggestions from code review

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Jason Wells <spinmaster@gmail.com>

---------

Signed-off-by: Jason Wells <spinmaster@gmail.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
rufusnufus added a commit to KazanExpress/jiralert that referenced this pull request May 13, 2024
* Better Jira error handling (prometheus-community#140)

* Better Jira error handling

* Return HTTP 400 Bad Request for non-retriable errors. It is inaccurate, but
  will prevent alertmanager from retrying.
* Turns out go-jira does actually produce useful error messages (and it consumes
  the response body in the process). Log that instead of the empty body.

Signed-off-by: Alin Sinpalean <alin.sinpalean@gmail.com>

* Also include HTTP response status 429 among retriable errors.

Signed-off-by: Alin Sinpalean <alin.sinpalean@gmail.com>

* Include both the go-jira error and the response body in errors. Sometimes go-jira consumes the body and includes it in its error, sometimes it doesn't.

Signed-off-by: Alin Sinpalean <alin.sinpalean@gmail.com>

---------

Signed-off-by: Alin Sinpalean <alin.sinpalean@gmail.com>
Co-authored-by: Alin Sinpalean <alin.sinpalean@gmail.com>

* disable update existing jira issues with parameter (prometheus-community#150)

* Bump all dependencies (prometheus-community#133)

Signed-off-by: Jan-Otto Kröpke <jok@cloudeteer.de>

Signed-off-by: Jan-Otto Kröpke <jok@cloudeteer.de>
Signed-off-by: Holger Waschke <holger.waschke@dvag.com>

* parameter to disable update jira issues

Signed-off-by: Holger Waschke <holger_2000@hotmail.com>
Signed-off-by: Holger Waschke <holger.waschke@dvag.com>

* rename parameter to make it more clear and avoid double negation. fix bug with missing return value.

Signed-off-by: Holger Waschke <holger.waschke@dvag.com>

* Update main.go

Signed-off-by: dvag-holger-waschke <85643002+dvag-holger-waschke@users.noreply.github.com>

* Update notify.go

Signed-off-by: dvag-holger-waschke <85643002+dvag-holger-waschke@users.noreply.github.com>

* Update main.go

Signed-off-by: dvag-holger-waschke <85643002+dvag-holger-waschke@users.noreply.github.com>

* Update main.go

Signed-off-by: dvag-holger-waschke <85643002+dvag-holger-waschke@users.noreply.github.com>

* Update main.go

Signed-off-by: dvag-holger-waschke <85643002+dvag-holger-waschke@users.noreply.github.com>

* Update notify.go

Signed-off-by: dvag-holger-waschke <85643002+dvag-holger-waschke@users.noreply.github.com>

* fix for notify test

Signed-off-by: Holger Waschke <holger.waschke@dvag.com>

---------

Signed-off-by: Jan-Otto Kröpke <jok@cloudeteer.de>
Signed-off-by: Holger Waschke <holger.waschke@dvag.com>
Signed-off-by: Holger Waschke <holger_2000@hotmail.com>
Signed-off-by: dvag-holger-waschke <85643002+dvag-holger-waschke@users.noreply.github.com>
Co-authored-by: Jan-Otto Kröpke <github@jkroepke.de>
Co-authored-by: Holger Waschke <holger_2000@hotmail.com>

* Adding getEnv templating function (prometheus-community#153)

Signed-off-by: Jiri Tyr <jiri.tyr@gmail.com>

* feat: add support for static jira labels (prometheus-community#154)

Signed-off-by: Herman Ewert <longtomjr@gmail.com>
Co-authored-by: Herman Ewert <hewert@mezzanineware.com>

* Fix prometheus-community#146 (safe limit of 200 characters from group label value) (prometheus-community#147)

Signed-off-by: jzajic <jan.zajic@corpus.cz>

* doc(PAT): Adds doc for PAT usage (prometheus-community#155)

Signed-off-by: Julian Beck <ju-fa-beck@t-online.de>

* truncate descriptions that exceed -max-description-length (default 32KB) (prometheus-community#165)

* truncate descriptions that exceed -max-description-length (default 32,768)

Signed-off-by: Jason Wells <spinmaster@gmail.com>

* Update main.go

size was off by 1

Signed-off-by: Jason Wells <spinmaster@gmail.com>

---------

Signed-off-by: Jason Wells <spinmaster@gmail.com>

* fix: 🐛 Fixes error message for doTransition to display the proper transition state (prometheus-community#176)

Signed-off-by: Nathan Gotz <nathan.gotz@gmail.com>

* search for existing issue in multiple projects (prometheus-community#162)

* search for existing issue in multiple projects

Signed-off-by: Jason Wells <spinmaster@gmail.com>

* Apply suggestions from code review

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Jason Wells <spinmaster@gmail.com>

---------

Signed-off-by: Jason Wells <spinmaster@gmail.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>

* add Fingerprint field to Alert so that it may be used in templates (prometheus-community#152) (prometheus-community#163)

Signed-off-by: Jason Wells <spinmaster@gmail.com>

---------

Signed-off-by: Alin Sinpalean <alin.sinpalean@gmail.com>
Signed-off-by: Jan-Otto Kröpke <jok@cloudeteer.de>
Signed-off-by: Holger Waschke <holger.waschke@dvag.com>
Signed-off-by: Holger Waschke <holger_2000@hotmail.com>
Signed-off-by: dvag-holger-waschke <85643002+dvag-holger-waschke@users.noreply.github.com>
Signed-off-by: Jiri Tyr <jiri.tyr@gmail.com>
Signed-off-by: Herman Ewert <longtomjr@gmail.com>
Signed-off-by: jzajic <jan.zajic@corpus.cz>
Signed-off-by: Julian Beck <ju-fa-beck@t-online.de>
Signed-off-by: Jason Wells <spinmaster@gmail.com>
Signed-off-by: Nathan Gotz <nathan.gotz@gmail.com>
Co-authored-by: Alin Sinpalean <58422065+alin-at-dfinity@users.noreply.github.com>
Co-authored-by: Alin Sinpalean <alin.sinpalean@gmail.com>
Co-authored-by: dvag-holger-waschke <85643002+dvag-holger-waschke@users.noreply.github.com>
Co-authored-by: Jan-Otto Kröpke <github@jkroepke.de>
Co-authored-by: Holger Waschke <holger_2000@hotmail.com>
Co-authored-by: Jiri Tyr <jtyr@users.noreply.github.com>
Co-authored-by: Herman <longtomjr@gmail.com>
Co-authored-by: Herman Ewert <hewert@mezzanineware.com>
Co-authored-by: Jan Zajic <jan.zajic@gmail.com>
Co-authored-by: Julian Beck <ju-fa-beck@t-online.de>
Co-authored-by: Jason Wells <spinmaster@gmail.com>
Co-authored-by: Nathan Gotz <775979+nlgotz@users.noreply.github.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search for existing JIRA issues that have been moved to other JIRA projects
4 participants