# Nginx k8s metrics

**URL:** <https://discuss.elastic.co/t/nginx-k8s-metrics/128690>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [April 19, 2018, 11:49am UTC](https://discuss.elastic.co/t/nginx-k8s-metrics/128690 "2018-04-19T11:49:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aokhotnikov](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@aokhotnikov](https://discuss.elastic.co/u/aokhotnikov)\
**Post date:** [April 19, 2018, 11:49am UTC](https://discuss.elastic.co/t/nginx-k8s-metrics/128690/1 "2018-04-19T11:49:34Z")

</div>

Hi

Is there some option to configure metricbeat for collecting nginx-ingress metrics/stats installed on k8s. AFAIK nginx module just parses stub\_status response. Nginx can ship metrics in prometheus format or in json.

Env:  
nginx: 1.13.9  
metricbeat: 6.2.3

I can't upload here json example.

Thank you

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [April 20, 2018, 10:43am UTC](https://discuss.elastic.co/t/nginx-k8s-metrics/128690/2 "2018-04-20T10:43:53Z")

</div>

The nginx module only implement stub\_status metricset. Prometheus and json (via http) are more generic protocols. Have you had a look at the [http](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-http.html) or [prometheus](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-prometheus.html) module?

---

<div class="post-metadata">

**Author:** ![aokhotnikov](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@aokhotnikov](https://discuss.elastic.co/u/aokhotnikov)\
**Post date:** [April 20, 2018, 11:28am UTC](https://discuss.elastic.co/t/nginx-k8s-metrics/128690/3 "2018-04-20T11:28:20Z")

</div>

@steffens

Thanks. Didn't know about that.

For those who questoned:

http module:

```
- module: http
  metricsets: ["json"]
  period: 10s
  hosts: ["nginx-ingress-controller-stats:18080"]
  namespace: "nginx"
  path: "/nginx_status/format/json"

```

or

```
- module: prometheus
  metricsets: ["collector"]
  period: 10s
  hosts: ["nginx-ingress-controller-metrics:9913"]
  metrics_path: /metrics
  namespace: nginx

```

nginx should be run with

```
--set controller.stats.enabled=true \
--set controller.metrics.enabled=true
```

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [April 20, 2018, 1:15pm UTC](https://discuss.elastic.co/t/nginx-k8s-metrics/128690/4 "2018-04-20T13:15:51Z")

</div>

Thank you for posting your solution with sample configs!

---

<div class="post-metadata">

**Author:** ![\_flo](https://avatars.discourse-cdn.com/v4/letter/_/f17d59/32.png) [@\_flo](https://discuss.elastic.co/u/_flo)\
**Post date:** [April 21, 2018, 5:03pm UTC](https://discuss.elastic.co/t/nginx-k8s-metrics/128690/5 "2018-04-21T17:03:52Z")

</div>

Hi,

do you have only one nginx instance running?  
I think the http / promethues collector needs an endpoint for each nginx instance.  
Or can metricbeat discover te endpoints?

regards flo

---

<div class="post-metadata">

**Author:** ![aokhotnikov](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@aokhotnikov](https://discuss.elastic.co/u/aokhotnikov)\
**Post date:** [April 21, 2018, 7:12pm UTC](https://discuss.elastic.co/t/nginx-k8s-metrics/128690/6 "2018-04-21T19:12:48Z")

</div>

Hi, @_flo

I have one pod of nginx-controller, but as you said there is endpoint for nginx-controller (stats and metrics too) and it points to all nginx-controller pods. So all you need is to place metricbeat in the same namespace as nginx or create your own service in metricbeat namespace. But i don't know how metrics is collected from multiple instance of nginx-controller pods.

---

<div class="post-metadata">

**Author:** ![\_flo](https://avatars.discourse-cdn.com/v4/letter/_/f17d59/32.png) [@\_flo](https://discuss.elastic.co/u/_flo)\
**Post date:** [April 22, 2018, 6:40am UTC](https://discuss.elastic.co/t/nginx-k8s-metrics/128690/7 "2018-04-22T06:40:53Z")

</div>

@aokhotnikov hi,

thx for the info, so then the easy way is to run the metricbeat in each nginx pod.

regards flo

---

<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:** [May 20, 2018, 8:41am UTC](https://discuss.elastic.co/t/nginx-k8s-metrics/128690/8 "2018-05-20T08:41:46Z")

</div>

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