Ben Hizak
Ben Hizak

Reputation: 31

Monitoring nginx on docker using stackdriver (gcloud hosted)

In order to monitor nginx (as an application) using stackdriver, is it sufficient to simply direct loggin to gcploggin driver or does one have to install the monitoring agent as well?

Upvotes: 0

Views: 1136

Answers (1)

Peycho Dimitrov
Peycho Dimitrov

Reputation: 1407

To monitor nginx status page metrics:

  1. Your server need to be google cloud instance or an AWS instance.
  2. Yes. You need to install the agent on your server/instance/docker
  3. You need to add nginx plugin configuration.
  4. You have to modify your Nginx configuration to allow Stackdriver agent to access the status page.

Nginx:

# Enable nginx-status for better monitoring with Stackdriver module.
location = /nginx-status {
    # Turn on nginx stats
    stub_status on;
    # I do not need logs for stats
    access_log   off;
    # Security: Only allow access from localhost
    allow 127.0.0.1;
    # Send rest of the world to /dev/null
    deny all;
}

Example Nginx plugin Configuration: https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/nginx.conf

You can modify the stackdriver nginx plugin config to read nginx status metrics like this:

LoadPlugin nginx
<Plugin "nginx">
    URL "http://localhost/nginx-status"
</Plugin>

More plugin configurations: https://github.com/Stackdriver/stackdriver-agent-service-configs/tree/master/etc/collectd.d

Upvotes: 1

Related Questions