alertmanager icon indicating copy to clipboard operation
alertmanager copied to clipboard

Alertmanager 0.28.1: Jira integration fails with "Field 'labels' cannot be set" error even when labels are not configured

Open Zarubenko opened this issue 1 year ago • 13 comments

Alertmanager version: 0.28.1

Issue: When configuring Jira integration in Alertmanager, the request to create an issue fails with the following error: time=2025-03-11T10:24:31.527Z level=ERROR source=dispatch.go:360 msg="Notify for alerts failed" component=dispatcher num_alerts=1 err="jira/jira[0]: notify retry canceled due to unrecoverable error after 1 attempts: failed to POST request to \"issue\": unexpected status code 400: {\"errorMessages\":[],\"errors\":{\"labels\":\"Field 'labels' cannot be set. It is not on the appropriate screen, or unknown.\"}}"

Expected behavior: Alertmanager should respect the configuration and not send the labels field when it is not explicitly defined in jira_configs.

Steps to reproduce: Configure jira_configs in alertmanager.yml:

receivers:
  - name: "jira"
    jira_configs:
      - project: "myproject"
        issue_type: "Incident"
        summary: "Test alert"
        description: "This is a test description"
        labels: [] # Empty fields to ensure no labels are sent
        fields: {}  # Empty fields to ensure no labels are sent

What has been tested: Manually sending a request via curl with no labels field works fine:

curl -X POST "https://jira.fofo.com/rest/api/2/issue/" \
     -H "Authorization: Bearer your_personal_access_token" \
     -H "Content-Type: application/json" \
     -d '{
          "fields": {
            "project": { "key": "myproject" },
            "summary": "Test Alert Summary",
            "description": "Test Alert Description",
            "issuetype": { "name": "Incident" }
          }
        }'
  • Downgrading Alertmanager to 0.28.0 does not fix the issue.
  • Explicitly setting labels: [] in jira_configs does not help.
  • Setting fields: {} does not prevent labels from being sent.
  • Debug logs do not show the actual request being sent.

Suggested Fix: Ensure that labels is not automatically added when not defined in jira_configs. Improve debug logging to show the exact JSON payload being sent to Jira.

Zarubenko avatar Mar 11 '25 17:03 Zarubenko

It seems to me that the integration sets this label even when labels: [] in jira_configs:

requestBody.Fields.Labels = append(requestBody.Fields.Labels, fmt.Sprintf("ALERT{%s}", groupID))

I'm not that experienced with Jira to know what is the correct behavior here, and the integration was an external contribution rather than created by the maintainers.

@jkroepke is it possible to ask for your thoughts here?

grobinson-grafana avatar Mar 11 '25 18:03 grobinson-grafana

@Zarubenko is it possible this is an authentication issue? I was looking at https://community.atlassian.com/forums/Jira-questions/Unable-to-add-set-label-on-Already-created-issue-via-edit-REST/qaq-p/1399335.

grobinson-grafana avatar Mar 11 '25 18:03 grobinson-grafana

@grobinson-grafana yes, I have the same problem. labels fields are not present in the ticket creation screen, but are only available through updating an already created ticket. so it is necessary to be able to tell the alertmanager not to send the "labels" field when creating a new ticket

Zarubenko avatar Mar 11 '25 18:03 Zarubenko

What doesn't make sense to me so far is why this isn't broken for other people?

grobinson-grafana avatar Mar 11 '25 19:03 grobinson-grafana

The Alertmanager JIRA integration is a reimplementation of jiralert.

In Alertmanager, ticket labels are used to deduplicate alerts; without them, a new ticket is created at each repeat interval.

The current implementation relies on labels, including on the creation screen.

A potential fix could be implementing https://github.com/prometheus-community/jiralert/issues/164 - which is using an alternative to labels.

What doesn't make sense to me so far is why this isn't broken for other people?

The default issue screen allows label customization. But in this scenario, the Jira instance of @Zarubenko is using a custom configuration which denies to set labels on creation.

jkroepke avatar Mar 11 '25 22:03 jkroepke

@jkroepke thanks for the detailed answer

Zarubenko avatar Mar 12 '25 08:03 Zarubenko

This sounds like a configuration error then?

grobinson-grafana avatar Mar 12 '25 10:03 grobinson-grafana

yes, this problem can be solved on jira side, but I suppose able to disable send labels field after solved https://github.com/prometheus-community/jiralert/issues/164 will be helpful

Zarubenko avatar Mar 12 '25 12:03 Zarubenko

the Jira instance of @Zarubenko is using a custom configuration which denies to set labels on creation

I'm not a Jira expert, so apologies if this is an obvious question. What is the use case of not allowing labels to be set when creating an issue? Is this a common configuration for Jira users? Basically I want to understand if this is something that will affect a lot of users in future or not.

grobinson-grafana avatar Mar 12 '25 12:03 grobinson-grafana

there is no prohibition on installing labels by default, this field may simply not be displayed on the screen or in the task type itself, since not everyone needs it. and we had it disabled, this is a special case and not a basic Jira setting, everything worked out for us when we fixed it on the Jira side, I think this ticket can be closed

Zarubenko avatar Mar 14 '25 07:03 Zarubenko

Colleagues, I need your help. Could anyone share a working configuration for Jira integration with Alertmanager? We’ve been struggling with this setup for a long time. We keep getting the message: msg="more than one issue matched, selecting the most recently resolved", and Alertmanager ends up updating the wrong issue (the most recently resolved one).

Worse still, it doesn’t even create or update any issue properly.

So I’d really appreciate it if someone could share (even a stripped-down version of) their config — both alertmanager.yml and jira.tmpl.

OlegF31 avatar Mar 28 '25 18:03 OlegF31

This may appears if multiple jira notifier are configured.

jkroepke avatar Mar 28 '25 19:03 jkroepke

@Zarubenko Did you manage to send data to Jira? Is the native integration in Alertmanager working?

OlegF31 avatar Apr 02 '25 06:04 OlegF31