Monitoring Pi-hole with Telegraf

If we have a Pi-hole in our network, to protect us from certain malicious DNS or advertising resolutions… and, if we have a Telegraf lying around, an Influxdb and a Grafana… in a moment we will be able to visualize the Pi-hole data there!

What I said, Pi-hole is a classic on our networks, We already saw it in this Post old man, which helps us to remove advertising in our browsing, making it cleaner and more digestible, in addition to that, we know that it also filters DNS names that will protect us from possible fraudulent URLs, etc… Well, well, if we want to transfer the results of this filtering and see it in Grafana, and then analyze it, understand it or consult it because this is your post 😉

In This post we already saw how to install Influxdb, Telegraf or Grafana, that we will need them, as we know the first to store the data we collect, the second is the agent that collects the data and Grafana we all know since he is the love of our life! I said no! So much not, but it's a great data visualizer!

Total, that simply, editaremos el fichero de Telegraf de la máquina desde donde queramos conectar a Pi-hole y mediante API obtenerle los datos, editamos ‘/etc/telegraf/telegraf.conf’ descomentando y quedándonos algo como:

[[inputs.http]]
#PiHole URL for data in JSON format urls = ["HTTP://DIRECCION_IP/admin/api.php"]
method = "GET"

#Overwrite measurement name from default `http` to `pihole_stats` name_override = "pihole_stats"

#Exclude url and host items from tags tagexclude = ["host"]

#Data from HTTP in JSON format data_format = "json"

#JSON values to set as string fields json_string_fields = ["URL", "status"]

insecure_skip_verify = true

Y tras grabar el fichero de configuración, reiniciamos Telegraf para leer los cambios, with:

sudo systemctl restart telegraf

And, ahora ya desde Grafana, thanks to the Data Source that connects to our Influxdb we will be able to import a Dashboard that the community has made, I recommend this ID: ‘13565‘ which belongs to my little friend Jorge de la Cruz and he works hard!

In a moment you'll have something like this! This one of mine is somewhat bland since there was no user browsing until a couple of hours ago, But, well, As an idea, it's worth it, No?

As usual, that you take good care of yourselves, May it go very well, May you be happy, Eat partridges… behave well and love!!!

Hugs,

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!

Monitoring Brocade switches

18 de April de 2023