Skip to content

Jira integration does not reopen issues when reopen_duration is set #4431

Open
@mashinarius

Description

@mashinarius

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

if firing {
if n.conf.ReopenTransition == "" {
jql.WriteString(`statusCategory != Done and `)
}
} else {
reopenDuration := int64(time.Duration(n.conf.ReopenDuration).Minutes())
if reopenDuration != 0 {
jql.WriteString(fmt.Sprintf(`(resolutiondate is EMPTY OR resolutiondate >= -%dm) and `, reopenDuration))
}
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions