This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

โš ๏ธ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use ๐Ÿ”— Github Discussions to ask your questions.

Not getting trigger JSON data processed and forwarded to action

Hi Team,
I am trying to get the status of the trigger.body.processed from the json payload which i am getting from the webhook placed.
Below is the rule configuration:

And below is the payload which i am getting in trigger instance via webhook:

  "trigger": "core.59362943-d192-4502-bc0a-9c7c8ecc69d1",
  "payload": {
    "headers": {
      "Host": "ded-95.opsteam1.srvs.ahdev.co,ded-95.opsteam1.srvs.ahdev.co",
      "X-Real-Ip": "34.222.110.137",
      "X-Forwarded-For": "34.222.110.137",
      "Content-Length": "8673",
      "Accept": "application/json",
      "X-Webhook-Id": "f2c74502-7e5b-11eb-8d69-0242c0a82a0b",
      "User-Agent": "PagerDuty-Webhook/V2.0",
      "Content-Type": "application/json",
      "X-Request-Id": "0664d280-e24c-4080-bb7b-03638479ad1d"
    },
    "body": {
      "messages": [
        {
          "event": "incident.trigger",
          "log_entries": [
            {
              "id": "RQ7LPQ18CVXGVY61GCMOS9FTGK",
              "type": "trigger_log_entry",
              "summary": "Triggered through the API",
              "self": "https://api.pagerduty.com/log_entries/RQ7LPQ18CVXGVY61GCMOS9FTGK",
              "html_url": "https://acquiaops.pagerduty.com/incidents/PH1X4KI/log_entries/RQ7LPQ18CVXGVY61GCMOS9FTGK",
              "created_at": "2021-03-06T09:11:34Z",
              "agent": {
                "id": "P0K0X5W",
                "type": "nagios_inbound_integration_reference",
                "summary": "Nagios",
                "self": "https://api.pagerduty.com/services/PFDGXO7/integrations/P0K0X5W",
                "html_url": "https://acquiaops.pagerduty.com/services/PFDGXO7/integrations/P0K0X5W"
              },
              "channel": {
                "type": "nagios",
                "host": "ded-92.opsteam1",
                "state": "CRITICAL",
                "summary": "ded-92.opsteam1",
                "service": "MySQL Real Lag",
                "details": {
                  "CONTACTPAGER": "e01258eab21f497ca5176a61d1ccbd04",
                  "HOSTDISPLAYNAME": "ded-92.opsteam1",
                  "HOSTNAME": "ded-92.opsteam1",
                  "SERVICEDESC": "MySQL Real Lag",
                  "SERVICEDISPLAYNAME": "MySQL Real Lag",
                  "SERVICEOUTPUT": "CRITICAL: Real slave lag exceeded threshold of 60m - 2146012s (run ah-dbcluster status ded-92 for full report)",
                  "SERVICEPROBLEMID": "102",
                  "SERVICESTATE": "CRITICAL",
                  "pd_nagios_object": "service"
                },
                "cef_details": {
                  "client": "",
                  "client_url": "",
                  "creation_time": "2021-03-06T09:11:29.000Z",
                  "dedup_key": "event_source=service;host_name=ded-92.opsteam1;service_desc=MySQL Real Lag",
                  "description": "CRITICAL: 'MySQL Real Lag' on 'ded-92.opsteam1'",
                  "details": {
                    "CONTACTPAGER": "e01258eab21f497ca5176a61d1ccbd04",
                    "HOSTDISPLAYNAME": "ded-92.opsteam1",
                    "HOSTNAME": "ded-92.opsteam1",
                    "SERVICEDESC": "MySQL Real Lag",
                    "SERVICEDISPLAYNAME": "MySQL Real Lag",
                    "SERVICEOUTPUT": "CRITICAL: Real slave lag exceeded threshold of 60m - 2146012s (run ah-dbcluster status ded-92 for full report)",
                    "SERVICEPROBLEMID": "102",
                    "SERVICESTATE": "CRITICAL",
                    "pd_nagios_object": "service"
                  },
                  "message": "CRITICAL: 'MySQL Real Lag' on 'ded-92.opsteam1'",
                  "mutations": [],
                  "severity": "critical",
                  "source_origin": "ded-92.opsteam1",
                  "version": "1.0",
                  "details_omitted": false
                },
                "details_omitted": false,
                "body_omitted": false
              },
              "service": {
                "id": "PFDGXO7",
                "type": "service_reference",
                "summary": "OPA",
                "self": "https://api.pagerduty.com/services/PFDGXO7",
                "html_url": "https://acquiaops.pagerduty.com/service-directory/PFDGXO7"
              },
              "incident": {
                "id": "PH1X4KI",
                "type": "incident_reference",
                "summary": "[#683222] CRITICAL: 'MySQL Real Lag' on 'ded-92.opsteam1'",
                "self": "https://api.pagerduty.com/incidents/PH1X4KI",
                "html_url": "https://acquiaops.pagerduty.com/incidents/PH1X4KI"
              },
              "teams": [
                {
                  "id": "P9CV6YW",
                  "type": "team_reference",
                  "summary": "OPA",
                  "self": "https://api.pagerduty.com/teams/P9CV6YW",
                  "html_url": "https://acquiaops.pagerduty.com/teams/P9CV6YW"
                }
              ],
              "contexts": [],
              "event_details": {
                "type": "service",
                "host": "ded-92.opsteam1",
                "service": "MySQL Real Lag",
                "service_state": "CRITICAL"
              }
            }
          ],
          "webhook": {
            "endpoint_url": "https://ded-95.opsteam1.srvs.ahdev.co/api/v1/webhooks/sample",
            "name": "Nagios Webhook",
            "description": null,
            "webhook_object": {
              "id": "PFDGXO7",
              "type": "service_reference",
              "summary": "OPA",
              "self": "https://api.pagerduty.com/services/PFDGXO7",
              "html_url": "https://acquiaops.pagerduty.com/service-directory/PFDGXO7"
            },
            "config": {
              "referer": "https://acquiaops.pagerduty.com/services/PFDGXO7/integrations?service_profile=1"
            },
            "outbound_integration": {
              "id": "PJFWPEP",
              "type": "outbound_integration_reference",
              "summary": "Generic V2 Webhook",
              "self": "https://api.pagerduty.com/outbound_integrations/PJFWPEP",
              "html_url": null
            },
            "accounts_addon": null,
            "id": "PLP8LA2",
            "type": "webhook",
            "summary": "Nagios Webhook",
            "self": "https://api.pagerduty.com/webhooks/PLP8LA2",
            "html_url": null
          },
          "incident": {
            "incident_number": 683222,
            "title": "CRITICAL: 'MySQL Real Lag' on 'ded-92.opsteam1'",
            "description": "CRITICAL: 'MySQL Real Lag' on 'ded-92.opsteam1'",
            "created_at": "2021-03-06T09:11:34Z",
            "status": "triggered",
            "incident_key": null,
            "service": {
              "id": "PFDGXO7",
              "name": "OPA",
              "description": "https://backlog.acquia.com/browse/OP-295273",
              "created_at": "2021-02-01T20:40:50Z",
              "updated_at": "2021-02-24T10:40:41Z",
              "status": "critical",
              "teams": [
                {
                  "id": "P9CV6YW",
                  "type": "team_reference",
                  "summary": "OPA",
                  "self": "https://api.pagerduty.com/teams/P9CV6YW",
                  "html_url": "https://acquiaops.pagerduty.com/teams/P9CV6YW"
                }
              ],
              "alert_creation": "create_alerts_and_incidents",
              "addons": [],
              "scheduled_actions": [],
              "support_hours": null,
              "last_incident_timestamp": "2021-03-06T09:11:34Z",
              "escalation_policy": {
                "id": "PS44B0I",
                "type": "escalation_policy_reference",
                "summary": "OPA",
                "self": "https://api.pagerduty.com/escalation_policies/PS44B0I",
                "html_url": "https://acquiaops.pagerduty.com/escalation_policies/PS44B0I"
              },
              "incident_urgency_rule": {
                "type": "constant",
                "urgency": "high"
              },
              "acknowledgement_timeout": null,
              "auto_resolve_timeout": null,
              "alert_grouping": null,
              "alert_grouping_timeout": null,
              "alert_grouping_parameters": {
                "type": null,
                "config": null
              },
              "integrations": [
                {
                  "id": "PKF9GZT",
                  "type": "app_event_transform_inbound_integration_reference",
                  "summary": "Rundeck - Runbook Automation",
                  "self": "https://api.pagerduty.com/services/PFDGXO7/integrations/PKF9GZT",
                  "html_url": "https://acquiaops.pagerduty.com/services/PFDGXO7/integrations/PKF9GZT"
                },
                {
                  "id": "P85ZYX9",
                  "type": "generic_events_api_inbound_integration_reference",
                  "summary": "StackStorm",
                  "self": "https://api.pagerduty.com/services/PFDGXO7/integrations/P85ZYX9",
                  "html_url": "https://acquiaops.pagerduty.com/services/PFDGXO7/integrations/P85ZYX9"
                },
                {
                  "id": "P0K0X5W",
                  "type": "nagios_inbound_integration_reference",
                  "summary": "Nagios",
                  "self": "https://api.pagerduty.com/services/PFDGXO7/integrations/P0K0X5W",
                  "html_url": "https://acquiaops.pagerduty.com/services/PFDGXO7/integrations/P0K0X5W"
                },
                {
                  "id": "PFD75UY",
                  "type": "generic_email_inbound_integration_reference",
                  "summary": "Rundeck Email",
                  "self": "https://api.pagerduty.com/services/PFDGXO7/integrations/PFD75UY",
                  "html_url": "https://acquiaops.pagerduty.com/services/PFDGXO7/integrations/PFD75UY"
                },
                {
                  "id": "P9KSMZ7",
                  "type": "generic_email_inbound_integration_reference",
                  "summary": "Stackstorm email",
                  "self": "https://api.pagerduty.com/services/PFDGXO7/integrations/P9KSMZ7",
                  "html_url": "https://acquiaops.pagerduty.com/services/PFDGXO7/integrations/P9KSMZ7"
                },
                {
                  "id": "PSPOC9H",
                  "type": "events_api_v2_inbound_integration_reference",
                  "summary": "Stackstorm",
                  "self": "https://api.pagerduty.com/services/PFDGXO7/integrations/PSPOC9H",
                  "html_url": "https://acquiaops.pagerduty.com/services/PFDGXO7/integrations/PSPOC9H"
                }
              ],
              "metadata": {},
              "response_play": null,
              "type": "service",
              "summary": "OPA",
              "self": "https://api.pagerduty.com/services/PFDGXO7",
              "html_url": "https://acquiaops.pagerduty.com/service-directory/PFDGXO7"
            },
            "assignments": [
              {
                "at": "2021-03-06T09:11:34Z",
                "assignee": {
                  "id": "PNF7VAO",
                  "type": "user_reference",
                  "summary": "TestNullUser",
                  "self": "https://api.pagerduty.com/users/PNF7VAO",
                  "html_url": "https://acquiaops.pagerduty.com/users/PNF7VAO"
                }
              }
            ],
            "assigned_via": "escalation_policy",
            "last_status_change_at": "2021-03-06T09:11:34Z",
            "first_trigger_log_entry": {
              "id": "RQ7LPQ18CVXGVY61GCMOS9FTGK",
              "type": "trigger_log_entry_reference",
              "summary": "Triggered through the API",
              "self": "https://api.pagerduty.com/log_entries/RQ7LPQ18CVXGVY61GCMOS9FTGK",
              "html_url": "https://acquiaops.pagerduty.com/incidents/PH1X4KI/log_entries/RQ7LPQ18CVXGVY61GCMOS9FTGK"
            },
            "alert_counts": {
              "all": 0,
              "triggered": 0,
              "resolved": 0
            },
            "is_mergeable": false,
            "escalation_policy": {
              "id": "PS44B0I",
              "type": "escalation_policy_reference",
              "summary": "OPA",
              "self": "https://api.pagerduty.com/escalation_policies/PS44B0I",
              "html_url": "https://acquiaops.pagerduty.com/escalation_policies/PS44B0I"
            },
            "teams": [
              {
                "id": "P9CV6YW",
                "type": "team_reference",
                "summary": "OPA",
                "self": "https://api.pagerduty.com/teams/P9CV6YW",
                "html_url": "https://acquiaops.pagerduty.com/teams/P9CV6YW"
              }
            ],
            "impacted_services": [
              {
                "id": "PFDGXO7",
                "type": "service_reference",
                "summary": "OPA",
                "self": "https://api.pagerduty.com/services/PFDGXO7",
                "html_url": "https://acquiaops.pagerduty.com/service-directory/PFDGXO7"
              }
            ],
            "pending_actions": [],
            "acknowledgements": [],
            "basic_alert_grouping": null,
            "alert_grouping": null,
            "last_status_change_by": {
              "id": "PFDGXO7",
              "type": "service_reference",
              "summary": "OPA",
              "self": "https://api.pagerduty.com/services/PFDGXO7",
              "html_url": "https://acquiaops.pagerduty.com/service-directory/PFDGXO7"
            },
            "metadata": {},
            "external_references": [],
            "incidents_responders": [],
            "responder_requests": [],
            "subscriber_requests": [],
            "urgency": "high",
            "id": "PH1X4KI",
            "type": "incident",
            "summary": "[#683222] CRITICAL: 'MySQL Real Lag' on 'ded-92.opsteam1'",
            "self": "https://api.pagerduty.com/incidents/PH1X4KI",
            "html_url": "https://acquiaops.pagerduty.com/incidents/PH1X4KI",
            "alerts": [
              {
                "alert_key": "event_source=service;host_name=ded-92.opsteam1;service_desc=MySQL Real Lag"
              }
            ]
          },
          "id": "f2c74502-7e5b-11eb-8d69-0242c0a82a0b",
          "created_on": "2021-03-06T09:11:34Z",
          "account_features": {
            "response_automation": true
          },
          "account_id": "PZH8ILE"
        }
      ]
    }
  },
  "occurrence_time": "2021-03-06T09:11:34.000000Z",
  "status": "processed",
  "id": "604347476a4da21609584dd6"
}```

I am not able to understand how to process this payload which i am getting via webhook.

I followed a conversation in support forum and got to know that we can check the status if the trigger body has got processed or not by using โ€œ{{trigger.body.processed}}โ€ i tried it to check if the payload is been forwarded to action. But i am not getting any output for that too. Kindly help.

You are very close :slightly_smiling_face: If you check the status is out of the body section. You need to change your jinja to appropriately find the status field in your json.
{{trigger.status}} might do the trick!

@arms11 thats something which torments me the most, how can i adjust my jinja to get the status field in the payload. Can you guide me on it, i am not sure about how to get this done.

Or in other case can i get anything displayed which is there in the body section? what should i write to display value of any key given inside the body of the trigger payload.

I think if I understand your question, I already gave the answer.

I mean I donโ€™t know what you expect or desire to do with your payload, but you can extract information out of the body or header with help of jinja and pass along to your action (hopefully more than core.echo) to do whatever you want.

From looking your json above what you get is the array of incidents {{trigger.body.messages}}, so while I am not a jinja expert, you can go through jinja docs to see how you can work with arrays. Hope that helps!

I started getting the data from the trigger to work.

But while processing the input in the workflow, i am getting different different errors. I can understand some good learning curve but this is simply giving some hard time.

Below is the workflow file:

version: 1.0
tasks:
  output_alert:
    action: core.echo
    with:
      items: "{{ ctx().alerts }}"
      concurrency: 1
    input:
      message: "Alert hostname {{item(HOSTNAME)}}, Alert hostname {{item(SERVICEDESC)}}"
input:
  - alerts

Below if the workflow file:

pack: default
enabled: true
runner_type: orquesta
parameters:
  alerts:
    type: object
    required: true
name: event_demo
entry_point: workflows/event_demo.yaml

Not sure how could i be able to fetch the data from the trigger payload which i am getting in the WF:

{"CONTACTPAGER":"e01258eab21f497ca5176a61d1ccbd04","HOSTDISPLAYNAME":"web-4.opsteam1","HOSTNAME":"web-4.opsteam1","SERVICEDESC":"Services Check","SERVICEDISPLAYNAME":"Services Check","SERVICEOUTPUT":"active","SERVICEPROBLEMID":"295","SERVICESTATE":"CRITICAL","pd_nagios_object":"service"}

I need some assistance here, to solve the problem.

Thanks its working now.