Telegraf is not reading Nginx access log file data on nginx 1.20

Hello guys. I’m studying about telegraf passing the data to prometheus and displaying the data in grafana. The nginx log is not passing through telegraf.
My telegraf.conf:

[[inputs.nginx]]
   urls = ["http://localhost/nginx_status"]
   response_timeout = "5s"
[[inputs.tail]]
  name_override = "nginxlog"
  files = ["/var/log/nginx/access.log"]
  from_beginning = true
  pipe = false
  data_format = "grok"
  grok_patterns = ["%{COMBINED_LOG_FORMAT}"]
[[inputs.cpu]]
  percpu = true
[[inputs.disk]]
[[inputs.diskio]]
[[inputs.io]]
[[inputs.net]]
[[inputs.mem]]
[[inputs.system]]

This code is working on nginx(1.18.0 - ubuntu), but on nginx(1.20.1 - centos) it doesn’t. I need you to pass this log to perform the metrics in grafana.

nginxlog_http_version{agent="Go-http-client/1.1",auth="-",client_ip="127.0.0.1",host="ubuntu",ident="-",path="/var/log/nginx/access.log",referrer="-",request="/nginx_status",resp_code="200",verb="GET"} 1.1

nginxlog_resp_bytes{agent="Go-http-client/1.1",auth="-",client_ip="127.0.0.1",host="ubuntu",ident="-",path="/var/log/nginx/access.log",referrer="-",request="/nginx_status",resp_code="200",verb="GET"} 101

Can you help me?

This code is working on nginx(1.18.0 - ubuntu), but on nginx(1.20.1 - centos)

What is not working? Are you getting an error message or are metrics just missing?

Centos is not working. No error shows in the telegraf log.
Telegraf is not reading Nginx access log file data.

Telegraf is not reading Nginx access log file data.

How do you know this? Are there any logs or data you can share with us to help you? Are you not seeing data in your output?

Have you tried using the [[outputs.file]] and only the tail input and see what metrics are coming in?

Can you run Telegraf with --debug to see what metrics it is capturing?

If the two log lines are the ones you are trying to parse, I don’t see how they can match with the grok COMBINED_LOG_FORMAT (which is an extension of COMMON_LOG_FORMAT)

for reference, this is what COMMON_LOG_FORMAT looks like

127.0.0.1 user-identifier frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326

The two lines you shared look like JSON, if that’s the case use the JSON format… otherwise you will have to write your own grok pattern (which is not easy, but the docs have or link almost all you need)