Skip to content

Webhook notifications

Using Webhook you can receive the JSON from your Mackerel alerts with POST. This will be handy for those users who want to automate processes that occur after notifications are received.

Adding Webhook notifications

Notification settings can be added and configured Webhook form in the Channels Page. Here you will need to designate the URL that will receive POSTs from Mackerel's servers.

JSON format

The JSON that will be sent contains the following. (Items may be added at any time)

json
{
  "orgName": "Macker...",
  "event": "alert",
  "imageUrl": "https://mackerel.io/embed/public/.../....png",
  "memo": "memo....",
  "type": "host",
  "message": "MetricName 2.26 > 1.96",
  "host": {
    "id": "22D4...",
    "name": "app01",
    "url": "https://mackerel.io/orgs/.../hosts/...",
    "type": "unknown",
    "status": "working",
    "memo": "",
    "isRetired": false,
    "roles": [
      {
        "fullname": "Service: Role",
        "serviceName": "Service",
        "serviceUrl": "https://mackerel.io/orgs/.../services/...",
        "roleName": "Role",
        "roleUrl": "https://mackerel.io/orgs/.../services/..."
      }
    ]
  },
  "alert": {
    "openedAt": 1473129912,
    "closedAt": 1473130092,
    "createdAt": 1473129912693,
    "statusChangedAt": 1473130092,
    "criticalThreshold": 1.9588528112516932,
    "duration": 5,
    "isOpen": true,
    "metricLabel": "MetricName",
    "metricValue": 2.255356387321597,
    "monitorName": "MonitorName",
    "monitorOperator": ">",
    "status": "critical",
    "trigger": "monitor",
    "id": "2bj...",
    "url": "https://mackerel.io/orgs/.../alerts/2bj...",
    "warningThreshold": 1.4665636369580741
  }
}

JSON items

KEYTYPEDESCRIPTION
orgNamestringname of the organization where the alert occurred
eventstringfixed as alert
typestringthe type of the monitor: connectivity ("connectivity"), host metric ("host"), service metric ("service"), external monitor ("external"), check monitor ("check"), expression monitor ("expression"), or anomaly detection for roles ("anomalyDetection")
messagestringalert message
hostobjecthost information (output for alerts of host metrics only)
serviceobjectservice information (output for alerts of service metrics only)
alertobjectalert information
imageUrlstring / nullimage URL of the corresponding graph
However, this is set as null if Include graph image is turned off or if no corresponding graph exists.
memostringnotes regarding the monitor.

JSON items (host information)

KEYTYPEDESCRIPTION
idstringhost ID
namestringhost name
urlstringURL of the host details
statusstringhost status (working, standby, poweroff, maintenance)
memostringmemo registered to the host
isRetiredbooleanwhether or not retired
rolesarray[object]role information (if the role is configured to the host)

JSON items (role information)

KEYTYPEDESCRIPTION
fullnamestringservice name: role name
serviceNamestringservice name
serviceUrlstringURL of the service details
roleNamestringrole name
roleUrlstringURL of the role in service details

JSON items (service information)

KEYTYPEDESCRIPTION
idstringservice ID
memostringmemo registered to services
namestringservice name
orgIdstringID of the organization where the service is registered
rolesarray[object]role information (if the role is registered in services)

JSON items (Metric information by query monitoring)

KEYTYPEDESCRIPTION
labelsobjectlabels of the metric e.g. { "http.method": "GET", "http.status_code": "200" }
namestringmetric name e.g. httpcheck.status

JSON items (alert information)

KEYTYPEDESCRIPTION
idstringalert ID
statusstringalert status (ok, warning, critical, unknown)
isOpenbooleanwhether or not the alert is open
triggerstringwhat triggered the notification (monitoring, manual, monitorDelete, hostRetire)
urlstringURL of the alert details
openedAtnumbertime the alert occurred (epoch seconds)
closedAtnumbertime the alert resolved (epoch seconds)
statusChangedAtnumbertime the alert status changed (epoch seconds)
createdAtnumbertime the alert occurred (epoch milliseconds). A deprecated item and not recommended. Please use openedAt
monitorNamestringname of the monitoring item that detected the alert
metricLabelstringtitle of the monitoring target's metrics etc.
metricValuenumbermetric value at the time of detection
criticalThresholdnumberCRITICAL threshold
warningThresholdnumberWARNING threshold
monitorOperatorstring> or <
durationnumbermonitoring interval

Note: Alert information items fluctuate depending on the type of monitoring target (host metrics, service metrics, external monitoring, expression monitoring, query monitoring) and each configuration item. For example, if only the URL is configured with external monitoring, information for metrics, thresholds, etc. will not be included. The type of monitoring target and the output items correspond with possible input items from the monitoring configurations screen.

Making use of Webhook

Security when using Webhook

For security purposes, we recommend taking the following measures when using Webhook.

  • Use SSL
    • Does not support unique certificates or partial certificate authority
  • Set up basic authentication and include the authentication information in the URL
    • Format like this https://user:p4ssw0rd@example.com
  • Enforce IP restriction
    • For infomation of the IP address range of request origins of notifications from Mackerel, check our FAQ page.