Knowledge Base

Incoming Webhook Metrics

Incoming webhooks can accept JSON objects to report metrics for a particular component. To enable reporting of webhook metrics for a component, simply add a webhook metric source to your component, and configure it to accept whatever metrics you require. For more general information about metrics, see the metrics documentation.

Usage

To report metrics for a component, send an HTTP POST to the metrics URL (along with the required X-WEBHOOK-KEY header) given by the metric source.

If the component your webhook metrics are added to uses a webhook watchdog as well, then the metrics URL and webhook key will be listed in the watchdog form alongside the other relevant URLs.

If you add webhook metrics to any other component, then the webhook key and metrics URL can be retrieved by clicking the Configure button on the webhook metric source.

Your request must have a JSON body with the following format:

{
  "metrics": {
    "metric_0": [
      {"x": 1488566988, "y": 1, "c": "Category0"},
      {"x": 1488566988, "y": 2, "c": "Category1"},
    ],
    "metric_1": [
      {"y": 80},
      {"y": 74}
    ],
    "metric_n": [
      {"x": 10.5, "y": 90.343, "t": 1488569976}
    ]
  }
}

metric_0 through metric_n must all be enabled on your webhook metric source, or they will not be accepted. Each metric can be given up to 25 points per request. Each point is defined by the various axes that it declares. Every point must at least declare a measure axis (in most cases, the "y-value" of your metric). By default, the x-axis of a metric represents time and will be inferred during processing if it is not reported in the webhook (observe metric_1 in the above example). If time is reported, it must be an integer UNIX timestamp.

Hint: Since you may declare the time for each point of a metric, you may report metrics at a slower interval (or report more points without increasing the reporting interval). For example, you could POST to the webhook every 5 minutes (instead of every minute), reporting all the data you collected since the last POST.

Other than the x and y axes, points may also declare c and t axes if needed. The c axis is a general category axis that can be used to create stacked bar graphs, among other visualizations. The t axis is a time axis used when neither the x nor y axes represent time so that the metric maintains an ordering (observe metric_n in the above example).

Note: Metrics are only processed every 30 seconds to a minute, depending on whether the watchdog is set to High-Frequency. This means that if you report metrics more often than the watchdog's refresh rate, you may lose data since any unprocessed data for a metric is overwritten by new incoming data for that same metric. However, you may report distinct metrics as a series of individual requests every 30 seconds to a minute if you require, without fearing overwrites. If you need to report metrics at a higher resolution, simply report more points every request.

Example payload:

{
  "metrics": {
    "exceptions_raised": [
      {"y": 1, "c": "Fatal"},
      {"y": 3, "c": "Nonfatal"}
    ],
    "response_time": [
      {"y": 80}
    ]
  }
}