Skip to content

Export logs-collector and pings-collector metrics to Prometheus - #80

Merged
define-null merged 6 commits into
mainfrom
logs-collector-metrics
Sep 24, 2026
Merged

define-null merged 6 commits into
mainfrom
logs-collector-metrics

Conversation

@define-null

@define-null define-null commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds Prometheus metrics to logs-collector and pings-collector, served at /metrics on PROMETHEUS_PORT (default 9090). Every series carries the instance's shard. Known label values are created at startup, so rates read 0 instead of no data.

Metrics

Both collectors (logs_collector_*, pings_collector_*):

  • shard_info{total_shards}, workers
  • requests_total{result,reason}, request_duration_seconds{result}, round_duration_seconds
  • storage_errors_total (with operation="read"|"insert" in logs-collector)

logs-collector:

  • log_lag_seconds: collector minus worker timestamp, per stored row. Share collected too late for rewards: 1 - rate(..._bucket{le="1200.0"}) / rate(..._count)
  • buffer_bytes, buffer_max_bytes, backlogged_workers
  • logs_stored_total, logs_discarded_total{reason} (lost), logs_deferred_total (buffer full, collected again later)

pings-collector:

  • heartbeats_stored_total, heartbeats_discarded_total{reason}

Notes

  • The transport doesn't export its error types, so reason is taken from the variant name at the start of the error's Debug form, or other if it isn't recognised.
  • Bumps logs-collector to 2.4.0 and pings-collector to 2.9.0.
  • Scraping needs a metrics container port and a PodMonitor per collector in the infra chart.

🤖 Generated with Claude Code

@define-null define-null changed the title Export logs-collector metrics to Prometheus Export logs-collector and pings-collector metrics to Prometheus Sep 24, 2026
define-null and others added 5 commits September 24, 2026 12:43
Serve /metrics on PROMETHEUS_PORT (default 9090) with the essential
collection metrics: workers and backlogged workers, log requests by
result, logs stored, logs dropped by reason, and storage errors.
Every series carries the instance's shard label.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Serve /metrics on PROMETHEUS_PORT (default 9090) with the metrics that
correspond to logs-collector's: workers, heartbeat requests by result,
heartbeats stored, heartbeats dropped by reason, and storage errors,
each with the instance's shard label. Move the /metrics server into
collector-utils so both collectors share it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Encoding into a String can't fail, so expect it instead of mapping the
error to a 500. Keep collector-utils' dependencies sorted, and start
pings-collector's metrics server right before the server, as in
logs-collector.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add the metrics the review asked for: log lag per stored row (with a
bucket at the 1200 s reward cutoff), buffer fill and limit, round and
request durations, and shard_info with total_shards.

Fix the existing ones: split logs_dropped into logs_discarded{reason}
(lost) and logs_deferred (collected again later), label request errors
with a fixed reason taken from the transport error's variant, label
storage errors with the operation, and create every known series up
front so rates read 0 instead of no data. Rename pings' heartbeats_dropped
to heartbeats_discarded to match.

The transport doesn't export FetchLogsError or RequestError, so the
reason is read from the start of the error's Debug form.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@define-null
define-null force-pushed the logs-collector-metrics branch from a9095d0 to 1247a2f Compare September 24, 2026 10:45
Move workers, requests, request and round durations, shard_info and the
error reason lookup into collector_utils::CollectorMetrics, tested once
there. observe_request wraps the request future, so call sites keep
their original match arms.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@define-null
define-null merged commit 0ef2ca0 into main Sep 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant