Skip to content

hatamiarash7/ipset-exporter

Repository files navigation

Prometheus Exporter for ipset

Golang Release License Image size

It's a simple ipset exporter that generate Prometheus metrics from ipset lists. Every metric has a label set that shows the ipset list name with the number of elements in the list as the value.

ipset_count{set="my-set-1"} 41
ipset_count{set="my-set-2"} 23

How-to 🚀

This exporter needs NET_ADMIN to fetch ipset data using netlink. You can build and run this exporter as a single binary:

make
sudo setcap cap_net_admin+ep ./bin/ipset-exporter
cp config.yml.example
./bin/ipset-exporter

Or you can use Docker:

docker run -d \
    --name ipset-exporter \
    --net host \
    -v /path/to/config.yml:/app/configs/config.yml \
    -e CONFIG_FILE=/app/configs/config.yml \
    --cap-add=NET_ADMIN \
    hatamiarash7/ipset-exporter:latest

Note

The Docker container needs to run with NET_ADMIN capability to fetch ipset data.
Also, You should run it with --net host to access the host network namespace.

Configuration 🛠

You can configure the exporter using a YAML file. The example configuration is:

app:
    host: 127.0.0.1
    port: 4613
    log_level: info

ipset:
    names:
        - my-set-1
        - my-set-2

You can choose any ipset name that you want to monitor or use the all keyword to monitor all ipset lists.


Support 💛

Donate with Bitcoin Donate with Ethereum

Contributing 🤝

Don't be shy and reach out to us if you want to contribute 😉

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Issues

Each project may have many problems. Contributing to the better development of this project by reporting them. 👍