miekg / caddy-prometheus

Prometheus metrics middleware for caddy
Apache License 2.0
65 stars 26 forks source link

Not getting any codes other than 200 #14

Closed leonkyneur closed 8 years ago

leonkyneur commented 8 years ago

running caddy 0.9.0

$ curl -I mycaddyserver:2015/php/breakme.phphp
HTTP/1.1 500 Internal Server Error
Content-Type: text/html
Server: Caddy
Status: 500 Internal Server Error
X-Powered-By: PHP/5.5.9-1ubuntu4.17
Date: Wed, 27 Jul 2016 09:11:30 GMT

/metrics only showing:

# HELP caddy_http_response_status_count_total Counter of response status codes.
# TYPE caddy_http_response_status_count_total counter
caddy_http_response_status_count_total{host="mycaddyserver",status="200"} 6

Caddyfile:

http://0.0.0.0:2015

fastcgi /php 127.0.0.1:9000 php

prometheus 127.0.0.1:2020
miekg commented 8 years ago

Hmm, that should work, but maybe the error path for 500s is different than for other slightly less severe errors, 403, etc.

On 27 Jul 2016 2:23 a.m., "Leon Kyneur" notifications@github.com wrote:

running caddy 0.9.0

$ curl -I mycaddyserver:2015/php/breakme.phphp HTTP/1.1 500 Internal Server Error Content-Type: text/html Server: Caddy Status: 500 Internal Server Error X-Powered-By: PHP/5.5.9-1ubuntu4.17 Date: Wed, 27 Jul 2016 09:11:30 GMT

/metrics only showing:

HELP caddy_http_response_status_count_total Counter of response status codes.

TYPE caddy_http_response_status_count_total counter

caddy_http_response_status_count_total{host="mycaddyserver",status="200"} 6

Caddyfile:

http://0.0.0.0:2015

fastcgi /php 127.0.0.1:9000 php

prometheus 127.0.0.1:2020

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/miekg/caddy-prometheus/issues/14, or mute the thread https://github.com/notifications/unsubscribe-auth/AAVkW6EuC7L_Q6eihqVeMW-f0rHyH4Gkks5qZyOQgaJpZM4JV_zs .

miekg commented 8 years ago

This is because of this text in fastcgi

            // Normally we would return the status code if it is an error status (>= 400),
            // however, upstream FastCGI apps don't know about our contract and have
            // probably already written an error page. So we just return 0, indicating
            // that the response body is already written. However, we do return any
            // error value so it can be logged.
            // Note that the proxy middleware works the same way, returning status=0.

I have no portable way to work around this, except adding a new metric that logs errors.

miekg commented 8 years ago

Or lump all err != nil to a 5xx status code... 500 prolly