Metricbeat can't collect nginx metrics

Hi folks,
:slight_smile:We encountered an issue while we trying to collect the nginx metrics from a nginx server via metricbeat, the thing that we installed the newest nginx version
and also enabled nginx status module and setup nginx module correctly in metricbeat.xml. when I enabled debug mode with metricbeat, can't get the nginx module metrics.

It would be appreciated if someone can help on this.

Env:

OS: centOS 6.8
Metricbeat: 5.2.1-1
Nginx:1.10.2

Configure:

/usr/local/nginx/sbin/nginx -V 2>&1 | grep -o with-http_stub_status_module
with-http_stub_status_module

nginx.conf

server {
location /nginx_status {
    stub_status on;

    access_log off;
    allow 127.0.0.1;
    deny all;
   }
}

metricbeat.xml

- module: nginx
  metricsets: ["stubstatus"]
  enabled: true
  period: 10s

  # Nginx hosts
  hosts: ["127.0.0.1"]

  # Path to server status. Default server-status
  #server_status_path: "nginx-status"

Test:
curl -k http://127.0.0.1/nginx_status

Active connections: 7 
server accepts handled requests
 125 125 2721 
Reading: 0 Writing: 1 Waiting: 6 

/usr/share/metricbeat/bin/metricbeat -c /etc/metricbeat/metricbeat.yml >/tmp/nginx

  "metricset": {
    "host": "127.0.0.1",
    "module": "nginx",
    "name": "stubstatus",
    "rtt": 3630
  },
  "nginx": {
    "stubstatus": {}
  },
  "type": "metricsets"

Our current implementation is tested with 1.9. I'm curious if something changed in 1.10? Could you share the output you get if you access localhost/server-status?

Hi ruflin,

Thanks for your quickly reply.
after I changed nginx location of stubstus from nginx-status to server-status, we can get the nginx metrics, It's weird that the configure file saids the server_status_path can be customized.

nginx.conf

server {
   location /server-status {
    stub_status on;

    access_log off;
    allow 127.0.0.1;
    deny all;
   }  
 }

metricbeat.yml

  • module: nginx
    metricsets: ["stubstatus"]
    enabled: true
    period: 10s

    Nginx hosts

    hosts: ["127.0.0.1"]

    Path to server status. Default server-status

    #server_status_path: "nginx-status"

metricbet startup log by debug mode

2017/03/02 03:29:24.991245 module.go:78: DBG Initializing Module type 'nginx': *mb.BaseModule={name:"nginx", config:{Module:"nginx", MetricSets:[stubstatus], Enabled:true, Hosts:[1 hosts], Period:"10s", Timeout:"1s", Raw:false, Fields:null, FieldsUnderRoot:false, Tags:[]}}
2017/03/02 03:29:24.991253 processor.go:43: DBG Processors:
2017/03/02 03:29:24.991260 module.go:94: DBG Initializing MetricSet type 'nginx/stubstatus' for host '127.0.0.1': *stubstatus.MetricSet={name:"stubstatus", module:"nginx", hostData:{SanitizedURI:"http://127.0.0.1/server-status", Host:"127.0.0.1"}}
Config OK

metric log

2017-03-02T11:30:15+08:00 DBG Publish: {
"@timestamp": "2017-03-02T03:30:15.007Z",
"beat": {
"hostname": "ukgrafana-test1",
"name": "ukgrafana-test1",
"version": "5.2.1"
},
"fields": {
"dc": "slough",
"env": "test",
"type": "nginx"
},
"metricset": {
"host": "127.0.0.1",
"module": "nginx",
"name": "stubstatus",
"rtt": 305
},
"nginx": {
"stubstatus": {
"accepts": 7,
"active": 1,
"current": 1,
"dropped": 0,
"handled": 7,
"hostname": "127.0.0.1",
"reading": 0,
"requests": 15,
"waiting": 0,
"writing": 1
}
},
"type": "metricsets"
}

In your example above, the line for the server_status_path is commented out. Is that just copy/paste problem?

I uncommented server_status_path="nginx-status" befoe and set the location as /nginx-status within
nginx.conf, but can't get the metrics, that's why I use the default server_status_path ..

That sounds like a bug :frowning: Could you open a Github issue so we can investigate this one further? Please add there the config you used for metricbeat and nginx that didn't work.

sure, I'll do it soon.

Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.