I don’t have this field at all: caddy_http_requests_total
This is what I only have. Why is this missing? How did you activate this in your caddy config?
curl localhost:2019/metrics | grep http
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6719 0 6719 0 0 1400k 0 --:--:-- --:--:-- --:--:-- 1640k
# HELP caddy_admin_http_requests_total Counter of requests made to the Admin API's HTTP endpoints.
# TYPE caddy_admin_http_requests_total counter
caddy_admin_http_requests_total{code="200",handler="load",method="POST",path="/load"} 40
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 162539
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
That’s not right. The metrics enabled by default are the admin metrics. These are what you see, even though you used the metrics handler. You haven’t enabled metrics on the server configuration itself.
Configuring servers is done in the global options. The options section goes at the top of the Caddyfile, not at the bottom. You need to read this page.
curl localhost:2019/metrics | grep http | grep total
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0# HELP caddy_admin_http_requests_total Counter of requests made to the Admin API's HTTP endpoints.
# TYPE caddy_admin_http_requests_total counter
caddy_admin_http_requests_total{code="200",handler="load",method="POST",path="/load"} 1
# HELP caddy_http_requests_total Counter of HTTP(S) requests made.
# TYPE caddy_http_requests_total counter
caddy_http_requests_total{handler="metrics",server="srv0"} 46
caddy_http_requests_total{handler="static_response",server="srv2"} 34
caddy_http_requests_total{handler="subroute",server="srv1"} 1475
caddy_http_requests_total{handler="subroute",server="srv2"} 2
100 86388 0 86388 0 0 19.1M 0 --:--:-- --:--:-- --:--:-- 20.5M
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 46
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
I am also able to load this into Prometheus and visualize it in Grafana.