Skip to main content

Create work items from monitoring alerts

Turn each alert from your monitoring tool into a Jira work item, through a URL that only your tool can call.

Problem: Alerts arrive by email or chat, and someone copies the important ones into Jira by hand. Some get lost, and the work item never says which alert started it.

Solution: Create a web trigger that checks a secret token, then creates a work item from the alert's title. Try it in the web trigger's test panel, then give the URL to your monitoring tool.

What you'll need​

  • Script Master for Jira, with an active license. See Get started.
  • The Administer Jira global permission.
  • A Companion App connected to Script Master. Web triggers run there. See The Companion App.
  • A space for the work items, for example DEMO, with the work type Task.
  • A long random token, for example from a password generator.
  • A monitoring tool that can send an HTTP POST with a header and a JSON body.

Set it up​

1. Create the web trigger​

  1. In Script Master, select the Web Triggers tab, then Create web trigger.

  2. In Title, enter Create work items from alerts.

  3. In Backend JavaScript, paste this script and replace <your-access-token> with your token:

    // The URL is public: reject every call without the token
    if (request.headers['authorization']?.[0] !== 'Bearer <your-access-token>') {
    console.warn('Call rejected: missing or wrong token');
    return { statusCode: 401, statusText: 'Unauthorized' };
    }

    let alert;
    try {
    alert = JSON.parse(request.body);
    } catch {
    return { statusCode: 400, statusText: 'Invalid JSON' };
    }
    const title = typeof alert.title === 'string' ? alert.title.slice(0, 200) : '';
    if (!title) return { statusCode: 400, statusText: 'A title is required' };

    const response = await api.asApp().requestJira(route`/rest/api/3/issue`, {
    method: 'POST',
    headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
    body: JSON.stringify({
    fields: {
    project: { key: 'DEMO' },
    issuetype: { name: 'Task' },
    summary: `Alert: ${title}`,
    labels: ['alert'],
    },
    }),
    });
    if (response.status !== 201) {
    console.error(`Jira answered ${response.status}`);
    return { statusCode: 502, statusText: 'The work item was not created' };
    }
    const created = await response.json();

    return {
    statusCode: 201,
    headers: { 'Content-Type': ['application/json'] },
    body: JSON.stringify({ key: created.key }),
    };
  4. Turn on Enable, then select Save. Web Trigger URL: now shows the URL.

2. Test it​

  1. Under the editor, turn on Test this Web Trigger.

  2. Select Generate request example > POST request example with body.

  3. In the request, set headers and body to these values:

    "headers": { "content-type": ["application/json"], "authorization": ["Bearer <your-access-token>"] },
    "body": "{\"title\": \"Disk space low on build server\"}"
  4. Select Test. The Result panel shows statusCode 201 and the new work item's key.

    The web trigger test panel with a POST request and a Result of 201 with the new work item&#39;s key

The test creates a real work item. Delete it in Jira when you're done.

3. Connect your monitoring tool​

  1. Next to Web Trigger URL:, select the copy icon.
  2. In your monitoring tool, add a webhook that sends a POST to that URL, with the header Authorization: Bearer <your-access-token> and a JSON body such as {"title": "Disk space low on build server"}.
PlaceholderDescription
<your-access-token>Your token. Use the same value in the script and in the monitoring tool.

What your team will experience​

  1. An alert fires in the monitoring tool, and it calls the web trigger.
  2. A Task named Alert: and the alert's title appears in DEMO, with the label alert.
  3. The team picks it up from the backlog like any other work item.

Check that it works​

  1. Send a test alert from your monitoring tool.
  2. Confirm that a new work item with the label alert appears in DEMO.
  3. On the Web Triggers tab, select the latest run in the web trigger's History column. Confirm that it shows no errors.

To check the token, send one call without the Authorization header, for example from a terminal:

curl -X POST '<web-trigger-url>' -H 'Content-Type: application/json' -d '{"title": "Test"}'

It gets 401 and creates nothing.

PlaceholderDescription
<web-trigger-url>The URL you copied from Web Trigger URL:.