sysulq / nginx-vts-exporter

Simple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption
https://sysulq.github.io/nginx-vts-exporter/
MIT License
645 stars 142 forks source link

unsupported protocol scheme "" #23

Closed rothgar closed 7 years ago

rothgar commented 7 years ago

I have nginx with vts and using the exporter I see this in the logs

fetchHTTP failed Get /status/format/json: unsupported protocol scheme ""

I can manually go to the /status/format/json endpoint and see the json data. Here's a sample

{"hostName":test-2rb6h","nginxVersion":"1.13.1","loadMsec":1497388530496,"nowMsec":1497388857639,"connections":{"active":1,"reading":0,"writing":1,"waiting":0,"accepted":20,"handled":20,"requests":317},"sharedZones":{"name":"ngx_http_vhost_traffic_status","maxSize":1048575,"usedSize":2441,"usedNode":1},"serverZones":{"test":{"requestCounter":316,"inBytes":102925,"outBytes":901605,"responses":{"1xx":0,"2xx":316,
"3xx":0,"4xx":0,"5xx":0,"miss":0,"bypass":0,"expired":0,"stale":0,"updating":0,"revalidated":0,"hit":0,"scarce":0},"requestMsec":0,"requestMsecs":{"times":[1497388770070,1497388771072,1497388772070,1497388773072,1497388774071,1497388775071,1497388776071,1497388777071,1497388778070,1497388779071,1497388780073,1497388781071,1497388782071,1497388783071,1497388784071,1497388785071,1497388786071,1497388787071,1497388788071,1497
388789071,1497388790071,1497388791072,1497388792071,1497388793072,1497388794071,1497388795071,1497388796072,1497388797071,1497388798071,1497388799072,1497388800071,1497388801071,1497388802072,1497388803071,1497388804071,1497388805071,1497388806071,1497388807070,1497388808070,1497388809072,1497388810070,1497388811072,1497388812071,1497388813077,1497388814071,1497388815071,1497388816071,1497388817071,1497388818071,1497388819
072,1497388820071,1497388821071,1497388822071,1497388823071,1497388824078,1497388825071,1497388826076,1497388827073,1497388828071,1497388829071,1497388830071,1497388831071,1497388856221],"msecs":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"overCounts":{"maxIntegerSize":18446744073709551615,"requestCounter":0,"inBytes":0,"outBytes":0,"1xx":
0,"2xx":0,"3xx":0,"4xx":0,"5xx":0,"miss":0,"bypass":0,"expired":0,"stale":0,"updating":0,"revalidated":0,"hit":0,"scarce":0}},"*":{"requestCounter":316,"inBytes":102925,"outBytes":901605,"responses":{"1xx":0,"2xx":316,"3xx":0,"4xx":0,"5xx":0,"miss":0,"bypass":0,"expired":0,"stale":0,"updating":0,"revalidated":0,"hit":0,"scarce":0},"requestMsec":0,"requestMsecs":{"times":[],"msecs":[]},"overCounts":{"maxIntegerSize":1844674
4073709551615,"requestCounter":0,"inBytes":0,"outBytes":0,"1xx":0,"2xx":0,"3xx":0,"4xx":0,"5xx":0,"miss":0,"bypass":0,"expired":0,"stale":0,"updating":0,"revalidated":0,"hit":0,"scarce":0}}}}

The metrics endpoint only shows

# TYPE nginx_vts_exporter_build_info gauge
nginx_vts_exporter_build_info{branch="fix-docker-error",goversion="go1.8",revision="0f3dbb44a86340d65bf3d6abbcc0ee88663cb419",version="0.4"} 1

I'm still troubleshooting but wanted to open an issue as there appears to be some configuration I've set up that doesn't work.

rothgar commented 7 years ago

I just started the same two containers on my local host manually and didn't have the same issue. There must be something different about when running these containers in kubernetes that isn't working.

If I exec into the vts-exporter pod I can curl localhost/status/format/json without issue. I'm still trying to figure out what the issue is.

rothgar commented 7 years ago

So it appears that the NGINX_HOST isn't getting set in the dockerfile. When I look at the running process in the container I can see the uri doesn't have the $NGINX_HOST variable

nginx-vts-exporter -nginx.scrape_uri=/status/format/json -telemetry.address :9913 -telemetry.endpoint /metrics -metrics.namespace nginx

I tried setting NGINX_HOST but it still didn't pick it up in the entrypoint script. I then set NGINX_STATUS to the full uri http://localhost/status/format/json and this works now.

I'm not exactly sure why this wouldn't work in kubernetes but works in vanilla docker but I figured out a way to get it to work. Closing this now and hopefully someone else can reference it in the future.