Skip to main content
All CollectionsAPI and integrationsFAQs
Extracting JSON alert data
Extracting JSON alert data
incident.io Engineering Team avatar
Written by incident.io Engineering Team
Updated over a week ago

When configuring alerts you can choose to extract specific fields you care about from the JSON payload of your alert.

You can manage this by navigating to Alerts > Sources and editing the alert source you wish to extract information from.

Select add a new attribute to get started


πŸ‘©β€πŸ’» Extracting fields from JSON

You can see the alert payload for all the alerts you've received.

The input for extracting data works with Javascript, but without any ES6 language features.

⚠️ ES6 language features are not supported

This means there is no support for arrow functions, template literals, some string functions, and other features listed here

To extract certain fields to map to your alert, you have a few options:

1. Extract a simple field

If you click on any field displayed in the payload, you'll automatically see this value extracted.

For example, to extract the service field from your metadata, use

 $.metadata.service

This will dynamically fetch whichever value is in the service field and apply it to your alert.

2. Map array fields

To map an array field, we can use standard Javascript.

In our JSON payload, our tags field has the following format:

tags: ["feature:api", "feature:payments", "service:api"]

To filter only certain values from our tags, we can use Javascript filtering:

$.metadata.tags.filter(function(tag) { return tag.startsWith("feature:") })

// This returns the following
feature:api, feature:payments

To map your array, you can also use standard Javascript functions:

$.metadata.tags.map(function(tag) {return tag.split(":")[1]})


// This returns the following
api, payments

To ensure that your output preserves all values from your array, select Result is an array.

Otherwise, your result will just select the first value of your array.

Did this answer your question?