alerts.sources.read; creating, editing, deleting and rotating tokens require alerts.sources.manage.
Source kinds
Each source has a kind, which decides whose format the request body is read in.
Systems that speak the Alertmanager webhook, such as the Alertmanager of Thanos, Cortex or Mimir, use the Alertmanager kind.
Create a source
- Open Alerts → Sources and click New alert source.
- Choose the Kind and enter a Name.
- Choose the Escalation policy. The default is Routed (default), the same as in the rule workbench: alert routing picks the team and the escalation policy by the routing rules, the service’s owning team and the team label, and otherwise the default policy named
default. With a policy chosen, incidents take it and routing only picks the team. With No escalation, notify policies only, incidents still open and notify, but no escalation policy pages anyone. - Choose the Default severity, used when an alert carries no severity of its own.
- Add Extra labels if needed, such as
team=payments. They are added to every incident the source opens. A label the alert carries itself wins. - Click Create. The source’s page opens with a dialog that shows its token and the setup with the token filled in; Alibaba Cloud CloudMonitor needs only the intake address, so the dialog shows the address with the token in it.
Intake address and token
Every source shares one intake address. The token tells which source an alert belongs to:ms_<16>_<32>, the same shape as an API token, but it only takes in alerts, and an API token cannot take in alerts. The sender puts it in a header:
https://<molesignal-host>/api/v1/intake/alerts?token=<token>.
The sender must reach this address. When a firewall stands in front of MoleSignal, allow the egress addresses of the sender’s site or region: Datadog lists them per site in the webhooks section of its ip-ranges, PagerDuty publishes them for its US and EU service regions, and Alibaba Cloud CloudMonitor lists its push ranges in its alarm callback docs. When MoleSignal runs on an internal network, see Public access for opening only this address to the internet.
Set up the sender
Intake on the source’s page gives the intake address, the token and the setup of each kind in three steps. Replace<TOKEN> with the token of the source. Once the source receives its first request, the three steps are checked.
API
action is trigger (the default), acknowledge or resolve. Use the same dedup_key to acknowledge or resolve the same alert. Send alerts describes every field.
Alertmanager
Add a receiver toalertmanager.yml and route alerts to it:
send_resolved at true, or recoveries are never sent. Give every replica of one Alertmanager cluster the same --web.external-url: the external URL is part of the dedup key, so groups of the same name from Alertmanagers in several regions with the same routing are not merged into one incident.
Grafana
- In Grafana, open Alerting → Contact points and click Add contact point.
- Set Integration to Webhook and URL to the intake address.
- Under Optional Webhook settings, set Authentication Header Scheme to
Bearerand Authentication Header Credentials to the token. - Leave Disable resolved message cleared, save, and use the contact point in a notification policy.
Datadog
- In Datadog, open Integrations → Webhooks and add a webhook, named for example
molesignal. - Set URL to the intake address and Custom Headers to
{"Authorization": "Bearer <token>"}. Leave Encode as form cleared. - Set Payload to the template below. The field names are MoleSignal’s and the values are Datadog variables; a request without this template is refused.
- Mention
@webhook-molesignalin the notification message of a monitor.
datadoghq.com, datadoghq.eu, us3, us5, ap1 and the others) can send to one source: the site is taken from the domain of $LINK and is part of the dedup key, together with the organization ID.
PagerDuty
- In PagerDuty, open Integrations → Generic Webhooks (v3) and click New Webhook.
- Set Webhook URL to the intake address and choose the Scope Type (the account, a service or a team).
- Under Event Subscription, select
incident.triggered,incident.acknowledged,incident.resolved,incident.reopenedandincident.priority_updated. - Add the custom header
Authorizationwith the valueBearer <token>.
<subdomain>.pagerduty.com or <subdomain>.eu.pagerduty.com) is part of the dedup key and is written to the label pagerduty.region.
Alibaba Cloud CloudMonitor
Add the token to the intake address:- Threshold alarms: enter this address as the alarm callback of an alarm rule. CloudMonitor POSTs the callback form-encoded; MoleSignal also reads JSON.
- System events: under Event Center → Event Subscription → Push channels, create a channel with the Webhook target type, the POST request method and the JSON data format, enter this address, and use the channel in a subscription policy.
503 on timeout so that CloudMonitor retries. The China and international sites and every region send the same format; the region is written to the label aliyun.region, and the account userId is part of the dedup key.
Tencent Cloud Observability Platform
In Tencent Cloud Observability Platform (formerly Cloud Monitor), edit or create a template under Alarm Management → Notification Templates, enter the intake address as its API callback, and bind the template to your alarm policies. Tencent Cloud’s callback cannot set headers, so the token goes in the address. Keep the address as a credential: the callback carries no signature, and the address is what identifies the source. Metric and event alarms both work, and triggers and recoveries are both pushed.- Dedup: the same account, alarm policy, metric or event name, and object make one alert. A leveled policy has one incident per level, each recovering on its own, as in Tencent Cloud.
- Severity:
alarmLevelSerious (Serious) is critical, Severe (Warn) is error and Reminder (Remind) is info. A policy without levels takes the source’s default severity. - Stateless events (
alarmStatusis5) open an incident with no recovery to wait for, so a person resolves it. - Times in the callback carry no time zone and are read as Beijing time.
Amazon CloudWatch
CloudWatch alarms do not call outside addresses themselves; they go through SNS:-
In the alarm’s notifications, send both entering In alarm (
ALARM) and returning to OK to the same SNS topic. WithoutOK, incidents do not resolve on their own. For no-data alerts, send Insufficient data (INSUFFICIENT_DATA) too. -
Add an HTTPS subscription to the topic with the intake address as its endpoint, the token in the address:
-
The subscription confirms itself: MoleSignal checks the signature of the confirmation message, then visits its
SubscribeURL.
sns.<region>.amazonaws.com, so the node taking the request must be able to reach that address.
CloudWatch alarms have no severity, so incidents take the source’s default. The alarm’s ARN is the dedup key, for composite alarms too. The alarm’s description and the reason for the state change go in annotations; the region, account, namespace, metric and dimensions go in labels, so a label like aws.region can drive routing.
Zabbix
Works from Zabbix 6.0. Zabbix has no request format of its own: a media type’s script sends the request. So the source’s page, and the dialog when you create it, give you a media type with the address and token filled in:- Save it as YAML and import it under Alerts → Media types → Import. Check the
tokenparameter. - Set the global macro
{$ZABBIX.URL}to the address of the Zabbix frontend. It counts in the dedup key, so one source can take several Zabbix servers, and incidents link back to Zabbix. It works without it too. - Give a user this media. Send to can be anything; the script does not use it.
- Add a trigger action whose operations, recovery operations and update operations all go to that user. Without recovery operations incidents do not resolve on their own.
{EVENT.ID} arrives as it is), MoleSignal answers 400 and says to use the media type from the docs.
INBOX by default) and Read every (15 to 3600 seconds, 60 by default). Click Test connection, then Save mailbox.
- Read only: it uses
EXAMINEandBODY.PEEK[], so nothing is marked as read or deleted. A read-only account will do. - No backlog: on first connecting it notes the position and reads only what arrives afterwards. A change of host, account or folder, or a server that rebuilt the mailbox (
UIDVALIDITYchanged), starts over from that moment. While the source is off nothing is read and no position is kept: it starts from the moment it is turned on again. - The sender list is required: anyone who knows the address can mail it. Under Accept mail from in the source’s settings, write addresses or
@example.comfor a whole domain;*accepts everyone. The list readsFrom, which can be forged, so keep the mail provider’s spam filtering and DMARC on. Mail from anyone else is recorded as Refused and opens nothing. - Signing in: a password, or an app password from the provider. Microsoft 365 no longer takes passwords: choose OAuth 2.0 and fill in the token address
https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token, the client ID, the client secret and the scopehttps://outlook.office365.com/.default. The application needs theIMAP.AccessAsApppermission and access to this mailbox. - No encryption belongs only on a network you trust: the password crosses it in the clear.
- When a read fails, the source’s page says why, and the next round tries again. With several alert nodes each mailbox is read by one of them. With federation, the mailbox is set up on the source’s receiving cluster and does not sync, so the password stays there.
pipe, SES, Mailgun’s raw MIME), POST the raw message to the intake address:
The severity comes from words in the subject (
critical, fatal, disaster, P1 are critical; error, P2 error; warning, P3 warning; info, notice, P4, P5 info), or else the source’s default; the high and low of High CPU and Low disk do not count. The body goes in the annotation message (HTML mail as text, at most 4096 characters), the sender in the label email.from and the annotation from, and the time comes from the Date header. Automatic replies (Auto-Submitted: auto-replied) and bounces (multipart/report) are no alerts. GBK, GB2312 and other character sets are understood. Mail over 4 MiB is recorded as Refused without its body being read.
How alerts become incidents
Priority and urgency are read apart: the API’s
priority and urgency, Datadog’s $ALERT_PRIORITY, and PagerDuty’s priority and urgency become the incident’s priority and urgency. Without an urgency, the source’s escalation policy decides, and an alert that reports no severity is high urgency; see Urgency.
An alert without a severity takes the source’s Default severity. The severity words of every sender are case-insensitive: critical, crit, fatal, page and P1 are critical; error, major, high and P2 are error; warning, warn, minor, medium and P3 are warning; info, low, P4 and P5 are info. Any other word takes the default severity.
- Opening: one source has at most one active incident per dedup key. The incident carries the labels
alert.source=externalandexternal.kind=<kind>, the alert’s own labels (for Alertmanager and Grafana, the group’scommonLabels) and the extra labels of the source. The labelservice.nameorservicebecomes an affected service, andhost.name,hostorhostnamebecomes a host. - Title: API uses
summary; Alertmanager and Grafana use thesummaryannotation, oralertnamewithout one; Datadog uses$ALERT_TITLE; PagerDuty uses the incident title; Alibaba Cloud CloudMonitor uses “alarm name · instance name”. - Links: addresses back to the sender are written to annotations, such as
alertmanager_url,generator_url,dashboard_url,datadog_urlandpagerduty_url, and the incident page shows them as links. Thelinksof the API are written to annotations byname. - Alerts of a group: an incident from Alertmanager or Grafana keeps every alert of the group (up to 100) with its status, updated with each notification. External alert on the incident page lists them, with the labels that tell them apart.
- Severity changes: an incident that is not yet acknowledged follows the severity of the alert, as the alert pipelines decide it. When it rises, escalation starts over from the first step. A severity set by hand stays.
- Acknowledging: the API’s
acknowledge, PagerDuty’sincident.acknowledgedand Zabbix update operations that acknowledge a problem acknowledge the incident and stop further escalation steps and calls. No user is recorded as the acknowledger. - Resolving: the incident resolves when the source reports recovery, acknowledged incidents included. No user is recorded as the resolver, and the timeline shows it as recovered.
- Late messages: each dedup key remembers the latest sender time it used, and an older message is ignored. A late trigger does not open a zombie incident, and a late recovery does not close a new one. The API carries no time, so its messages are taken in the order they arrive.
- Resolved by a person first: when the source still reports the alert, its next resend opens a new incident, as for rules.
- No data: incidents opened by CloudMonitor’s
INSUFFICIENT_DATAand Datadog’s No Data carryalert.condition=no_data, and their notification titles start withNO DATA. - Turning off and deleting: a turned-off source refuses alerts (
409), and its open incidents stay. Deleting a source makes its token stop working at once and resolves its open incidents.
external.kind, the extra labels of a source, or the alert’s own labels.
Recently received
The top of the source’s page says how the source stands: Waiting for the first request, Receiving, Last request refused, No requests in 7 days or Turned off. Beside it are the requests and alerts of the last 24 hours, and the incidents the source opened that are still open. Once requests have come in, Recently received on the source’s page lists the requests the source received: the time, the result (Handled, Refused or Forwarded), the HTTP status, the number of alerts and what became of them (Opened, Updated, Unchanged, Acknowledged, Resolved or Ignored). Click a row to see each alert’s title, severity, action, result and incident; a refused request also shows the reason and the start of its body (up to 16 KiB). The last 500 requests of each source are kept, for up to 7 days.Multiple clusters
With cross-cluster federation on:- Sources sync between clusters like other alerting configuration, tokens included, so one token works at the intake address of every cluster.
- The incidents of a source open only on its Receiving cluster: the cluster it was created on, unless changed in the source’s settings. Another cluster that receives an alert of the source passes it over gRPC to the receiving cluster, and returns the receiving cluster’s answer to the sender. One external alert is therefore one incident, whichever cluster’s address it arrives at.
- When the receiving cluster cannot be reached, the answer is
503and the sender retries. If the receiving cluster’s region stays down, change the Receiving cluster in the source’s settings to one that is up. - Recently received is recorded on the cluster that handled the request. The source’s page says so when it is opened on another cluster.
Limits
The HMAC signature of Grafana and the signature of PagerDuty are not checked; the token already tells the source. Acknowledging or resolving an incident in MoleSignal is not written back to the sender.