Skip to main content

PowerDNS records exporter

Project description

Python PowerDNS Records Exporter

This module can be used to export PowerDNS records database in several ways:

  • to bind zone format
  • records metrics for Prometheus

Installation

PyPI

Deploy the pdns records exporter in your server with the pip command.

pip install python_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.

docker pull dmachard/pdns-exporter:latest

Deploy the container

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

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

pdns_exporter-0.0.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

pdns_exporter-0.0.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file pdns_exporter-0.0.1.tar.gz.

File metadata

  • Download URL: pdns_exporter-0.0.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pdns_exporter-0.0.1.tar.gz
Algorithm Hash digest
SHA256 76f2403f8094c62ea4505b700d155d2565485b443e86d6a3f9d24193a83ba33b
MD5 f20242501d11d76e9225e2302f2aa5d0
BLAKE2b-256 8059e6a045bb6418512fa70d0b21bef88938c0917066c19f2e5606cb20d2233b

See more details on using hashes here.

File details

Details for the file pdns_exporter-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pdns_exporter-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pdns_exporter-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f616d374d826ae31b290034f2eb759cce08246f9c501e1f72378089bd1a5a84
MD5 c2612298aa1e36dadc79a486f4b54858
BLAKE2b-256 292174c8e1ca4c79540adf5070eb894f92f7b718c8ffdc1d4f5057771819210a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page