alertmanager icon indicating copy to clipboard operation
alertmanager copied to clipboard

Jira integration does not reopen issues when reopen_duration is set

Open mashinarius opened this issue 6 months ago • 0 comments

Summary

When an alert re‑fires within the configured reopen_duration, the existing Jira issue is not reopened, even though reopen_transition is configured. The issue only gets updated while it remains in the Done status.

Alertmanager version

alertmanager, version 0.28.1

Minimal configuration to reproduce

receivers:
  - name: jira
    jira_configs:
      - send_resolved: false
        reopen_duration: 12h   
        reopen_transition: "Back to work in progress"

Relevant log excerpt

time=2025-06-12T06:14:48.826Z level=DEBUG source=dispatch.go:530 msg=flushing component=dispatcher aggrGroup="{}/{channel=\"atlassian\",device_number=~\"^(?:.+)$\",report=\"true\",severity=~\"^(?:critical|warning|info)$\"}:{alertname=\"DU02-AN\", device_number=\"0216\"}" alerts=[DU02-AN[f3dae8b][active]]
time=2025-06-12T06:14:48.826Z level=DEBUG source=jira.go:230 msg="search for recent issues" integration=jira group_key="{}/{channel=\"atlassian\",device_number=~\"^(?:.+)$\",report=\"true\",severity=~\"^(?:critical|warning|info)$\"}:{alertname=\"DU02-AN\", device_number=\"0216\"}" jql="project=\"SPT\" and labels=\"ALERT{766e703fe63f1da246fb533c404024890bdfe90f216bba7cb55b50918ce1fce5}\" order by status ASC,resolutiondate DESC"
time=2025-06-12T06:14:49.232Z level=DEBUG source=jira.go:106 msg="updating existing issue" integration=jira group_key="{}/{channel=\"atlassian\",device_number=~\"^(?:.+)$\",report=\"true\",severity=~\"^(?:critical|warning|info)$\"}:{alertname=\"DU02-AN\", device_number=\"0216\"}" issue_key=SPT-1104

The generated JQL find also ticket that was already resolved more than reopen_duration time ago

Code pointer

https://github.com/prometheus/alertmanager/blob/b2099eaa2c9ebc25edb26517cb9c732738e93910/notify/jira/jira.go#L205-L214

Why this is wrong

The reopenDuration clause is inside the else branch that executes only when the alert is not firing. As a result it tries to reopen ticket that was already resolved several days ago, while reopen_duration is only 12h

Expected logic

For firing alerts with a reopen_transition, Alertmanager should:

Search for issues closed within reopen_duration.

If found, reopen them using the supplied transition.

Otherwise create a new issue.

Reference documentation

The Grafana Alerting docs describe Reopen Duration as: "The time duration (in minutes) to control whether to reopen an issue that was closed within this duration or create a new one." this matches the expected behaviour above.

mashinarius avatar Jun 12 '25 08:06 mashinarius