How max-bytes/metrics-receiver works
metrics-receiver is a Go HTTP service that accepts Influx line-protocol writes and forwards processed metrics to configured TimescaleDB and InfluxDB outputs. The main runtime workflow parses and groups points, applies per-output filtering and measurement rules, optionally enriches tags from a cached Omnikeeper query, then dispatches writes. It also exposes health and enrichment-cache endpoints and can emit internal metrics. The README documents the status and cache APIs; source excerpts establish the write and enrichment paths, while some handler and orchestration lines are omitted.
Main entry points: main.go HTTP Service · processMeasurementPoints.go Filter and Prepare · omnikeeper.go Enrichment Fetch · write.go Timescale Writer
Components 17
Ingestion
- HTTP Service
cmd/metrics-receiver/main.go - Line Parser
pkg/influx/InfluxLineProtocolParser.go - Health Check
cmd/metrics-receiver/main.go - Cache Info API
cmd/metrics-receiver/main.go - Internal Metrics
cmd/metrics-receiver/main.go
Metric Processing
- Runtime Config
pkg/config/config.go - Measurement Grouping
pkg/general/splitPointsByMeasurement.go - Filter and Prepare
pkg/general/processMeasurementPoints.go
Enrichment
- Enrichment Fetch
pkg/enrichments/omnikeeper.go - Enrichment Cache
pkg/enrichments/omnikeeper.go
Storage Outputs
- Output Dispatch
cmd/metrics-receiver/main.go - Timescale Writer
pkg/timescale/write.go - TimescaleDB
- Influx Writer
pkg/influx/write.go - InfluxDB
Other components
- Metric Sender
- Omnikeeper API
Connections 20
- Metric Sender → HTTP Service: sends writes
- HTTP Service → Line Parser: parses body
- HTTP Service → Measurement Grouping: groups points
- HTTP Service → Runtime Config: loads config
- HTTP Service → Filter and Prepare: prepares outputs
- Filter and Prepare → Runtime Config: reads rules
- Filter and Prepare → Enrichment Cache: looks up tags
- HTTP Service → Output Dispatch: dispatches writes
- Output Dispatch → Timescale Writer: writes points
- Output Dispatch → Influx Writer: writes points
- Timescale Writer → TimescaleDB: inserts rows
- Influx Writer → InfluxDB: writes points
- HTTP Service → Enrichment Fetch: starts refresh
- Enrichment Fetch → Omnikeeper API: queries traits
- Enrichment Fetch → Enrichment Cache: updates cache
- HTTP Service → Health Check: serves check
- HTTP Service → Cache Info API: serves cache info
- Cache Info API → Enrichment Cache: reads cache
- HTTP Service → Internal Metrics: collects counters
- Internal Metrics → Output Dispatch: flushes metrics