Jira Alert in Watcher

The product page of Watcher mentions the option to alert Jira.

Get Notified the Way You Want
Easily set up email alerts when incidents occur, or integrate Watcher into your existing monitoring infrastructure via webhook to send alerts to JIRA, HipChat, PagerDuty, Slack, and more.

I can't seem to find how to do this and how it works. I found ElastAlert on the internet and this is able to create tickets in Jira or even update a ticket. Can Watcher do this also? How does it work :smile:?

Thanks!

You can use the WebHook action to integrate with any 3rd party service that has an RESTful API, including Jira. We are planning a more native integration, which will make it a bit simpler, but you should be able to integrate with Jira today.

Currently this can be done using the webhook action. This action enables you to create a generic HTTP request to an external service. For example, if you enable JIRA API. Here's an example action that create a jira issue (using the same example as in JIRA docs):

{
  ...,

  "actions" : {
    "create_jira_issue" : {
      "webhook" : {
        "host" : "localhost",
        "port" : 2990,
        "method" : "post",
        "path" : "/jira/rest/api/2/issue"
        "auth" : {
          "basic" : {
            "username" : "admin",
            "password" : "admin"
          }
        },
        "body" : {
          "fields": {
            "project": {
              "id": "10000"
            },
            "summary": "No REST for the Wicked.",
            "description": "Creating of an issue using ids for projects and issue types using the REST API",
            "issuetype": {
              "id": "3"
            }
          }
        }
      }
    }
  }
}

Interesting! I might be mistaken but wouldn't that just make a thin jira issue? It wouldn't really have a lot of information regarding the issue. I haven't been able to find something for it yet but isn't it possible to add data or logs to it?

The example above is simply the same example as in their intro doc... only within a watch. Their API for creating an issue is much richer than that though. The webhook body can be templated as well.

I see! Thanks! :smile:

The above values for the HTTP response body doesn't work

{ "error": { "root_cause": [ { "type": "parse_exception", "reason": "unexpected field [fields]" } ], "type": "parse_exception", "reason": "could not parse [webhook] action [myalert]. failed parsing http request template", "caused_by": { "type": "parse_exception", "reason": "could not parse http request template. could not parse value for [body] field", "caused_by": { "type": "parse_exception", "reason": "unexpected field [fields]" } } }, "status": 400 }

we just allow static text or mustache templates right? @uboness
Or am I missing something here?

no, you're not missing something, indeed the body field should be a templated string, not an object (with all the json parts escaped).. not ideal... we should look into it to see how we can simplify this (perhaps with an alternative jsonBody field)