The `prometheus-remote-writer` is a Python library (version 1.1.3) designed to simplify the process of sending time-series data to Prometheus-compatible storage using the Prometheus Remote Write protocol. It offers a platform-independent, intuitive API, supporting custom HTTP headers, various authentication methods, and efficient batch data sending. The library is actively maintained with regular updates.
pip install prometheus-remote-writerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `RemoteWriter` with a target URL and an authorization header, then construct and send a list of time-series data points. Timestamps should be in milliseconds. Ensure `PROMETHEUS_REMOTE_WRITE_URL` and `PROMETHEUS_REMOTE_WRITE_TOKEN` environment variables are set or replace the placeholder values.
Monitor official documentation for `prometheus-remote-writer` for v2.0 support. If interacting with a v2.0-only endpoint, ensure the library version supports it or configure it explicitly if options become available.
Implement client-side rate limiting or backoff mechanisms, or ensure your remote storage backend has sufficient capacity and robust handling for spikes. Monitor your remote write queue metrics on the Prometheus server or client side to detect dropped samples.
Monitor the health and memory usage of the application sending metrics. Ensure the remote storage is healthy and responsive. If possible, configure queue capacity and timeout parameters in your client or Prometheus configuration to prevent excessive buffering.
Verify the `url` and `headers` (especially authentication tokens) provided to the `RemoteWriter` instance. Check network connectivity from the client to the remote endpoint. Ensure the remote endpoint (e.g., Mimir, Thanos, Grafana Cloud) is operational and accessible.
Reduce the volume or rate of metrics being sent. Review and adjust the ingestion limits on your remote storage solution. Consider aggregating metrics or applying `write_relabel_configs` on the Prometheus server (if applicable) to drop high-cardinality or less critical metrics.
Double-check the `url` in `RemoteWriter` to ensure the hostname and port are correct. Verify that the remote write endpoint service is running and accessible on the specified port. Check any firewalls or network security groups that might be preventing the connection.
Review the authentication configuration for your remote storage and ensure the exact credentials are being passed correctly in the `RemoteWriter`'s `headers` or `auth` parameters. Pay attention to case sensitivity and token expiration.
No dependency data recorded yet.