Shreyas Damle
Shreyas Damle

Reputation: 11

How to write prometheus exporter to capture http request metrics for my application for prometheus

I would like to write Prometheus exporter to gather HTTP request metrics for my application. The constraint is, I neither want to add any code to my app nor do I want to add any web server specific code i.e. apache or nginx. Is there any way that can work for the configured web server(either Apache or Nginx). I would like to use this exporter to send data to my Prometheus instance.

Upvotes: 1

Views: 3559

Answers (1)

anemyte
anemyte

Reputation: 20306

Two options for NGINX:

  1. Write access log, use prometheus-nginxlog-exporter or a custom exporter to parse lines.
  2. (If you use OpenResty or built NGINX with Lua module) - use NGINX lua module for Prometheus.

I personally use a self-written exporter and parse JSON log lines, but I plan to switch to Lua. The reason is that using logs has some reliability issues (file access problems, rotation, etc) and it can make the web server configuration messy.

Also, NGINX ingress controller has its own implementation of Prometheus metrics. You may want to take a hint or two from it.

Upvotes: 3

Related Questions