Solved

Getting user segment labels in custom monitor webhook


Userlevel 1
Badge

I have a webhook set up to receive Amplitude alerts.  When an alert fires, my webhook receives a notification as expected.  On the incoming request, I can’t find the name of the user segment that’s getting alerted.  This would especially be helpful in charts with multiple segments.  I do see a user_segment_idx field that contains a number, presumably the index into the list of segments.  Is there a way to lookup the name of the segment?  Can this be done with an API call?  Here’s a snippet of the incoming JSON payload for reference:

 

{
"charts": [
{
"header": "My Alert",
"user_segment_idx": "1",
"segment_value_label": null,
"what_happened": "2022-10-13 14:00:00: 44.4 is lower than the threshold 55.0.",
"chart_url": "https://analytics.amplitude.com/mychart?source=custom_monitor_webhook",
"rca_url": "https://analytics.amplitude.com/mychart?source=custom_monitor_email&RCA.time=2022-10-13T14%3A00%3A00",
"filename": "filename.png",
"contentType": "image/png",
"cid": "12345",
"metric": "chart_monitor_metric",
"change_str": 19,
"direction": false,
"image_url": "https://bosch-images.s3-us-west-2.amazonaws.com/public/image.png",
"anomaly_label": {
"segment": "1",
"value": null
},
"anomaly_message": "2022-10-13 14:00:00: 44.4 is lower than the threshold 55.0."
},

 

icon

Best answer by Yuanyuan Zhang 25 October 2022, 11:37

View original

10 replies

Userlevel 5
Badge +5

Hi @TristanEarl

Thank you for writing this post! 

Could you please tell me a bit more about the webhook you have set up? Did you set it up following any Amplitude Documentation? If not, can you share some external resources about the webhook? Thanks. 

Best,

Userlevel 1
Badge

Hi Yuanyuan,

Thanks for your response.  I set up my webhook using the following documentation:  https://help.amplitude.com/hc/en-us/articles/360055808391-Webhooks-for-custom-monitors#create-and-configure-a-webhook

The URL I entered points to an HTTP endpoint on our service.  In that endpoint, I can see the request coming from Amplitude, but it doesn’t seem to include the name of the user segment being alerted on.

Userlevel 5
Badge +5

Hi @TristanEarl

Thanks for letting me know! I have created a ticket on your behalf as I will need the chart that you set the webhook for. Once the issue is solved, I will post updates here, too.

We’ll be in touch!

Best,

Userlevel 5
Badge +5

Sharing updates on this topic:

This is what the Engineering Team had to say about the user_segment_idx value:
 

Hi, user_segment_idx should represent the segment index that was triggered for an alert. For example, if a chart has a list of 2 simple segments with 1 where filter per segment such as [Country=USACountry=Canada], then user_segment_idx 1 means that Country=Canada segment has an anomaly.

We currently don’t return the name of the segment in the payload, but feel free to file a feature request.

 

We have submitted a feature request to the product team. 

Userlevel 1
Badge

Hi @Yuanyuan Zhang ,

I have a follow-up question related to this.  I’m seeing for some of charts when an alert fires, the user_segment_idx field is null.  It has the same user segments as the other charts that do get a non-null value for user_segment_idx, but it does use the Formula tab.  Can you clarify in what cases the user_segment_idx is set to null?  If that field is null, how can we determine which segment has an anomaly?

 

Edit: For the chart I mentioned above, the segment_value_label field is populated with the value “  ROLLWIN(TOTALS,A,3)/ROLLWIN(TOTALS,B,3)”, which is the formula used in that chart.  All anomalous segments have this same value, so it still doesn’t give us a way to differentiate segments.

Userlevel 5
Badge +5

Hi @TristanEarl

I have reached out to the engineer team, and will get back to you with updates!

Have a good day!

Userlevel 6
Badge +9

Hi @TristanEarl , 

The Eng Team has confirmed it is a bug that the user_segment_idx field is null. They are looking into it. We will let you know once it’s fixed. 

Userlevel 5
Badge +5

Updates:

Our Engineering team has resolved the issue that the user_segment_idx field is null in the alert. 

Userlevel 1
Badge

Awesome!  I just tested and confirmed the user_segment_idx field has the correct value.  Thanks for following up with a fix!

Userlevel 3
Badge +2

We’re glad this worked out @TristanEarl. Please keep us posted as you continue to make progress with Amplitude! 😀

Reply