Extracting and composing alert fields
Summarize
Summary of Extracting and composing alert fields
In ServiceNow alert automation, extracting and composing alert fields help you manage alert output to simplify filtering, grouping, and readability. Extracting pulls specific data from event payloads into alert output fields, while composing merges multiple alert fields or texts into a single output field. These capabilities enable clearer and more actionable alert notifications.
Show less
Extracting alert fields
Extracting involves using regular expressions (regex) to isolate relevant context hidden within event payloads, enriching alert outputs for better understanding and resolution. For example, extracting cluster information from a host name helps in tagging and grouping alerts appropriately.
- Use Perl Compatible Regular Expressions (PCRE) and capture groups in parentheses to extract specific portions of input data.
- The entire input must match the regex, so it is common to surround regex with
.on both ends. - Multiple capture groups produce multiple alert output fields.
- Preview multiple events with example payloads to verify regex accuracy before finalizing.
Example: Extract six letters from the "Metric Name" field value "Free swap space in %" using the regex (.........). and output it to a new alert field called mynewfield. Tag the new field to enable tag-based grouping and verify extraction through the preview feature.
Composing alert fields
Composing allows you to combine existing alert fields, tags, and free text into a single readable alert output field, enhancing clarity and management options.
- Alert fields use the syntax
${fieldname}, which can be manually entered or selected from a dropdown. - You can create new alert output fields or update existing ones.
- Tag composed alert fields for easier grouping.
- Include free text along with fields to create meaningful alert messages.
Example scenarios:
- Scenario 1: Combine an existing alert field with another field (e.g.,
${classification} and ${ueventid}) into a new alert output fieldmynewfield, tagging it for grouping. - Scenario 2: Compose free text with existing fields (e.g.,
Problem type: ${type} with severity ${severity}) and output to an existing alert field such asDescription.
Practical benefits for ServiceNow customers
- Enhance alert clarity by extracting precise, relevant data from complex event payloads.
- Improve alert filtering and grouping through tagging extracted or composed fields.
- Create customizable, actionable alert messages by composing multiple fields and text.
- Validate extraction and composition logic using preview tools before deployment.
Extracting and composing are ways to manage what you see in the alert output, making it simpler to filter, group, and read. Alert automation enables you to extract values from event payload's alert field and place it in an alert output field. Composing allows you to merge multiple alert fields into a single output field.
Extracting alert fields
Alert notifications often contain relevant context buried within event payloads. By enriching alert outputs with values from the existing payload, you can better understand the significance of alerts and determine the appropriate steps for resolution. For example, a host name typically includes crucial information such as service, node, cluster, datacenter, and domain. To automatically add the value for a cluster tag based on incoming host data, you can extract just the cluster data.
.* on each end. For example, (\w+).acme.com.*
captures the host name in a fully qualified domain name. The parser for the regex engine is Perl Compatible Regular Expressions (PCRE) compatible.Example: Extracting alert fields
- Source input field: Select the event field from which you want to extract data. In this case, the field is Metric Name.
- Regular expression: Use a regular expression to extract the specific part you need from the selected field's value. For example, if the Metric Name field value contains "Free swap space in %" and you want to extract "Free swap", your regular expression must be (.........).*.
- Alert output:
- Choose an existing alert field, an existing alert tag, or manually enter a new field name. In this case, let's enter a new field name mynewfield.
- Set mynewfield as a tag for later use in tag-based grouping. Notice the tag displayed before the field name.
After applying the regular expression to the selected field's value (in this case the Metric Name field value), verify the extracted word displayed below the Alert output field. For instance, it should show "Free swap" if the regular expression matches correctly.
- Preview multiple events: Previewing multiple events allows you to verify if the regular expression accurately extracts data from a range of example events. This helps determine if any adjustments to the regular expression are needed.
Composing alert fields
When creating an alert output, you can select or manually enter fields, tags, or free text to include. This data can be easily read, filtered, and grouped for better management and understanding of the alerts.
Example: Composing alert fields
- Scenario 1:
- Source input field: Select an existing alert field and add the text "and", followed by entering another field u_eventid. For example: ${classification} and
${u_eventid}.
Note that alert fields are displayed in the
${field}syntax format. You can also select the field name from the drop-down list, and the syntax will be added automatically. - Alert output: Enter the name of the new alert field where you want to display the values from the input fields. For example, let's name it mynewfield.
Set mynewfield as a tag for later use in tag-based grouping. Notice the tag displayed before the field name.
- Source input field: Select an existing alert field and add the text "and", followed by entering another field u_eventid. For example: ${classification} and
${u_eventid}.
- Scenario 2:
- Source input field: Select existing alert fields and include any desired free text for how you want them to appear in the alert output field. For example: Problem type: ${type} with severity
${severity}.
Alert fields are displayed in the
${field}syntax format. You can also select the field name from the drop-down box, and the syntax will be added automatically. - Alert output: Select an existing alert field where you want to display the values from the input fields. For instance, select Description.
- Source input field: Select existing alert fields and include any desired free text for how you want them to appear in the alert output field. For example: Problem type: ${type} with severity
${severity}.