Prometheus Remote Write and Remote Read mechanisms:
Remote Write: Send data from Prometheus to remote storage systems.
Configuration Example:
yamlremote_write: - url: "http://remote-storage:9201/api/v1/write" basic_auth: username: "user" password: "pass" queue_config: capacity: 10000 max_shards: 50 min_shards: 1 max_samples_per_send: 1000 batch_send_deadline: 5s min_backoff: 30ms max_backoff: 100ms write_relabel_configs: - source_labels: [__name__] regex: 'expensive_.*' action: drop
Use Cases:
- Long-term data storage
- Cross-cluster data aggregation
- Data analysis and reporting
- Backup and disaster recovery
Remote Read: Read data from remote storage systems.
Configuration Example:
yamlremote_read: - url: "http://remote-storage:9201/api/v1/read" read_recent: true basic_auth: username: "user" password: "pass"
Use Cases:
- Query historical data
- Cross-datasource queries
- Data analysis
Supported Remote Storage:
- Thanos
- Cortex
- VictoriaMetrics
- InfluxDB
- M3DB
- TimescaleDB
Queue Configuration Parameters:
capacity: Queue capacitymax_shards: Maximum number of shardsmin_shards: Minimum number of shardsmax_samples_per_send: Maximum samples per sendbatch_send_deadline: Batch send timeoutmin_backoff/max_backoff: Backoff time
Best Practices:
- Use
write_relabel_configsto filter unnecessary data - Configure queue parameters reasonably to avoid memory overflow
- Monitor Remote Write performance metrics
- Use
read_recent: trueto improve query performance - Consider data compression to reduce network transmission
Monitoring Metrics:
prometheus_remote_storage_queue_lengthprometheus_remote_storage_failed_samples_totalprometheus_remote_storage_succeeded_samples_total