prometheus-community / jiralert

JIRA integration for Prometheus Alertmanager
Apache License 2.0
333 stars 130 forks source link

JIRA Server versus JIRA Cloud #35

Open m-gnaedig opened 5 years ago

m-gnaedig commented 5 years ago

Hello

We are using jiralert with a JIRA Server installation and everything is working like expected. Now we like to migrate our projects to JIRA Cloud.

But with JIRA Cloud I get the following ERROR:

curl -H "Content-type: application/json" -X POST -d '{"receiver": "jira-ab", "status": "firing", "alerts": [{"status": "firing", "labels": {"alertname": "TestAlert", "key": "value"} }], "groupLabels": {"alertname": "TestAlert"}}' http://localhost:9097/alert
{"Error":true,"Status":500,"Message":"JIRA request https://dkv.atlassian.net/rest/api/2/search?jql=project%3D%22ALERT%22+and+labels%3D%22ALERT%7Balertname%3D%5C%22TestAlert%5C%22%7D%22+order+by+resolutiondate+desc\u0026startAt=0\u0026maxResults=2\u0026expand=\u0026fields=summary,status,resolution,resolutiondate\u0026validateQuery= returned status 401 Unauthorized, body \"\""}

Should jiralert also work with JIRA Cloud? Is my ERROR a 401 Unauthorized problem with the User and PW or a 500 ERROR? The same User has Access via the JIRA Web-interface.

Thanks in advance

free commented 5 years ago

I have only used it with JIRA Cloud, so it does work. I am not an admin however, so I don't know how authentication is set up and if e.g. it is possible to disable HTTP basic authentication (which is what JIRAlert is using).

free commented 5 years ago

Is my ERROR a 401 Unauthorized problem with the User and PW or a 500 ERROR?

Per the log message, it appears that the error JIRA Cloud returns to JIRAlert is actually a 401 Unauthorized. JIRAlert in turn returns a 500 to you (which is unfortunate, I guess, as it should maybe also return 401 or something else than 500).

You can try doing a curl to the URL in the log message, using basic authentication and the credentials in your jiralert.yml file. You should get back a 401 (but according to the log message, no body).

m-gnaedig commented 5 years ago

Thanks for your message. I will check the user settings with our admin.

taktv6 commented 5 years ago

Basic Auth will be removed: https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/

nvtkaszpir commented 5 years ago

It works with API tokens, which is just like using basic auth with specific password. https://confluence.atlassian.com/cloud/api-tokens-938839638.html