# Python PowerDNS Records Exporter
![powerdns auth 4.8.x](https://img.shields.io/badge/pdns%204.8.x-tested-green) ![powerdns auth 4.7.x](https://img.shields.io/badge/pdns%204.7.x-tested-green) ![powerdns auth 4.6.x](https://img.shields.io/badge/pdns%204.6.x-tested-green) ![powerdns auth 4.5.x](https://img.shields.io/badge/pdns%204.5.x-tested-green) ![powerdns auth 4.4.x](https://img.shields.io/badge/pdns%204.4.x-tested-green)
This tool can be usedto export PowerDNS records database in several ways:
- bind zone format
- metrics for Prometheus
## Installation
### PyPI
Deploy the pdns records exporter in your server with the pip command.
```python
pip install pdns_exporter
```
After installation, you can execute the `pdns_exporter` to start-it.
By default, the server is listening on the tcp port `9090`.
See [config file](/pdns_exporter/settings.conf) example for more options.
### Docker Hub
Pull the pdns exporter image from Docker Hub.
```bash
sudo docker pull dmachard/pdns-exporter:latest
```
Deploy the container
```bash
sudo docker run -d -p 9090:9090 --name=pdnsexporter01 dmachard/pdns-exporter
```
The container can be configured with the following environment variables:
| Variables | Description |
| ------------- | ------------- |
| PDNSEXPORT_VERBOSE | 1 or 0 to enable verbose mode |
| PDNSEXPORT_LOCAL_ADDRESS | listening ip address of the server |
| PDNSEXPORT_LOCAL_PORT | listening port |
| PDNSEXPORT_API_LOGIN | login for basic authentication |
| PDNSEXPORT_API_PASSWORD | password for basic authentication |
| PDNSEXPORT_DB_HOST | Ip address of your database powerdns server |
| PDNSEXPORT_DB_PORT | Port of your database powerdns server |
| PDNSEXPORT_DB_USER | User database of your powerdns server |
| PDNSEXPORT_DB_PWD | Password database of your powerdns server |
| PDNSEXPORT_DB_NAME | Database name of your powerdns server |
## HTTP API
### Security
Basic authentication method is only supported, don't forget to change the default login and password in settings.conf.
### Swagger
See the [swagger](https://generator.swagger.io/?url=https://raw.githubusercontent.com/dmachard/python-pdns-exporter/master/swagger.yml) documentation.
## Examples
Get all dns zones
```bash
$ curl -u changeme:changeme http://127.0.0.1:9090/zones | jq .
[
{
"id": 1,
"name": "zone.test"
}
]
```
Get a specific zone with zone file format
```bash
$ curl -u changeme:changeme http://127.0.0.1:9090/zone/1
$ORIGIN .
zone.test 3600 IN SOA a.misconfigured.dns.server.invalid hostmaster.zone.test 0 10800 3600 604800 3600
zone.test 3600 IN NS ns1.zone.test
ns1.zone.test 3600 IN A 128.0.0.1
a.zone.test 300 IN A 128.0.0.2
a2.zone.test 300 IN A 128.0.0.2
a2.zone.test 300 IN A 128.0.0.3
aaaa.zone.test 300 IN AAAA fe80::42:1eff:feed:f6d6
cname.zone.test 300 IN CNAME a.zone.test
txt.zone.test 300 IN TXT "hello world"
```
Get metrics for prometheus of each dns zones declared in your dns server
```bash
$ curl -u changeme:changeme http://127.0.0.1:9090/metrics
# HELP pdnsexporter_zones_total Total number of zones
# TYPE pdnsexporter_zones_total counter
pdnsexporter_zones_total 4
# HELP pdnsexporter_records_total Total number of records
# TYPE pdnsexporter_records_total counter
pdnsexporter_records_total 32
...
```
See [metrics file](/metrics.txt) example.
## Development
### Run
the dnstap receiver from source
```bash
sudo python3 -c "from pdns_exporter import exporter; exporter.start_exporter();" -v
```
### Testunits
```bash
sudo python3 -m unittest -v
```
### Build docker image
```bash
sudo docker build . --file Dockerfile -t pdns-exporter
```
## About
| | |
| ------------- | ------------- |
| Author | Denis Machard <d.machard@gmail.com> |
| PyPI | https://pypi.org/project/python-pdns-exporter/ |
| Github | https://github.com/dmachard/python-pdns-exporter|
| DockerHub | https://hub.docker.com/r/dmachard/pdns-exporter |
| | |
Raw data
{
"_id": null,
"home_page": "https://github.com/dmachard/python-pdns-exporter",
"name": "pdns-exporter",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "powerdns pdns database exporter mysql zone bind",
"author": "Denis MACHARD",
"author_email": "d.machard@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3e/9a/b29fc7541a3d4c7953ee21818c0b1c27931bea9ebdd38e0a519cc8f9c40e/pdns_exporter-0.3.0.tar.gz",
"platform": "any",
"description": "# Python PowerDNS Records Exporter\n\n![powerdns auth 4.8.x](https://img.shields.io/badge/pdns%204.8.x-tested-green) ![powerdns auth 4.7.x](https://img.shields.io/badge/pdns%204.7.x-tested-green) ![powerdns auth 4.6.x](https://img.shields.io/badge/pdns%204.6.x-tested-green) ![powerdns auth 4.5.x](https://img.shields.io/badge/pdns%204.5.x-tested-green) ![powerdns auth 4.4.x](https://img.shields.io/badge/pdns%204.4.x-tested-green)\n\nThis tool can be usedto export PowerDNS records database in several ways:\n- bind zone format\n- metrics for Prometheus\n\n## Installation\n\n### PyPI\n\nDeploy the pdns records exporter in your server with the pip command.\n\n```python\npip install pdns_exporter\n```\n\nAfter installation, you can execute the `pdns_exporter` to start-it.\nBy default, the server is listening on the tcp port `9090`.\n\nSee [config file](/pdns_exporter/settings.conf) example for more options.\n\n### Docker Hub\n\nPull the pdns exporter image from Docker Hub.\n\n```bash\nsudo docker pull dmachard/pdns-exporter:latest\n```\n\nDeploy the container\n\n```bash\nsudo docker run -d -p 9090:9090 --name=pdnsexporter01 dmachard/pdns-exporter\n```\n\nThe container can be configured with the following environment variables:\n\n| Variables | Description |\n| ------------- | ------------- |\n| PDNSEXPORT_VERBOSE | 1 or 0 to enable verbose mode |\n| PDNSEXPORT_LOCAL_ADDRESS | listening ip address of the server |\n| PDNSEXPORT_LOCAL_PORT | listening port |\n| PDNSEXPORT_API_LOGIN | login for basic authentication |\n| PDNSEXPORT_API_PASSWORD | password for basic authentication |\n| PDNSEXPORT_DB_HOST | Ip address of your database powerdns server |\n| PDNSEXPORT_DB_PORT | Port of your database powerdns server |\n| PDNSEXPORT_DB_USER | User database of your powerdns server |\n| PDNSEXPORT_DB_PWD | Password database of your powerdns server |\n| PDNSEXPORT_DB_NAME | Database name of your powerdns server |\n\n\n## HTTP API\n\n### Security\n\nBasic authentication method is only supported, don't forget to change the default login and password in settings.conf.\n\n### Swagger\n\nSee the [swagger](https://generator.swagger.io/?url=https://raw.githubusercontent.com/dmachard/python-pdns-exporter/master/swagger.yml) documentation.\n\n## Examples\n\nGet all dns zones \n\n```bash\n$ curl -u changeme:changeme http://127.0.0.1:9090/zones | jq .\n[\n {\n \"id\": 1,\n \"name\": \"zone.test\"\n }\n]\n```\n\nGet a specific zone with zone file format\n\n```bash\n$ curl -u changeme:changeme http://127.0.0.1:9090/zone/1\n$ORIGIN .\nzone.test\t3600\tIN\tSOA\ta.misconfigured.dns.server.invalid hostmaster.zone.test 0 10800 3600 604800 3600\nzone.test\t3600\tIN\tNS\tns1.zone.test\nns1.zone.test\t3600\tIN\tA\t128.0.0.1\na.zone.test\t300\tIN\tA\t128.0.0.2\na2.zone.test\t300\tIN\tA\t128.0.0.2\na2.zone.test\t300\tIN\tA\t128.0.0.3\naaaa.zone.test\t300\tIN\tAAAA\tfe80::42:1eff:feed:f6d6\ncname.zone.test\t300\tIN\tCNAME\ta.zone.test\ntxt.zone.test\t300\tIN\tTXT\t\"hello world\"\n```\n\nGet metrics for prometheus of each dns zones declared in your dns server\n\n```bash\n$ curl -u changeme:changeme http://127.0.0.1:9090/metrics\n# HELP pdnsexporter_zones_total Total number of zones\n# TYPE pdnsexporter_zones_total counter\npdnsexporter_zones_total 4\n# HELP pdnsexporter_records_total Total number of records\n# TYPE pdnsexporter_records_total counter\npdnsexporter_records_total 32\n...\n```\n\nSee [metrics file](/metrics.txt) example.\n\n## Development\n\n### Run \n\nthe dnstap receiver from source\n\n```bash\nsudo python3 -c \"from pdns_exporter import exporter; exporter.start_exporter();\" -v\n```\n\n### Testunits\n\n```bash\nsudo python3 -m unittest -v\n```\n\n### Build docker image\n\n```bash\nsudo docker build . --file Dockerfile -t pdns-exporter\n```\n\n## About\n\n| | |\n| ------------- | ------------- |\n| Author | Denis Machard <d.machard@gmail.com> |\n| PyPI | https://pypi.org/project/python-pdns-exporter/ |\n| Github | https://github.com/dmachard/python-pdns-exporter|\n| DockerHub | https://hub.docker.com/r/dmachard/pdns-exporter |\n| | |\n",
"bugtrack_url": null,
"license": "",
"summary": "PowerDNS records exporter",
"version": "0.3.0",
"project_urls": {
"Homepage": "https://github.com/dmachard/python-pdns-exporter"
},
"split_keywords": [
"powerdns",
"pdns",
"database",
"exporter",
"mysql",
"zone",
"bind"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ca6cdbe0117735357593bd9342eeda03b32ee94c437c5d70186d396f51925cf7",
"md5": "a85cbcefe2943bb2b06fd9e20087308d",
"sha256": "088c650a56ba62f55cdcd835f112e9bc88548dabe18cb8f6a182945e6bb62d52"
},
"downloads": -1,
"filename": "pdns_exporter-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a85cbcefe2943bb2b06fd9e20087308d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7322,
"upload_time": "2023-07-06T18:42:59",
"upload_time_iso_8601": "2023-07-06T18:42:59.506410Z",
"url": "https://files.pythonhosted.org/packages/ca/6c/dbe0117735357593bd9342eeda03b32ee94c437c5d70186d396f51925cf7/pdns_exporter-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3e9ab29fc7541a3d4c7953ee21818c0b1c27931bea9ebdd38e0a519cc8f9c40e",
"md5": "3971fea43ef60a501d20301c895a7f6d",
"sha256": "bacc5098d3f92556d4b5bb4ec0ed4c79f1e5c9d3597d397d6a4cf106a51e577c"
},
"downloads": -1,
"filename": "pdns_exporter-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "3971fea43ef60a501d20301c895a7f6d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7683,
"upload_time": "2023-07-06T18:43:01",
"upload_time_iso_8601": "2023-07-06T18:43:01.428059Z",
"url": "https://files.pythonhosted.org/packages/3e/9a/b29fc7541a3d4c7953ee21818c0b1c27931bea9ebdd38e0a519cc8f9c40e/pdns_exporter-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-06 18:43:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dmachard",
"github_project": "python-pdns-exporter",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "pdns-exporter"
}