Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to enable integration with OpsGenie?

pavol_cvincek01 June 30, 2020

Hello,
I had to install OpsGenie Edge Connector on our test Jira server but when I am trying to submit alert on OpsGenie side, I can't get Jira SD to make ticket from that alert. Communication works from OpsGenie (OG) to Jira SD server. This is part of the output.txt file:
WARNING:root:[createIssue] Could not execute at Jira Service Desk; response: b'{"errorMessages":[],"errors":{"components":"Component/s is required."}}' status code: 400
In the settings for that project there are fields which are needed for creation of the ticket. "Component/s" is there as hidden. I was not able to remove it completely. When I made it blank - didn't help
I tried to define "Component/s" on OG side but no success as well. I am still getting above warning.
Can you please help me get thru that error message so Jira SD could create tickets based on OG alerts?

1 answer

1 vote
Robert
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 2, 2020

Hi @pavol_cvincek01 !

 

If the Jira project and issue type you are sending alerts to have (non-standard) required fields (like a component), there are two main options for getting them filled:

 

  1. Use Manual Issue Creation for Jira Software. This flow will essentially bring up the same Create Issue modal from Jira, including custom fields. The downside of this option is it isn't automated; a user would have to click the "Create Issue" button in an alert. 2020-07-02_11-50-38_01.png
  2. Customize the OEC script to include component in the createIssue action: https://github.com/opsgenie/oec-scripts/blob/master/Jira/scripts/actionExecutor.py#L113

    This would end up looking something like this:
     content_params = {
    "fields": {
    "project": {
    "key": project_key
    },
    "issuetype": {
    "name": issue_type_name
    },
    "summary": queue_message.get("summary"),
    "description": queue_message.get("description"),
    "labels": [toLabel.replace("\\s", "")],
    "components": [{
    "id": component
    }]
    }
    }

Hope this helps!

pavol_cvincek01 July 13, 2020

Hello Robert,
First of all, thanks a lot for your feedback. Option 1 is not suitable for us so I went for second one. I added "compoment" there as suggested but after I started OEC I could see there error saying " NameError: name 'component' is not defined". I tried to define it by adding "import component" on the top of the actionExecutor.py but another problem appeared - "ImportError: No module named 'component". It would be great if you would be able to advice with this as well.
Thank you in advance and have a nice day.

Robert
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 13, 2020

Hi @pavol_cvincek01 !

 

The "component" I had included in that snippet was an example variable name, so there's no need to do any additional imports in the script.

You would need to define "component" somewhere in the script, or at least substitute it with your component ID:

 

 content_params = {
"fields": {
"project": {
"key": project_key
},
"issuetype": {
"name": issue_type_name
},
"summary": queue_message.get("summary"),
"description": queue_message.get("description"),
"labels": [toLabel.replace("\\s", "")],
"components": [{
"id": "12345"
}]
}
}

Hope this helps clarify things a bit!

pavol_cvincek01 July 15, 2020

Hi @Robert 
Yep, I used our value for component at first but no success as mentioned above. Afterwards I changed "id" to "name" and it finally works. Thanks a lot for that, it helped significantly.


Unfortunately now I can see this there:
"WARNING:root:[createIssue] Could not execute at Jira Service Desk; response: b'{"errorMessages":[],"errors":{"customfield_13040":"Field Customer Request Type is required.","customfield_15340":"Field Did It work in the past? is required."}}' status code: 400"

Field Customer Request Type should be "Alerts"
Field Did It work in the past? should be "Yes"

When I tried the same approach like for "components" I wasn't successful. Can you advice how the code should looks like?

Thanks in advance and have a nice day.

Robert
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 15, 2020

@pavol_cvincek01 I think you're on the right track by following the same process as the first field. My first guess is those fields might be a different "type" of custom field though, so the format in the API request may need to be modified.

 

This page has some great examples in the Creating an issue using custom fields section. I'd check the types of those custom fields and make sure they're using the format mentioned in those docs.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events