Skip to main content
Solved

Getting user segment labels in custom monitor webhook


Forum|alt.badge.img

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."
    },

 

Best answer by Yuanyuan Zhang

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. 

View original
Did this topic help you find an answer to your question?

10 replies

Yuanyuan Zhang
Team Member
Forum|alt.badge.img+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,


Forum|alt.badge.img
  • Author
  • Helpful Hero
  • 7 replies
  • October 18, 2022

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.


Yuanyuan Zhang
Team Member
Forum|alt.badge.img+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,


Yuanyuan Zhang
Team Member
Forum|alt.badge.img+5
  • Team Member
  • 181 replies
  • Answer
  • October 25, 2022

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. 


Forum|alt.badge.img
  • Author
  • Helpful Hero
  • 7 replies
  • October 26, 2022

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.


Yuanyuan Zhang
Team Member
Forum|alt.badge.img+5

Hi @TristanEarl

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

Have a good day!


Amplitude Admin
Community Manager
Forum|alt.badge.img+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. 


Yuanyuan Zhang
Team Member
Forum|alt.badge.img+5

Updates:

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


Forum|alt.badge.img
  • Author
  • Helpful Hero
  • 7 replies
  • November 3, 2022

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


Product Release Team
Team Member
Forum|alt.badge.img+2

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings