Feature Idea: Webhook notification channel - Targets are not shown

Hi,

As per the link - Sending Alerts data to Insights
I have created a webhook notification channel and provided the payload as below

{
  "eventType": "alert",
  "account_id": "$ACCOUNT_ID",
  "account_name": "$ACCOUNT_NAME",
  "closed_violations_count_critical": "$CLOSED_VIOLATIONS_COUNT_CRITICAL",
  "closed_violations_count_warning": "$CLOSED_VIOLATIONS_COUNT_WARNING",
  "condition_description": "$DESCRIPTION",
  "condition_family_id": "$CONDITION_FAMILY_ID",
  "condition_name": "$CONDITION_NAME",
  "current_state": "$EVENT_STATE",
  "details": "$EVENT_DETAILS",
  "duration": "$DURATION",
  "event_type": "$EVENT_TYPE",
  "incident_acknowledge_url": "$INCIDENT_ACKNOWLEDGE_URL",
  "incident_id": "$INCIDENT_ID",
  "incident_url": "$INCIDENT_URL",
  "metadata": "$METADATA",
  "open_violations_count_critical": "$OPEN_VIOLATIONS_COUNT_CRITICAL",
  "open_violations_count_warning": "$OPEN_VIOLATIONS_COUNT_WARNING",
  "owner": "$EVENT_OWNER",
  "policy_name": "$POLICY_NAME",
  "policy_url": "$POLICY_URL",
  "runbook_url": "$RUNBOOK_URL",
  "severity": "$SEVERITY",
  "targets": "$TARGETS",
  "timestamp": "$TIMESTAMP",
  "violation_callback_url": "$VIOLATION_CALLBACK_URL",
  "violation_chart_url": "$VIOLATION_CHART_URL"
}

I receive the webhook notification and the dashboard gets updated as and when the violation is seen. But the “targets” are not getting displayed when i try to dump the entire event fields by using the NRQL query

SELECT * FROM alert

As per the documentation, i adhere to the rules. Could you check and let me know if any issues here.

"targets" $TARGETS

The $TARGETS variable cannot be used with FORM data, but is compatible with JSON data.

For static NRQL faceted alerts, the name of the facet that triggered the alert will be populated in the target’s name field.


New Relic Edit

  • I want this too
  • I have more info to share (reply below)
  • I have a solution for this

0 voters

We take feature ideas seriously and our product managers review every one when plotting their roadmaps. However, there is no guarantee this feature will be implemented. This post ensures the idea is put on the table and discussed though. So please vote and share your extra details with our team.

Hi @naveen.shivanna -

The Targets attribute of the Webhook Payload is formatted in nested JSON, such as:

{
  "key": "value",
  "key1": "value1",
  "targets": {
    "key2": "value2",
    "key3": "value3"
  }
}

The Insights event API (which is what you are hitting when your webhook sends alert data to Insights), only supports one layer of JSON.

If you need the targets array of data, I would suggest sending the webhook to a 3rd party service, or a custom built service like a lambda function that serves to flatten the JSON, such that the Targets are included in the one layer of JSON required.

I’ll convert your post into a feature idea & send it up to the Insights team, for the event API to accept nested JSON

1 Like

Another option is to use New Relic Connect, which has a flatten_target option.

2 Likes

Can you please provide example for using flatten_target in payload to retrieve ‘name’ in $TARGETS?

i tried the below way but could not get the result-

“sections”: [
{

    "flatten_target": true, 
        "startGroup": true,  
        "title": "**$TARGETS.name $CONDITION_NAME $EVENT_DETAILS incident $EVENT_STATE**",

Hey @mgalla - I haven’t used flatten target personally and I don’t see any examples on our docs, but, I’m happy to look into this with you.

Can you clarify what about this is not working for you? What error are you getting, or, what do you mean by ‘could not get the result’??

Along a similar thread, I’m interested in dumping an array of JSON payloads to render the data using NR Insights’ interactive dashboards.

As a corollary, Power BI streaming datasets allows JSON payloads to be posted to an endpoint and rendered in real-time. If you have a backlog of pre-existing payloads, you can populate them into an array and fire the whole lot through directly in one request for Power BI to separate out into individual events.

This would allow Insights to take the spotlight as the data collation and rendering solution, particularly when looking to migrate from alternatives.

Hey @rishav.dhar

I’m not sure your question fits this thread, but, you can already do that with Insights. Your JSON payload must be single layered, and each segment must include an event type, but other than that, you can send the data you need… A sample payload below; sending 2 different events in the same JSON file.

[
   {
      "eventType":"myFirstEvent",
      "attribute1":123,
      "anotherAttribute": "Here is a attribute value"
   },
   {
      "eventType":"mySecondEvent",
      "actionType":"purchase",
      "account":5,
      "amount":12309,
      "product":"Super expensive thing"
   }
]

Oh, this changes things!

In that case, is there a data retention period set for this? In my use-case, the data payload I would like to upload into Insights start from January 2020.

On that note, is there a specific timestamp format I need to follow for Insights input? It’s in ISO 8601 format (i.e., 2020-01-02T14:05:05Z) at the moment.

So there may be some issues with that.

You can absolutely send events, regardless of when they are from… the issue with that is that, as far as I know, you can only backdate the events by 24hrs. If you want to add in a separate attribute for date, you can, but the timestamp attribute will either be today or yesterday. Within 24hrs.

As for format, the timestamp must be a 64-bit integer (unix time), as per this doc:
https://docs.newrelic.com/docs/insights/insights-data-sources/custom-data/introduction-event-api#json-guidelines

You can use a Unix time converter like this: https://www.unixtimeconverter.io/ to figure out the 64 bit integer from a ISO 8601 time format.

In addition, retention depends on your subscription.

If you have an Insights Free subscription, you will get 1 day of custom event retention.

If you have an Insights pro subscription, you likely have more, but that will depend on your account’s contracted amount.