A prometheus exporter for opnsense dhcp ipv4 leases written in typescript with nestjs.
As a network administrator, I want to have a Prometheus exporter for OPNsense firewall that can export DHCPv4 lease data. This will allow me to monitor the DHCPv4 leases in my network infrastructure and make informed decisions based on the metrics. The exporter should be able to:
- Connect to the OPNsense firewall and fetch DHCPv4 lease data.
- Transform the fetched data into a format that Prometheus can understand.
- Expose an HTTP endpoint that Prometheus can scrape to collect the metrics.
- Handle any errors during the data fetching and transformation process, and expose these errors as metrics as well.
pnpm install
You can pass CONFIG_PATH
env variable to point to your configuration.yaml
. Default path is $(XDG_CONFIG_HOME)/opnsense-exporter/configuration.yaml
You can use env variables as placeholder in the configuration.yaml
---
app:
port: 3000
host: 0.0.0.0
pretty: true
opnsense:
url: ${env.OPNSENSE_URL}
apiKey: ${env.OPNSENSE_API_KEY}
apiSecret: ${env.OPNSENSE_API_SECRET}
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod
# unit tests
$ pnpm run test
# e2e tests
$ pnpm run test:e2e
# test coverage
$ pnpm run test:cov