nginx-vts-exporter icon indicating copy to clipboard operation
nginx-vts-exporter copied to clipboard

Getting "fetchHTTP failed HTTP status 401" error

Open tdabasinskas opened this issue 5 years ago • 1 comments

Hi,

We are facing a strange issue with nginx-vts-exporter (v0.10.3). The exporter keeps flooding /var/log/messages with the following error:

#tail -n 10 /var/log/messages | grep nginx
nginx-vts-exporter: 2018/07/24 10:04:50 fetchHTTP failed HTTP status 401

In addition, it only exports the following metric:

#curl http://localhost:9913/metrics
# HELP nginx_vts_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which nginx_vts_exporter was built.
# TYPE nginx_vts_exporter_build_info gauge
nginx_vts_exporter_build_info{branch="HEAD",goversion="go1.10",revision="8aa2881c7050d9b28f2312d7ce99d93458611d04",version="0.10.3"} 1

We are using the default configuration (no environment variables or command line parameters), meaning it should be scraping http://localhost/status URL. The interesting part is that trying to CURL this URL from the server works perfectly:

# curl -sSL -D - http://localhost/status -o /dev/null
HTTP/1.1 200 OK
Server: nginx/1.14.0
Date: Tue, 24 Jul 2018 08:07:32 GMT
Content-Type: application/json
Content-Length: 50803
Connection: keep-alive

Some of the Nginx VHosts are indeed protected by basic auth, which could possibly result in 401, but localhost should not require the auth (which is confirmed by the CURL result above).

One more thing worth mentioning is that restarting nginx-vts-exporter solves the problem for some time (it starts getting the metrics properly). Anyhow, after some time it breaks again.

Any ideas what might be happening here?

tdabasinskas avatar Jul 24 '18 08:07 tdabasinskas

You should add these two lines in nginx.conf inside http:

    vhost_traffic_status_zone shared:vhost_traffic_status:32m;
    vhost_traffic_status_filter_by_host on;

ykfq avatar Nov 14 '20 00:11 ykfq