Monitoring Caddy Server with Grafana (Prometheus + Loki) on Debian

Monitoring Caddy Server with Grafana (Prometheus + Loki) on Debian

I want to share with you a solution for monitoring your Caddy server with Grafana.

I decided to write this because it is not easy to find the necessary information on this subject and it is difficult to find an example of a recent Grafana Dashboard.

To do this, I used the following tools:
:point_right: Grafana which is a data analysis and monitoring tool.
:point_right: Prometheus which communicates with the REST API of the Caddy web server.
:point_right: Loki (Promtail) which retrieves json logs from the Caddy web server.

GitHub tutorial link: Malfhas/caddy-grafana: Monitoring Caddy Server with Grafana (Prometheus + Loki) on Debian (github.com)
Grafana Dashboard link: Caddy Monitoring | Grafana Labs

Screenshot :

I hope this can be helpful for some.

8 Likes

Good job :slight_smile:
Having this as a Docker (compose) container would be great!

Hi,

is it poosible to run this without Loki? I just want to see the Caddy metrics through Grafana.

Thank you for sharing

Thank you so much! this works really well for my homelab

just one comment for anybody who will do this on their large docker-compose. Slight offtopic, but related to caddy admin, and may be helpful for people who will try to setup this.

in case, if you a lot of networks, and do not want (you probably now want) to expose caddy admin to another containers, you could use network alias and bind caddy admin to that alias. It’s same thing as binding to specific interface, but just will use alias, as in docker networks it’s not a good thing to bind to static ip’s

In example below, network caddy_with_admin is used to bind caddy admin. Only within this network, caddy container is aliased to caddy-aliased. In other_network, it’s not resolvable. To access caddy admin from another container, just add it to caddy_with_admin net and try to curl caddy-aliased:2019, it will work :slight_smile:

# Caddyfile
{
    admin caddy-aliased:2019
}

# docker-compose.yml
services:
    caddy:
      # ...
      networks:
        other_network:
        caddy_with_admin:
          aliases:
            - caddy-aliased