Python PowerDNS Records Exporter
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.
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 example for more options.
Docker Hub
Pull the pdns exporter image from Docker Hub.
sudo docker pull dmachard/pdns-exporter:latest
Deploy the container
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 documentation.
Examples
Get all dns zones
$ 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
$ 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
$ 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 example.
Development
Run
the dnstap receiver from source
sudo python3 -c "from pdns_exporter import exporter; exporter.start_exporter();" -v
Testunits
sudo python3 -m unittest -v
Build docker image
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 |
Metadata
Release files for pdns-exporter 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pdns_exporter-0.3.0.tar.gz | 7.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pdns_exporter-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.0 kB
Release files / pdns_exporter-0.3.0.tar.gz
| Download URL | pdns_exporter-0.3.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bacc5098d3f92556d4b5bb4ec0ed4c79f1e5c9d3597d397d6a4cf106a51e577c
|
|
BLAKE2b-256 checksum How to use checksums |
3e9ab29fc7541a3d4c7953ee21818c0b1c27931bea9ebdd38e0a519cc8f9c40e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / pdns_exporter-0.3.0-py3-none-any.whl
| Download URL | pdns_exporter-0.3.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
088c650a56ba62f55cdcd835f112e9bc88548dabe18cb8f6a182945e6bb62d52
|
|
BLAKE2b-256 checksum How to use checksums |
ca6cdbe0117735357593bd9342eeda03b32ee94c437c5d70186d396f51925cf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|