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

[Question] Using with multiple Virtual Hosts #7

Closed MrMMorris closed 7 years ago

MrMMorris commented 7 years ago

hi!

Thanks for making such an awesome exporter available! I really want to utilize it, but I have a question first:

If I want to separate my metrics per virtual host/domain then would I need to run an instance/container per virtual host with differing NGINX_STATUS'?

For instance, if I have one nginx LB serving requests for a.blah.com and b.blah.com, do I have one exporter with NGINX_STATUS=http://a.blah.com/status/format/json and one with NGINX_STATUS=http://b.blah.com/status/format/json?

Thanks!

sysulq commented 7 years ago

Nice to hear that 😆

You don't have to do it that way, because virtual host variable would be a label value in prometheus metrics.

Just like this:

nginx_server_requests{code="1xx",host="test.domain.com"} 0
MrMMorris commented 7 years ago

beautiful! Thank you 😄

MrMMorris commented 7 years ago

sorry, I guess I am still a little bit confused.

How would I set it up so that it's not a separate /status for each server block, but instead a single "global" /status?

So instead of this:

http {
    vhost_traffic_status_zone;
    ...
    server {
        server_name blah1.com;
        location /status {
            vhost_traffic_status_display;
        }
    }

    server {
        server_name blah2.com;
        location /status {
            vhost_traffic_status_display;
        }
    }

    server {
        server_name blah3.com;
        location /status {
            vhost_traffic_status_display;
        }
    }
}

I do something like this?

http { 
    vhost_traffic_status_zone;
    ...
    server { 
        server_name _;
        location /status {
            vhost_traffic_status_display;
        }
    }

    server {
        server_name blah1.com;
        ...
    }

    server {
        server_name blah2.com;
        ...
    }

    server {
        server_name blah3.com;
        ...
    }
}
sysulq commented 7 years ago

Absolutely right, you should try it this way 😄 You just need a global /status