OSidorenkov / zabbix-jira

Python module that allows you to create tasks in Jira by the trigger from Zabbix
MIT License
40 stars 21 forks source link

Problem with disaster triggers on zabbix 4.2 #15

Open GitShayan opened 4 years ago

GitShayan commented 4 years ago

Hi, I use jirabix on zabbix 4.2. it works normally with High triggers but it can't create disaster triggers. I create it in my jira project but I got the following message in action message:

Traceback (most recent call last): File "/usr/local/share/zabbix/alertscripts//jirabix.py", line 231, in main() File "/usr/local/share/zabbix/alertscripts//jirabix.py", line 204, in main config.jira_issue_type, priority) File "/usr/local/share/zabbix/alertscripts//jirabix.py", line 34, in create_issue return jira.create_issue(fields=issue_params).key File "/usr/lib/python2.7/site-packages/jira/client.py", line 1107, in create_issue r = self._session.post(url, data=json.dumps(data)) File "/usr/lib/python2.7/site-packages/jira/resilientsession.py", line 154, in post return self.verb('POST', url, **kwargs) File "/usr/lib/python2.7/site-packages/jira/resilientsession.py", line 147, in verb raise_on_error(response, verb=verb, kwargs) File "/usr/lib/python2.7/site-packages/jira/resilientsession.py", line 57, in raise_on_error r.status_code, error, r.url, request=request, response=r, kwargs) jira.exceptions.JIRAError: JiraError HTTP 400 url: https://myjirasite.com/rest/api/2/issue text: This priority is not available for this project.

response headers = {'Content-Length': '96', 'X-AUSERNAME': 'ZabbixTicket', 'X-AREQUESTID': '594x968418x1', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "frame-ancestors 'self'", 'Content-Encoding': 'gzip', 'X-Seraph-LoginReason': 'OK', 'Vary': 'User-Agent', 'X-ASESSIONID': '1dgok5l', 'Connection': 'close', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Wed, 01 Jan 2020 06:24:54 GMT', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Type': 'application/json;charset=UTF-8', 'X-ASEN': 'SEN-L14752448'} response text = {"errorMessages":[],"errors":{"priority":"This priority is not available for this project."}}

JB221B commented 3 years ago

In my case, solved by adding the priority field in the issue create screen for the project.

rcaballo commented 3 years ago

In my case, solved by adding the priority field in the issue create screen for the project.

@JB221B can you explain a bit more how did you fix this issue? please

JB221B commented 3 years ago

In my case, solved by adding the priority field in the issue create screen for the project.

@JB221B can you explain a bit more how did you fix this issue? please

Certainly.

Note the returned error: "response text = {"errorMessages":[],"errors":{"priority":"This priority is not available for this project."}}".

In my case, at my Jira Service Desk, the native field Priority wasn't included in the Issue Create Screen for my Jira Project.

To Jira accept a field from api it must to be available in the correspondent Issue Create Screen, as if the ticket was created in Jira interface, although it is being created via api.

Is it more clear now?

rcaballo commented 3 years ago

@JB221B .... Any way to set priority to High always on the python script?

I can see that by default is creating priority "Warning" as you can see https://github.com/OSidorenkov/zabbix-jira/blob/master/entry.txt

or do I have to create a "Warning" priority type on JIRA?

JB221B commented 3 years ago

@JB221B .... Any way to set priority to High always on the python script?

I can see that by default is creating priority "Warning" as you can see https://github.com/OSidorenkov/zabbix-jira/blob/master/entry.txt

or do I have to create a "Warning" priority type on JIRA?

As we can see in the script code, the entry.txt isn't used:

# zbx_body = open('entry.txt', 'r').read() zbx_body = sys.argv[3]

The script uses the parameters received from Zabbix Alert Message defined in Zabbix Media Type, which uses the content of Zabbix Action Message. On Zabbix Action Message, the priority field is set with the Trigger Priority that triggered the event.

zbx;priority:{TRIGGER.SEVERITY}

So you can set a fixed values there in the Action Message, but you would consider to use it as it was planned, and respect the Trigger Severity, doing a coherent setup. That is my opinion.