Use Jiralert to implement AlertManager alarm docking with Jira
This article was last updated on: July 24, 2024 am
Brief introduction
Alertmanager Handles alerts sent by client applications, such as Prometheus server. It is responsible for deduplicating, grouping, and routing them to the correct receiver integration, such as email, WeChat, or DingTalk. It is also responsible for handling silencing, timed send/do not send (Mute), and inhibition of alarms.
As an open source alerting application designed for Prometheus, AlertManager already has a variety of rich, flexible, and customizable functions of alerting applications:
Jiralert
Prometheus Alertmanager Webhook Receiver for JIRA。
JIRAlert implements Alertmanager’s webhook HTTP API and connects to one or more JIRA instances to create highly configurable JIRA Issues. Each different Groupkey creates an issue – by the Alertmanager’s Routing Configuration sectiongroup_by
Parameter definition - but does not close when the alarm is resolved (default parameter, adjustable). Our expectation is that people will look at this issue. , take any necessary action, and then close it. If human interaction is not necessary, then it probably shouldn’t have called the police in the first place. However, this behavior can be set throughauto_resolve
section is modified and it will resolve the JIRA issue in the desired state.
If a corresponding JIRA issue. Already exists, but is solved and it will be reopened. There must be one between the resolved state and the reopened stateJIRA transition–asreopen_state
–Otherwise, the reopening will fail. You can optionally define a “won’t fix” resolution (resolution–Bywont_fix_resolution
Definition: JIRA issues with this resolution will not be reopened by JIRARlert.
Install Jiralert
The installation of Jiralert is relatively simple, mainly consisting of Deployment, Secret (Jiralert’s configuration) and Service. Typical examples are as follows:
1 |
|
1 |
|
1 |
|
Configuration of the corresponding AlertManager:
1 |
|
📝 Illustrate:
- Official JirAlert image address: https://quay.io/repository/jiralert/jiralert-linux-amd64?tab=tags
- Official JirAlert Latest Mirror: <quay.io/jiralert/jiralert-linux-amd64:latest>
jiralert.tmpl
Similar to AlertManager’s template, issues sent to Jira use this as a templatejiralert.yml
Jiralert’s configuration filedefaults
Basic configurationreceivers
Multiple receivers can be set up, and which Jira receiver AlertManager wants to send to needs to have the same name as the jiralert receiver. (Like the example above, both of them.)jiralert
)
Jiralert configuration
The complete production Jiralert configuration is as follows:
1 |
|
📝 The detailed description is as follows:
api_url
: Jira’s address, if using Jira’s SaaS service, ishttps://<tenant>.atlassian.net
- Authentication:
- For the public cloud version of Jira, it can only be used
user
andpassword
Thereinto:user
Fill in your account email address;password
Need to be in first API Token | Atlassian account Apply for API Token. (🐾 Note: The password used for login cannot be authenticated)
- For other versions, it can also be filled in for use
personal_access_token
Conduct certification. Its values are:[email protected]:api_token_string
The base64 encoded string. For specific instructions, see: Basic auth for REST APIs (atlassian.com)
- For the public cloud version of Jira, it can only be used
issue_type
: Depending on your Jira Issue Type, it could be:Alert
Support
Bug
New Feature
And so on or so onpriority
Depending on your Issue priority, it may be:Critical
High
Medium
Low
And so on or so onreopen_state
: Jira’s issue has been closed, to reopen, needed transitionAs:Back to in progress
. (🐾 Note: What needs to be filled in here is your custom.) transition, and not status)wont_fix_resolution
: With this resolution The problem (solution) will not be reopened. As:Won't Do
Won't Fix
, need to be according to their own resolution Define the content to fill in.reopen_duration
: How long does it take for the issue to reopen, default isalways reopen
, which can be set to such as:30d
, indicating that if the same issue was 30 days ago, open a new issue instead of reopening the old issue.receivers
: Multiple receivers can be defined, pointing to different onesproject
project
: Jira’s Project ID, which is the initial capital of the project’s detailed name. Such as Project isFor Example
, fill in hereFE
add_group_labels
: Whether you want to add AlertManager’s Group Labels to Jira’s Labels. (🐾 Note: Jira Labels cannot have spaces in their Value, so if your AlertManager’s Group Label Value has spaces.) NoTurn on this feature)auto_resolve
: The latest 1.2 version adds a new feature, when the alarm is restored, you can automatically resolve the corresponding Jira Issue.state: 'Resolve this issue'
Here is also to fill in your predefined Jira to solve the problem transition And not statusas'Resolve this issue'
.
Other difficult situations
If you encounter all kinds of weird logs, most of the reasons are caused by not properly authenticating and logging in, typical such as this error:
1 |
|
In fact, it is caused by not properly authenticating the login.
For details, please refer to here: Solved: REST error "The value ‘XXX’ does not exist for the… (atlassian.com)
There is also a category of errors that tell you that you can’t transition an issue
This is often due to the following reasons:
- Jiralert
reopen_state
orauto_resolve
targetstate
Not filled in correctlytransition
- The account you are using does not have the corresponding permissions
- The status the Issue is in now (eg
Closed
) is not allowed to proceed againtransition
For details, please refer to here: I can’t transition an issue in my Jira project - W… - Atlassian Community
The final effect
As shown in the following figure:
You can create an issue, update Summary, update Description, Update Resolution, Update Status; The same problem recurred, reopening the previous issue…
🎉🎉🎉