Name | py-exporter-template JSON |
Version |
0.0.0.dev0
JSON |
| download |
home_page | None |
Summary | Add your description here |
upload_time | 2024-10-24 20:09:02 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | # MIT License Copyright (c) 2024 Pavel Sapezhka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
exporter
monitoring
prometheus
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pyexporter
Template for a Prometheus exporter for various metrics.
- Create a repo from this template
- Change name of the package, Docker image, docs, examples, etc.
- Implement your own collectors
- Enjoy!
## Installation
The exporter is written in Python. The simplest way to run it is to use the Docker image.
```shell
docker run -d -p 9123:9123 weastur/py-exporter:latest
```
Additionally, as it's a standard Python package, you can install it with `pip` or `pipx`:
```shell
pip install py-exporter-template
```
An isolated installation using a virtual environment can be found in the [examples](https://github.com/weastur/pyexporter/blob/main/examples/ansible/roles/py-exporter/tasks/main.yml).
## Usage
### Configuring
There are several ways to configure the exporter (in a priority order):
- Defaults
- Command line arguments
- Environment variables
- `.env` file in the current directory
- Configuration file (`config.yaml` or `config.yml`) in the current directory
#### Defaults and command line arguments
The exporter can be run with or without arguments (using defaults). See the full list of parameters with defaults
[below](#full-list-of-command-line-arguments).
#### Environment variables
All parameters can be set with environment variables. The environment variables should be in the following format:
`PY_EXPORTER_<PARAMETER_PATH>` using `__` as a nested delimeter
(replacing `.` in command line arguments)
For example:
```shell
export PY_EXPORTER_LOG__LEVEL=debug
export PY_EXPORTER_COLLECTOR__DEFAULT__GC=false
```
#### `.env` file
The `.env` file should be in the current directory and follow this format:
```shell
PY_EXPORTER_LOG__LEVEL=debug
PY_EXPORTER_COLLECTOR__DEFAULT__GC=false
```
#### Configuration file
The configuration file should be in the current directory and follow this format:
```yaml
log:
level: debug
web:
port: 9123
addr: "0.0.0.0"
```
See the full example [here](https://github.com/weastur/pyexporter/blob/main/examples/config.yml).
P. S. By the way, you can dump json schema for the configuration file with the following command:
```shell
py-exporter jsonschema config.schema.json
```
### [Full list of command line arguments](#full-list-of-command-line-arguments)
```shell
usage: py-exporter [-h]
[--log.level {trace,debug,info,success,warning,error,critical}]
[--web.port int] [--web.addr IPv4Address]
[--web.tls.cert Path] [--web.tls.key Path]
[--web.tls.protocol int]
[--web.tls.mtls.enabled | --no-web.tls.mtls.enabled]
[--web.tls.mtls.cafile Path] [--web.tls.mtls.capath Path]
[--collector.disable_created_series | --no-collector.disable_created_series]
[--collector.default.gc | --no-collector.default.gc]
[--collector.default.platform | --no-collector.default.platform]
[--collector.default.process | --no-collector.default.process]
{jsonschema} ...
optional arguments:
-h, --help show this help message and exit
subcommands:
{jsonschema}
jsonschema Dump the JSON schema to a file.
log options:
--log.level {trace,debug,info,success,warning,error,critical}
Log level (default: info)
web options:
--web.port int Port to listen on (default: 9123)
--web.addr IPv4Address
Address to listen on (default: 0.0.0.0)
web.tls options:
--web.tls.cert Path Path to the TLS certificate (default: None)
--web.tls.key Path Path to the TLS key (default: None)
--web.tls.protocol int
TLS protocol number, as described in the ssl python
module (default: 17)
web.tls.mtls options:
--web.tls.mtls.enabled, --no-web.tls.mtls.enabled
Enable mTLS (default: False)
--web.tls.mtls.cafile Path
Path to the client CA file (default: None)
--web.tls.mtls.capath Path
Path to the client CA directory (default: None)
collector options:
--collector.disable_created_series, --no-collector.disable_created_series
Disable created series (default: False)
collector.default options:
--collector.default.gc, --no-collector.default.gc
Enable the GC collector (default: True)
--collector.default.platform, --no-collector.default.platform
Enable the platform collector (default: True)
--collector.default.process, --no-collector.default.process
Enable the process collector (default: True)
```
## Examples
In the [examples](https://github.com/weastur/pyexporter/tree/main/examples/) you can find some useful files to look at:
- Docker Compose file example
- Prometheus coinfig to scrape the exporter
- Grafana dashboard
- VRL program for Vector
- SystemD service file for running the exporter outside the container
- Ansible playbook to deploy it in an isolated environment outside the container
- Full [dump](https://github.com/weastur/pyexporter/blob/main/examples/metrics.txt) (one scrape) of all metrics exporter can generate.
You can investigate it with [prom2json](https://github.com/prometheus/prom2json)
## Contributing
- Read the [contribution guide](https://github.com/weastur/pyexporter/blob/main/CONTRIBUTING.md)
- Don't forget to take a quick look at [code of conduct](https://github.com/weastur/pyexporter/blob/main/CODE_OF_CONDUCT.md)
## Credits
Although the license doesn’t require credits, I maintain a list of authors in the [CREDITS](https://github.com/weastur/pyexporter/blob/main/CREDITS.md)
file in the alphabetical order.
## License
MIT, see [LICENSE](https://github.com/weastur/pyexporter/blob/main/LICENSE.md)
Raw data
{
"_id": null,
"home_page": null,
"name": "py-exporter-template",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "exporter, monitoring, prometheus",
"author": null,
"author_email": "Pavel Sapezhka <me@weastur.com>",
"download_url": "https://files.pythonhosted.org/packages/96/65/4622d7e56fb3c72a9468edb1c3ec40f2d5f4941fdf048f6bcd4e635a457f/py_exporter_template-0.0.0.dev0.tar.gz",
"platform": null,
"description": "# pyexporter\n\nTemplate for a Prometheus exporter for various metrics.\n\n- Create a repo from this template\n- Change name of the package, Docker image, docs, examples, etc.\n- Implement your own collectors\n- Enjoy!\n\n## Installation\n\nThe exporter is written in Python. The simplest way to run it is to use the Docker image.\n\n```shell\ndocker run -d -p 9123:9123 weastur/py-exporter:latest\n```\n\nAdditionally, as it's a standard Python package, you can install it with `pip` or `pipx`:\n\n```shell\npip install py-exporter-template\n```\n\nAn isolated installation using a virtual environment can be found in the [examples](https://github.com/weastur/pyexporter/blob/main/examples/ansible/roles/py-exporter/tasks/main.yml).\n\n## Usage\n\n### Configuring\n\nThere are several ways to configure the exporter (in a priority order):\n\n- Defaults\n- Command line arguments\n- Environment variables\n- `.env` file in the current directory\n- Configuration file (`config.yaml` or `config.yml`) in the current directory\n\n#### Defaults and command line arguments\n\nThe exporter can be run with or without arguments (using defaults). See the full list of parameters with defaults\n[below](#full-list-of-command-line-arguments).\n\n#### Environment variables\n\nAll parameters can be set with environment variables. The environment variables should be in the following format:\n`PY_EXPORTER_<PARAMETER_PATH>` using `__` as a nested delimeter\n(replacing `.` in command line arguments)\nFor example:\n\n```shell\nexport PY_EXPORTER_LOG__LEVEL=debug\nexport PY_EXPORTER_COLLECTOR__DEFAULT__GC=false\n```\n\n#### `.env` file\n\nThe `.env` file should be in the current directory and follow this format:\n\n```shell\nPY_EXPORTER_LOG__LEVEL=debug\nPY_EXPORTER_COLLECTOR__DEFAULT__GC=false\n```\n\n#### Configuration file\n\nThe configuration file should be in the current directory and follow this format:\n\n```yaml\nlog:\n level: debug\nweb:\n port: 9123\n addr: \"0.0.0.0\"\n```\n\nSee the full example [here](https://github.com/weastur/pyexporter/blob/main/examples/config.yml).\n\nP. S. By the way, you can dump json schema for the configuration file with the following command:\n\n```shell\npy-exporter jsonschema config.schema.json\n```\n\n### [Full list of command line arguments](#full-list-of-command-line-arguments)\n\n```shell\nusage: py-exporter [-h]\n [--log.level {trace,debug,info,success,warning,error,critical}]\n [--web.port int] [--web.addr IPv4Address]\n [--web.tls.cert Path] [--web.tls.key Path]\n [--web.tls.protocol int]\n [--web.tls.mtls.enabled | --no-web.tls.mtls.enabled]\n [--web.tls.mtls.cafile Path] [--web.tls.mtls.capath Path]\n [--collector.disable_created_series | --no-collector.disable_created_series]\n [--collector.default.gc | --no-collector.default.gc]\n [--collector.default.platform | --no-collector.default.platform]\n [--collector.default.process | --no-collector.default.process]\n {jsonschema} ...\n\noptional arguments:\n -h, --help show this help message and exit\n\nsubcommands:\n {jsonschema}\n jsonschema Dump the JSON schema to a file.\n\nlog options:\n --log.level {trace,debug,info,success,warning,error,critical}\n Log level (default: info)\n\nweb options:\n --web.port int Port to listen on (default: 9123)\n --web.addr IPv4Address\n Address to listen on (default: 0.0.0.0)\n\nweb.tls options:\n --web.tls.cert Path Path to the TLS certificate (default: None)\n --web.tls.key Path Path to the TLS key (default: None)\n --web.tls.protocol int\n TLS protocol number, as described in the ssl python\n module (default: 17)\n\nweb.tls.mtls options:\n --web.tls.mtls.enabled, --no-web.tls.mtls.enabled\n Enable mTLS (default: False)\n --web.tls.mtls.cafile Path\n Path to the client CA file (default: None)\n --web.tls.mtls.capath Path\n Path to the client CA directory (default: None)\n\ncollector options:\n --collector.disable_created_series, --no-collector.disable_created_series\n Disable created series (default: False)\n\ncollector.default options:\n --collector.default.gc, --no-collector.default.gc\n Enable the GC collector (default: True)\n --collector.default.platform, --no-collector.default.platform\n Enable the platform collector (default: True)\n --collector.default.process, --no-collector.default.process\n Enable the process collector (default: True)\n```\n\n## Examples\n\nIn the [examples](https://github.com/weastur/pyexporter/tree/main/examples/) you can find some useful files to look at:\n\n- Docker Compose file example\n- Prometheus coinfig to scrape the exporter\n- Grafana dashboard\n- VRL program for Vector\n- SystemD service file for running the exporter outside the container\n- Ansible playbook to deploy it in an isolated environment outside the container\n- Full [dump](https://github.com/weastur/pyexporter/blob/main/examples/metrics.txt) (one scrape) of all metrics exporter can generate.\n You can investigate it with [prom2json](https://github.com/prometheus/prom2json)\n\n## Contributing\n\n- Read the [contribution guide](https://github.com/weastur/pyexporter/blob/main/CONTRIBUTING.md)\n- Don't forget to take a quick look at [code of conduct](https://github.com/weastur/pyexporter/blob/main/CODE_OF_CONDUCT.md)\n\n## Credits\n\nAlthough the license doesn\u2019t require credits, I maintain a list of authors in the [CREDITS](https://github.com/weastur/pyexporter/blob/main/CREDITS.md)\nfile in the alphabetical order.\n\n## License\n\nMIT, see [LICENSE](https://github.com/weastur/pyexporter/blob/main/LICENSE.md)\n",
"bugtrack_url": null,
"license": "# MIT License Copyright (c) 2024 Pavel Sapezhka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Add your description here",
"version": "0.0.0.dev0",
"project_urls": {
"Changelog": "https://github.com/weastur/pyexporter/releases",
"Documentation": "https://pyexporter.weastur.com",
"Homepage": "https://pyexporter.weastur.com",
"Issues": "https://github.com/weastur/pyexporter/issues",
"Repository": "https://github.com/weastur/pyexporter.git"
},
"split_keywords": [
"exporter",
" monitoring",
" prometheus"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ebe8e5ab5647590fb25c48c79013c7f4b3542f0b2f80ab56167ee847427fdc58",
"md5": "cce534e5bac7d39f06ed32c2e830ab7f",
"sha256": "a224c5151412a5a400d32ff04bb19ee83e0ff23d0428670dea466f3940e3fe50"
},
"downloads": -1,
"filename": "py_exporter_template-0.0.0.dev0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cce534e5bac7d39f06ed32c2e830ab7f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 8516,
"upload_time": "2024-10-24T20:09:00",
"upload_time_iso_8601": "2024-10-24T20:09:00.936195Z",
"url": "https://files.pythonhosted.org/packages/eb/e8/e5ab5647590fb25c48c79013c7f4b3542f0b2f80ab56167ee847427fdc58/py_exporter_template-0.0.0.dev0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "96654622d7e56fb3c72a9468edb1c3ec40f2d5f4941fdf048f6bcd4e635a457f",
"md5": "8c5179578a0bd9851cdbaa52783dc5dc",
"sha256": "48e0642a3d50bd05398380f2dbb0a6cb2c60e5237bc91c6c14e25ffcda77647a"
},
"downloads": -1,
"filename": "py_exporter_template-0.0.0.dev0.tar.gz",
"has_sig": false,
"md5_digest": "8c5179578a0bd9851cdbaa52783dc5dc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 81594,
"upload_time": "2024-10-24T20:09:02",
"upload_time_iso_8601": "2024-10-24T20:09:02.501332Z",
"url": "https://files.pythonhosted.org/packages/96/65/4622d7e56fb3c72a9468edb1c3ec40f2d5f4941fdf048f6bcd4e635a457f/py_exporter_template-0.0.0.dev0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-24 20:09:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "weastur",
"github_project": "pyexporter",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "py-exporter-template"
}