mweinelt / kea-exporter

Export Kea Metrics in the Prometheus Exposition Format
MIT License
33 stars 17 forks source link

Kea HTTP ctrl-agent support #33

Closed Qwiko closed 5 months ago

Qwiko commented 1 year ago

I think it would be a good idea to continue developing this repository. I would like to help rebuilding to support both sockets and http "backends". I see someone have already implemented a http-version but it is rather outdated. https://github.com/ddericco/kea_exporter/tree/master

I can also see that a docker container with http metric support would be very useful for kubernetes deployments with automatic prometheus discovery. Configurable either with environment-variables or a configmap/configfile.

mweinelt commented 1 year ago

On a conference, will hopefully have a chance to take a look next week.

Qwiko commented 7 months ago

Pull request: #40 adds docker support. I think it should be added to version 0.6.0.

mweinelt commented 7 months ago

I will tag another release once the currently active PRs are in. That should only take a few days. Sorry for not making a release with HTTP support earlier.

mweinelt commented 5 months ago

Has been released in 0.6.0

M0NsTeRRR commented 5 months ago

I think it would be a good idea to continue developing this repository. I would like to help rebuilding to support both sockets and http "backends". I see someone have already implemented a http-version but it is rather outdated. https://github.com/ddericco/kea_exporter/tree/master

I can also see that a docker container with http metric support would be very useful for kubernetes deployments with automatic prometheus discovery. Configurable either with environment-variables or a configmap/configfile.

I've just deployed the exporter on a kubernetes environment with helm and it works like a charm :) I will update this weekend the kea-exporter dashboard :)

M0NsTeRRR commented 5 months ago

Here is my basic helm chart for my homelab, I post it here as reference if someone wants an example in the future :) https://github.com/M0NsTeRRR/helm-charts/tree/main/charts/kea-exporter

i've integrated the serviceMonitor & prometheus rule to notify if the exporter is down or if a dhcp pool is over 90% :)

M0NsTeRRR commented 5 months ago

Dashboard updated. I've also updated the screenshots, although they are not currently displayed due to Grafana caching.

Qwiko commented 5 months ago

@M0NsTeRRR I am using your helm-chart now in my environment with argocd and it works very well! I have 2 dhcp servers with HA and using multiple targets in one pod overwrites metrics from each other. I am instead using a parent chart with your chart as a dependency with different aliases so I get individual statistics from each server.

Chart.yaml

apiVersion: v2
name: kea-exporter
version: 0.0.1
dependencies:
  - name: kea-exporter
    alias: keadhcp-01
    version: 0.1.2
    repository: https://helm-charts.adminafk.fr
  - name: kea-exporter
    alias: keadhcp-02
    version: 0.1.2
    repository: https://helm-charts.adminafk.fr

values.yaml

keadhcp-01:
  extraEnv: 
    - name: TARGETS
      value: "http://keadhcp-01:8000"

keadhcp-02:
  extraEnv: 
    - name: TARGETS
      value: "http://keadhcp-02:8000"
M0NsTeRRR commented 5 months ago

Metrics are differents on each server with HA ? It should not be the case ? 🤔

I did not test that but I assume they would be the same when both servers have the same configuration.

Qwiko commented 5 months ago

Metrics are differents on each server with HA ? It should not be the case ? 🤔

I did not test that but I assume they would be the same.

In my setup only one of the servers is active at once (Active/Standby) and therefore some metrics are different between the servers.

Example:

#server 1 Active
kea_dhcp4_packets_sent_total{operation="ack"} 17844.0
kea_dhcp4_packets_sent_total{operation="nak"} 10.0
kea_dhcp4_packets_sent_total{operation="offer"} 640.0
#server 2 Standby
kea_dhcp4_packets_sent_total{operation="ack"} 0.0
kea_dhcp4_packets_sent_total{operation="nak"} 0.0
kea_dhcp4_packets_sent_total{operation="offer"} 0.0

It looks like the statistics in the kea-server is only cached locally and resets after a reboot. So it makes sense that some metrics are different between two servers.

From: https://kea.readthedocs.io/en/kea-2.4.1/arm/stats.html#statistics-lifecycle

All of the statistics supported by Kea's servers are initialized upon the servers' startup and are returned in response to the commands such as statistic-get-all. The runtime statistics concerning DHCP packets processed are initially set to 0 and are reset upon the server restart.

Qwiko commented 5 months ago

I was thinking about how you would deploy Kea fully in kubernetes. Kea has official docker containers. https://gitlab.isc.org/isc-projects/kea-docker

Would be cool to see how to run kea with kea-exporter as a sidecar, then you get individual statistics per pod. I wonder if you could use the new Kubernetes gateway api with UDPRoute with auto-scaling pods in a active/active scenario if it even is possible doing this with dhcp-servers. Config backend would be simple by using PostgreSQL operator for example.

Might try this as a test some day to see if it is possible.

M0NsTeRRR commented 5 months ago

I don't currently run my Kea dhcp in a Kubernetes environment, as I've set it up with DNS as a requirement for my basic infrastructure. However, I believe it could be done with some effort. The optimal deployment would likely involve using a Kea DHCP Helm chart with optional monitoring, including an exporter as a sidecar, automatically mounting the dashboard, and adding Prometheus rules as you described. As cilium released API Gateway support in GA it could be the best working solution 👍

I've added to my to-do list the task of adding the dashboard as a configmap sidecar for Grafana autodiscovery in my helm chart.