Define Custom Variable

Here’s to hoping I am in the correct category.

I have an onprem version of prometheus that is feeding data to Pagerduty. From there I am trying to execute a custom incident action back to On Premises Process automation. In order to match the nodename in process automation to the server name in the alert, I believe I need to define a custom variable, but can’t seem to get it to work.

The message that is in Pagerduty looks like this

Labels:

  • alertname = AlertName
  • application = AppName
  • category = Cat
  • creating_process_id = 724
  • instance = InstanceName
  • job = JobName
  • location = location
  • process = process
  • process_id = 2576
    - servername = servername
  • severity = critical

The JSON payload that goes to Process Automation via the webhook only has the server name listed in the summary sections. and they look like this:

“incident”: {
“id”: “ID#”,
“type”: “incident_reference”,
“summary”: “[iNCIDENT#] [FIRING:1] Alertname [INSTANCENAME] (Better description of said alert that has the Servername in it here and Ends with Servername critical)”,
“self”: “https://api.pagerduty.com/incidents/incidentkey”,
“html_url”: “https://wynn.pagerduty.com/incidents/incidentkey
},

Wondering if someone could point me in the right direction of creating a variable that will be fed over to rundeck so I can match the node names.

Appreciate it in advance,

Dave

Take a look at event triggered webhooks and creating the extractions there into new fields to be sent to your webhook endpoint.

Creating custom variables: https://support.pagerduty.com/docs/event-orchestration#create-custom-variables
Event Triggered Webhook Action: https://support.pagerduty.com/docs/event-orchestration#webhooks

I like to use this site to test my regex for custom variables. It uses the Go implementation of regex that PagerDuty uses, so it will transfer over to the custom variable creation exactly as is.

I copied the example JSON above and entered this string to get “servername” to return: (?i)(?:Ends with )(\w*)(?: critical)

So, after testing that string, I would just paste it in the regex section and use dot notation to pick the field that the regex should be applied to. Like this:

1 Like