Nginx k8s metrics

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

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 or prometheus module?

@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

Thank you for posting your solution with sample configs!

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

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.

@aokhotnikov hi,

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

regards flo