Skip to Content

How do I tie CloudWatch alarms to the right service?

Tares ties CloudWatch alarms to a service through labels on a webhook source: you map one field of the alarm event to the primary label that your metrics and logs sources also carry. Alarms then land on the same per-service timeline as that evidence. CloudWatch reaches Tares through the webhook connector and an EventBridge setup, because Tares has no connector of its own for CloudWatch today. The field you usually map is detail.alarmName.

How it works

Tares builds one timeline per entity, and the primary label picks the entity. If your metrics source, your logs source and your alarm source all carry a primary label with the same name and the same values, their events merge on one clock. This is the pattern in Build an AI SRE, where every source is keyed by the same service label.

For CloudWatch the path is:

  • An EventBridge rule on the default event bus matches source aws.cloudwatch and detail-type CloudWatch Alarm State Change.
  • The rule’s target is an API destination that POSTs the event as a JSON body to your Tares ingest URL.
  • A webhook source stores the payload lossless and reads your declared labels from it.

Which payload fields can be labels:

  • source, detail-type and region are top-level fields.
  • detail.alarmName is one level deep, so it works directly as a dotted label field.
  • detail.state.value is two levels deep. Flatten it with an input transformer on the rule target if you want it as a label or in text_template.

The label value has to match what the metrics and logs carry. If your alarm names are the service names, map detail.alarmName directly. If they are not, use an input transformer on the rule target to send a flat field that holds the service name, and map that field instead. Labels also support the keys pattern, replace and map for reshaping a value.

Alarm actions that publish to SNS do not fit this route. An SNS HTTPS subscription cannot send a custom header, and its SubscriptionConfirmation message would never be confirmed.

Set it up

  1. In Tares, add a webhook source (Sources → Add source → webhook) with a primary label named like the one your metrics and logs use. This example assumes that label is service, and that the alarm name identifies the service:
- name: cloudwatch-alarms connector: webhook config: event_type_field: detail-type labels: - { name: service, field: detail.alarmName, primary: true } - { name: region, field: region }
  1. Save the source and copy its ingest endpoint from the source page. It has the form /ingest/<ingest_key>.
  2. In EventBridge, create an API destination whose endpoint is that Tares ingest URL and whose method is POST. The endpoint must be public HTTPS, so a local http://127.0.0.1:8787 address does not work for this route.
  3. Give the API destination a connection, which EventBridge requires. Use API key authorization with header name Authorization and the value Bearer followed by an ingest-scoped API key. The key value only matters when Tares has auth on.
  4. Create a rule on the default event bus that matches source aws.cloudwatch and detail-type CloudWatch Alarm State Change, and set the API destination as its target. Add an input transformer on the target if you need detail.state.value or a service field flattened.
  5. Check the mapping by posting a sample payload to the ingest URL, then open the source page. Recent events shows what arrived. Fields shows which payload fields arrive and how often, so you can confirm the field behind your primary label is reliably present.
curl -X POST http://localhost:8787/ingest/<ingest_key> \ -H 'Content-Type: application/json' \ -d '{"detail-type": "CloudWatch Alarm State Change", "source": "aws.cloudwatch", "region": "eu-west-1", "detail": {"alarmName": "checkout-high-5xx"}}'
  1. Open the same entity in Explore. Alarm events appear on the timeline next to the metrics and logs that carry the same primary label value.

What you get

  • Alarm state changes sit on the same per-service timeline as your metrics and logs, so an agent or a person reads one correlated view instead of three.
  • Triggers keyed by the primary label fire per service, so an alarm wakes the investigation for the service it belongs to.
  • The full EventBridge payload is stored lossless, so fields you did not map are still there.
  • Fields on the source page shows which payload fields arrive, which helps you pick a reliable key.

When something else fits

  • If your alarm names do not map cleanly to services, flatten a service field with an input transformer first, or choose another top-level or one-level field as the primary label.
  • If you want CloudWatch data other than alarm state changes, such as metrics or logs, use OTLP or the webhook connector with an EventBridge rule, or use http_poll against an API.

Still stuck? Get help

Last updated on