Skip to content

Metrics Sink

The metrics sink writes telemetry frames from gateways into Elasticsearch using the bulk API. It's the final step in the ingestion pipeline - after metric data arrives via Service Bus and gets mapped to domain models, the sink persists it to a time-series data stream.

How It Works

  1. Gateway sends a telemetry frame containing metric values
  2. Platform maps the DTO to a domain model via TelemetryFrameMapper
  3. Empty frames (no metric values) are filtered out
  4. Remaining frames are bulk-indexed into the configured data stream

The sink batches writes automatically. Even single-frame calls go through the bulk path for consistency.

Configuration

Index naming follows the pattern {type}-{dataset}-{namespace}:

json
{
  "Elasticsearch": {
    "IndexType": "iot-metrics",
    "Dataset": "voltimax-gateway",
    "Namespace": "prod"
  }
}

This produces an index name like iot-metrics-voltimax-gateway-prod.

Performance

  • Bulk indexing warns if a batch takes longer than 5 seconds
  • Each batch response reports success and error counts separately
  • Empty frames are skipped before reaching Elasticsearch

Error Handling

Failed bulk operations throw ElasticsearchIndexException. Individual item failures within a batch are logged with:

  • Error type and reason
  • HTTP status code
  • Index name and duration
  • Root cause analysis (at trace level)
  • Index Migrator - sets up the index template and lifecycle policy that the sink writes to
  • Logs Query - querying gateway logs from Elasticsearch
  • Data Model - metric domains and key format