A Python package to send data using Prometheus remote write protocol.
Project description
Prometheus Remote Writer
Introduction
prometheus-remote-writer is a Python library designed to simplify the process of writing data to a database using
the Prometheus Remote Write
protocol. This library is platform-independent and aims to provide developers with an intuitive way to send time-series
data to Prometheus-compatible storage.
Key Features
- Easily write data to Prometheus-compatible storage backends.
- Supports custom HTTP headers and authentication methods.
- Provides a simple and easy-to-use API.
- Supports batch data sending to improve transmission efficiency.
Installation
Before using prometheus-remote-writer, ensure that Python 3.8 or higher is installed on your system.
pip install prometheus-remote-writer
Quick Start
Here's a simple example of how to use prometheus-remote-writer in your project:
from prometheus_remote_writer import RemoteWriter
# Create a RemoteWriter instance
writer = RemoteWriter(
url='https://your-prometheus-server/api/v1/write',
headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
)
# Prepare the data to send
data = [
{
'metric': {'__name__': 'cpu_usage', 'host': 'server1'},
'values': [23.5, 24.1, 22.8],
'timestamps': [1609459200000, 1609459260000, 1609459320000]
}
]
# Send the data
writer.send(data)
Configuration
RemoteWriter supports the following configuration parameters:
url (required): The URL of the Prometheus remote write endpoint.
headers (optional): Custom HTTP headers for authentication or other purposes.
timeout (optional): Request timeout in seconds, default is 10 seconds.
Unit Testing
This project uses pytest for unit testing. To run the tests, execute the following command:
pytest
Contribution Guide
We welcome contributions from the community! To contribute to prometheus-remote-writer, please follow these steps:
Fork the repository.
Create your feature branch (git checkout -b feature/YourFeature).
Commit your changes (git commit -m 'Add some feature').
Push to the branch (git push origin feature/YourFeature).
Open a pull request.
FAQ
Why can't I connect to the Prometheus server?
Ensure your network connection is active and the url is correct. You may also need to configure firewall rules to
allow traffic.
How do I report a bug?
Please file a bug report on the GitHub issues page with detailed information and steps to reproduce the issue.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Contact
If you have any questions or suggestions, feel free to contact us at xy.kong@gmail.com.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prometheus_remote_writer-0.0.12.tar.gz.
File metadata
- Download URL: prometheus_remote_writer-0.0.12.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2e4e6cbc2a74526b14a5b775f57bea96639babaceaf3e524611b438206bc1fb
|
|
| MD5 |
c1307dd4baaa6255334e9d21c7b8d489
|
|
| BLAKE2b-256 |
d3772247667edb86c3093bbd5423d0755ced95964797943c1708c36aa00a157e
|
Provenance
The following attestation bundles were made for prometheus_remote_writer-0.0.12.tar.gz:
Publisher:
python-publish.yml on xykong/prometheus-remote-writer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prometheus_remote_writer-0.0.12.tar.gz -
Subject digest:
d2e4e6cbc2a74526b14a5b775f57bea96639babaceaf3e524611b438206bc1fb - Sigstore transparency entry: 170175363
- Sigstore integration time:
-
Permalink:
xykong/prometheus-remote-writer@f6bfa9924c23133b51f215ee5709ffc147f547c1 -
Branch / Tag:
refs/tags/v0.0.12 - Owner: https://github.com/xykong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f6bfa9924c23133b51f215ee5709ffc147f547c1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file prometheus_remote_writer-0.0.12-py3-none-any.whl.
File metadata
- Download URL: prometheus_remote_writer-0.0.12-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db8ad5e7dba7338cfa4d4ddc90d709262bbf670e25225f50a5fea5dc3b6a2be6
|
|
| MD5 |
9151e8708c30c216e3496a8102ae26d4
|
|
| BLAKE2b-256 |
9197a955da628d386d1698ab5164786e049fbcad18ab05fe9ee32dbb444d79ae
|
Provenance
The following attestation bundles were made for prometheus_remote_writer-0.0.12-py3-none-any.whl:
Publisher:
python-publish.yml on xykong/prometheus-remote-writer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prometheus_remote_writer-0.0.12-py3-none-any.whl -
Subject digest:
db8ad5e7dba7338cfa4d4ddc90d709262bbf670e25225f50a5fea5dc3b6a2be6 - Sigstore transparency entry: 170175364
- Sigstore integration time:
-
Permalink:
xykong/prometheus-remote-writer@f6bfa9924c23133b51f215ee5709ffc147f547c1 -
Branch / Tag:
refs/tags/v0.0.12 - Owner: https://github.com/xykong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f6bfa9924c23133b51f215ee5709ffc147f547c1 -
Trigger Event:
push
-
Statement type: