Proposal: Last Seen Connector for detecting stale OTLP clients #49582
|
Problem We're using the following architecture: OTel Agents (VMs) Each VM continuously exports metrics through the gateway. One of our operational requirements is to detect when an agent stops sending telemetry and keep that condition visible until the agent starts sending data again. Today we're alerting using metrics such as: time() - max by (host_name)timestamp(otelcol_process_uptime_seconds_total) The issue is that when an agent stops sending telemetry, Prometheus eventually marks the time series as stale. Once the series disappears, Grafana resolves the alert because there is no longer a series to evaluate. This makes it difficult to: Keep incidents open until the agent actually recovers Question Is there a recommended OpenTelemetry Collector pattern for solving this problem? I'm trying to understand whether there is already a recommended solution before building something custom. Thanks! |
Replies: 2 comments
|
I would model this at the monitoring/inventory layer rather than as a Collector connector. With push telemetry, Prometheus can only alert on label sets that still exist. Once the final sample becomes stale, neither Grafana nor an Then alert on expected agents that have produced no heartbeat in the lookback window: Use a stable
A “last seen” connector would have to emit on a timer even when no telemetry arrives, persist identities across restarts, define expiry/removal semantics, and deduplicate state in an HA gateway deployment. That is effectively an inventory/state service, which is why keeping expected membership outside the telemetry stream is usually more reliable. |
|
The existing reply covers the Prometheus-layer approach well, but there are several native Collector-side options worth knowing about before building anything custom. Option 1 The simplest Collector-side solution is to use the This doesn't solve the stale series problem on its own because once the agent goes silent, Prometheus still stalens the series. But combined with a generous Option 2 count connector as a presence signal The This gives you a Option 3 The correct long-term solution (inventory-join in Prometheus) The existing reply is right about this being the most reliable approach. The key insight is that the Collector is the wrong place to track presence because it only knows about agents that are currently talking to it. An inventory source (cloud provider metadata, Ansible inventory, Terraform state, a simple ConfigMap) is the authoritative list of The recommended pattern: Expose Why a "Last Seen Connector" is complex to build correctly If you do go the custom connector route, the main challenges are:
These are the reasons the inventory-join approach wins operationally. The connector would essentially be reimplementing a lightweight inventory service inside the Collector. |
The existing reply covers the Prometheus-layer approach well, but there are several native Collector-side options worth knowing about before building anything custom.
Option 1
transformprocessor to emit a heartbeat gaugeThe simplest Collector-side solution is to use the
transformprocessor to add alast_seen_timestampmetric on every batch that passes through. This keeps the series alive as long as the agent is sending:This doesn't solve the stale series problem on its own because once the a…