{"library":"prometheus-remote-writer","title":"Prometheus Remote Writer","description":"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.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install prometheus-remote-writer"],"cli":null},"imports":["from prometheus_remote_writer import RemoteWriter"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport time\nfrom prometheus_remote_writer import RemoteWriter\n\n# Configure the remote write endpoint URL\nREMOTE_WRITE_URL = os.environ.get('PROMETHEUS_REMOTE_WRITE_URL', 'https://example.com/prometheus/api/v1/write')\n# Configure authentication (e.g., Bearer token)\nAUTH_TOKEN = os.environ.get('PROMETHEUS_REMOTE_WRITE_TOKEN', 'YOUR_STATIC_TOKEN_HERE')\n\n# Create a RemoteWriter instance\nwriter = RemoteWriter(\n    url=REMOTE_WRITE_URL,\n    headers={'Authorization': f'Bearer {AUTH_TOKEN}'}\n)\n\n# Prepare some sample data to send\n# Prometheus Remote Write expects timestamps in milliseconds\ncurrent_time_ms = int(time.time() * 1000)\n\ndata_points = [\n    {\n        'metric': {'__name__': 'my_app_cpu_usage_total', 'host': 'server1', 'region': 'us-east-1'},\n        'values': [9.5],\n        'timestamps': [current_time_ms]\n    },\n    {\n        'metric': {'__name__': 'my_app_memory_utilization_bytes', 'host': 'server1', 'region': 'us-east-1'},\n        'values': [1024 * 1024 * 500],\n        'timestamps': [current_time_ms]\n    }\n]\n\ntry:\n    # Send the data\n    writer.send(data_points)\n    print(f\"Successfully sent {len(data_points)} data points to {REMOTE_WRITE_URL}\")\nexcept Exception as e:\n    print(f\"Failed to send data: {e}\")","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"1.1.3","pypi_latest":"1.1.3","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":5,"avg_import_s":0.77,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.75,"mem_mb":13.2,"disk_size":"58.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.6,"import_time_s":0.41,"mem_mb":11.9,"disk_size":"53M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.23,"mem_mb":14.5,"disk_size":"61.0M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.6,"import_time_s":0.7,"mem_mb":13.8,"disk_size":"56M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.13,"mem_mb":14.3,"disk_size":"61.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.1,"import_time_s":0.7,"mem_mb":13.7,"disk_size":"57M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1,"mem_mb":14.7,"disk_size":"61.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.4,"import_time_s":0.67,"mem_mb":14.1,"disk_size":"56M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.63,"mem_mb":12.9,"disk_size":"57.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"prometheus-remote-writer","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":6.4,"import_time_s":0.49,"mem_mb":11.5,"disk_size":"53M"}]}}