Create Jira Issues from Watcher

Use Elasticsearch Watcher to open Jira issues automatically when a watch condition matches.

What You Need

  • A Watcher-enabled Elasticsearch deployment
  • Access to configure xpack.notification.jira in elasticsearch.yml
  • Jira credentials stored in the Elasticsearch keystore
  • A target Jira project and issue type

Step 1: Configure a Jira Account

Watcher uses Jira accounts configured under xpack.notification.jira.

Store the sensitive values in the keystore:

bin/elasticsearch-keystore add xpack.notification.jira.account.monitoring.secure_url
bin/elasticsearch-keystore add xpack.notification.jira.account.monitoring.secure_user
bin/elasticsearch-keystore add xpack.notification.jira.account.monitoring.secure_password

Use HTTPS by default. Plain-text HTTP is rejected unless allow_http: true is explicitly enabled.

Step 2: Optional Account Defaults

You can define defaults so each watch action does not need to repeat the same Jira fields:

xpack.notification.jira:
  account:
    monitoring:
      issue_defaults:
        project:
          key: proj
        issuetype:
          name: Bug
        summary: "X-Pack Issue"
        labels: ["auto"]

If you configure multiple Jira accounts, either define default_account or specify account in the action itself.

Step 3: Add a Jira Action to the Watch

Example structure:

"actions" : {
  "create-jira-issue" : {
    "transform" : { ... },
    "throttle_period" : "5m",
    "jira" : {
      "account" : "integration-account",
      "fields" : {
        "project" : {
          "key": "PROJ"
        },
        "issuetype" : {
          "name": "Bug"
        },
        "summary" : "Encountered {{ctx.payload.hits.total}} errors in the last 5 minutes",
        "description" : "Encountered {{ctx.payload.hits.total}} errors in the last 5 minutes",
        "labels" : ["auto"],
        "priority" : {
          "name" : "High"
        }
      }
    }
  }
}

Required Fields

These are always required to create the Jira issue:

  • fields.project.key or fields.project.id
  • fields.issuetype.name or fields.issuetype.id
  • fields.summary

Optional Fields

Common optional fields include:

  • fields.description
  • fields.labels
  • fields.priority.name
  • fields.assignee.name
  • fields.reporter.name
  • fields.environment
  • fields.customfield_XXX

Practical Notes

  • Use watch transforms to shape the payload before building Jira fields
  • Use templating in summary or description to include counts, identifiers, or timestamps from ctx.payload
  • If Jira requires organization-specific custom fields, pass them as customfield_XXX
  • If the Jira URL includes a path, it must be the full path to the create-issue endpoint; default is /rest/api/2/issue

See Also