Skip to main content
Four monitors that turn a working Datadog drain into pages. They are built on the field names in the event schema, so they keep working as new sources are added. Before you begin
  • A datadog drain in state healthy. Confirm with lua drains status.
  • A Datadog API key and an application key, if you import over the API.
  • Three log facets created once, from any record: @lua.eventName, @lua.attributes.lua.source, and @lua.attributes.gen_ai.tool.name. Open one Lua record in Log Explorer, expand lua, and choose Create facet on each. Grouping and alerting need them; plain search does not.

What you get

Install the heartbeat monitor first. It is the one that makes the other three trustworthy: they all alert on the presence of something, so their silence is only meaningful while the pipeline is known to be up.

Import it

One monitor at a time: Monitors → New Monitor → Import Monitor from JSON, paste a single object from the monitors array, then Save. Repeat for the other three.Add your notification handles to each monitor’s message before saving — the pack ships with none, so an imported monitor alerts in the UI and pages nobody.

The pack

lua-datadog-monitors.json

Tune it

  • Notification handles. Append @slack-your-channel, @pagerduty-your-service, or @[email protected] to each message. Nothing in the pack notifies anyone as shipped.
  • Thresholds. “More than 5 errors in 5 minutes” is a starting point, not a measurement of your traffic. Run the query in Log Explorer over the last week and set the threshold above your normal peak.
  • Grouping. The error and truncation monitors group by("service,env"), where service is the agent’s name and env comes from the drain’s env: tag — so production and sandbox alert separately, per agent. Group by agent instead to key on the agent id.
  • Selecting errors. @lua.eventName:lua.*.error matches every source’s error records. @lua.severityText:ERROR selects exactly the same set and needs no wildcard, if you would rather not rely on one.
  • Multi-alert noise. new_group_delay: 60 stops a newly created agent alerting on its first minute. Raise it if you create agents in bursts.
  • The heartbeat monitor alerts twice on purpose. It carries both a < 1 threshold and notify_no_data, so it fires whether your index reports a zero count or reports nothing at all. For the one alert every other alert depends on, a duplicate page is better than a missed one. Drop notify_no_data once you have seen it fire correctly in your own organization.

Why these queries

The Datadog encoder puts the whole record under a lua key, so every schema field is addressable as an attribute: @lua.eventName, @lua.severityText, @lua.attributes.<name>. That makes eventName the natural selector here. The Grafana pack selects differently — on attributes such as lua_drain_backlog rather than on the event name — because Loki’s OTLP ingestion indexes attributes rather than the OTLP eventName field. The two packs watch the same four signals; only the way they address them differs.

Next steps

Datadog

Create the drain these monitors watch.

Delivery guarantees

What the heartbeat and the drop record mean.

Event schema

Every field these queries address.

Grafana dashboard

The same signals, over Loki.