Skip to content

A prometheus exporter for opnsense dhcp ipv4 leases written in typescript with nestjs.

License

Notifications You must be signed in to change notification settings

tyriis/opnsense-exporter

Repository files navigation

taskfile pre-commit renovate NestJS TypeScript

opnsense-exporter

A prometheus exporter for opnsense dhcp ipv4 leases written in typescript with nestjs.

User Story

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.

Installation

pnpm install

Configuration

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}

Running the app

# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod

Test

# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov