Curious Minds

Clear answers to science and history questions

Alertmanager Webhooks vs Native Alert Labels for Context

· 6 min read · Science

Alertmanager webhooks and native alert labels both add context to alerts, but they serve fundamentally different purposes: labels are structured key-value pairs that define alert identity and routing, while webhooks are HTTP callbacks that deliver the full alert payload to external systems. For adding context, labels are the primary mechanism within Alertmanager, while webhooks extend context to external tools and workflows.

Background: Why Context Matters in Alerting

In any monitoring setup, an alert without context is just a timestamp and a metric name. Context answers the questions: What exactly is failing? How severe is it? Who owns it? What should the responder do first? Alertmanager, the alert handling component of Prometheus, processes alerts generated by Prometheus rules and routes them to receivers like email, Slack, PagerDuty, or custom webhooks. The way you attach context to these alerts determines how quickly an on-call engineer can triage and resolve an incident.

How Native Alert Labels Work

Prometheus alerts are defined in recording and alerting rules. Each alert can have a set of labels attached in the rule definition. These labels are key-value pairs, for example severity="critical", team="platform", or service="api-gateway". Labels serve two main functions:

  • Identity: Labels like alertname and instance uniquely identify an alert. If the same label set fires again, Alertmanager treats it as the same alert and can group or silence it.
  • Routing: Alertmanager uses label matchers in route definitions to decide which receiver to send an alert to. For example, team: platform routes to the platform Slack channel, while severity: page routes to PagerDuty.

Labels are also used for grouping (combining related alerts into one notification) and inhibition (suppressing lower-severity alerts when a higher one is active). They are the native, structured way to add context that Alertmanager itself understands and acts upon.

How Webhooks Add Context

A webhook is an HTTP endpoint that Alertmanager sends a POST request to whenever an alert fires, resolves, or is suppressed. The request body is a JSON payload containing the alert data, including all labels, annotations, and some metadata like startsAt and endsAt. Webhooks are defined as receivers in Alertmanager’s configuration:

receivers:
- name: 'custom-webhook'
  webhook_configs:
  - url: 'https://example.com/hooks/alert'
    send_resolved: true

Webhooks provide context in a different way: they push the alert data to an external system, which can then enrich it with additional context. For example, a webhook receiver might:

  • Look up the affected service in an internal CMDB and attach ownership information.
  • Fetch recent deployment history or change requests for the affected component.
  • Create a ticket in a service desk with a pre-filled description.
  • Trigger an automated runbook or diagnostic script.

Webhooks are not limited to Alertmanager’s native fields; they can receive the full alert payload and transform it or augment it before delivering to a human or another system.

Key Differences: Labels vs Webhooks

AspectNative LabelsWebhooks
PurposeDefine identity, routing, groupingDeliver alert data to external systems
Context typeStructured, queryable, used by AlertmanagerExternal enrichment, arbitrary payload
ConfigurationIn Prometheus rule filesIn Alertmanager config file
FlexibilityLimited to key-value pairsCan include any JSON data, can be processed
ConsumersAlertmanager itself, receiversExternal services, custom logic

Labels are the backbone of alert context within the Prometheus ecosystem. Webhooks are the bridge to the outside world, where context can be enriched and acted upon.

How to Choose: When to Use Which

Use native labels for any context that Alertmanager needs to make routing decisions or that should be visible in every notification. Common examples:

  • severity to determine if a page is warranted.
  • team to route to the correct on-call group.
  • service to identify the affected component.
  • region to indicate geographic scope.

Use webhooks when you need to:

  • Integrate with a custom incident management platform.
  • Enrich alerts with data from external APIs (e.g., deployment info, log links).
  • Perform automated actions like opening a ticket or triggering a runbook.
  • Transform the alert payload into a format specific to a downstream system.

In practice, you often use both: labels for routing and basic context, and webhooks for deeper integration with tools that need more than what labels can convey.

Common Problems and Misconceptions

One common misconception is that webhooks replace labels. They do not; webhooks receive the labels as part of the payload, and labels are still essential for Alertmanager’s internal logic. Another issue is overloading labels with too much information. Labels are indexed and used for grouping, so too many unique label values can cause excessive alerts and poor performance. Annotations are a better place for human-readable details like a description or a runbook URL, because they are not used for routing or identity.

Another problem is assuming webhooks are only for outgoing notifications. Webhooks can also be used to receive alerts from external systems, but that is a different feature. In Alertmanager, webhooks are strictly outbound.

Costs and Trade-offs

Labels are free in terms of external dependencies, but they add cardinality to Prometheus’ internal storage, which can increase memory usage. Use labels sparingly and avoid high-cardinality values like request IDs. Webhooks introduce network latency, external service dependencies, and potential failure points. If the webhook endpoint is down, alerts may be delayed or lost unless you configure retries and fallbacks. Also, webhooks require you to build and maintain the receiving service, which is more work than simply configuring a label.

Safety and Best Practices

When sending webhooks, ensure the endpoint is secure (HTTPS) and that you validate incoming requests if the endpoint is public. Avoid sending sensitive information in labels or annotations, as they may be transmitted to multiple receivers. Use annotations for human-readable context, and keep labels minimal. Test your routing rules with amtool or the Alertmanager UI to ensure alerts land where they should.

Frequently Asked Questions

Can webhooks add labels to alerts?

No, webhooks cannot modify the alert’s labels. They only receive the alert data. To add labels, you must do so in the Prometheus rule definition or via Alertmanager’s mutate feature (if available in newer versions).

Do labels affect alert deduplication?

Yes. Alertmanager groups alerts by their label set (excluding some like instance if configured). If labels change, the alert is considered new. Keep labels stable across occurrences of the same issue.

What is the difference between labels and annotations?

Labels are used for routing, grouping, and identity. Annotations are for human-readable context like descriptions and links. Annotations are not used for routing or grouping.

Can I use a webhook to send alerts to multiple systems?

Yes, you can define multiple webhook receivers in Alertmanager and route to them via different routes. Each webhook will receive the same alert payload.

Is it better to put a runbook URL in a label or annotation?

Put it in an annotation. Annotations are designed for display and do not affect routing or grouping. Labels should be reserved for structured data that Alertmanager uses for logic.

In summary, labels are the core context mechanism within Alertmanager, while webhooks extend that context to external systems. Use labels for routing and identity, and webhooks for integration and enrichment.

In this article
  1. Background: Why Context Matters in Alerting
  2. How Native Alert Labels Work
  3. How Webhooks Add Context
  4. Key Differences: Labels vs Webhooks
  5. How to Choose: When to Use Which
  6. Common Problems and Misconceptions
  7. Costs and Trade-offs
  8. Safety and Best Practices
  9. Frequently Asked Questions