# Metricbeat can't collect nginx metrics

**URL:** <https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [March 1, 2017, 4:46am UTC](https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911 "2017-03-01T04:46:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robin\_Guo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robin_guo/32/42297_2.png) [@Robin\_Guo](https://discuss.elastic.co/u/Robin_Guo)\
**Post date:** [March 1, 2017, 4:46am UTC](https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911/1 "2017-03-01T04:46:40Z")

</div>

Hi folks,  
🙂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](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"
```

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [March 1, 2017, 9:33am UTC](https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911/2 "2017-03-01T09:33:29Z")

</div>

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`?

---

<div class="post-metadata">

**Author:** ![Robin\_Guo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robin_guo/32/42297_2.png) [@Robin\_Guo](https://discuss.elastic.co/u/Robin_Guo)\
**Post date:** [March 2, 2017, 3:40am UTC](https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911/3 "2017-03-02T03:40:06Z")

</div>

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

**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](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"  
}

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [March 3, 2017, 12:23pm UTC](https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911/4 "2017-03-03T12:23:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Robin\_Guo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robin_guo/32/42297_2.png) [@Robin\_Guo](https://discuss.elastic.co/u/Robin_Guo)\
**Post date:** [March 4, 2017, 6:41am UTC](https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911/5 "2017-03-04T06:41:05Z")

</div>

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 ..

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [March 6, 2017, 2:39pm UTC](https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911/6 "2017-03-06T14:39:49Z")

</div>

That sounds like a bug ☹ 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.

---

<div class="post-metadata">

**Author:** ![Robin\_Guo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robin_guo/32/42297_2.png) [@Robin\_Guo](https://discuss.elastic.co/u/Robin_Guo)\
**Post date:** [March 7, 2017, 10:14am UTC](https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911/7 "2017-03-07T10:14:23Z")

</div>

> [@ruflin](#):
>
> nd nginx that didn't wo

sure, I'll do it soon.

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 4, 2017, 10:14am UTC](https://discuss.elastic.co/t/metricbeat-cant-collect-nginx-metrics/76911/8 "2017-04-04T10:14:36Z")

</div>

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