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
- Gateway sends a telemetry frame containing metric values
- Platform maps the DTO to a domain model via
TelemetryFrameMapper - Empty frames (no metric values) are filtered out
- 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)
Related Documentation
- 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