Coder Social home page Coder Social logo

Comments (3)

 avatar commented on August 12, 2024 2

The problem was that when starting the container, monitoring was done in a directory inside the container
-v /var/log/nginx:/mnt/nginxlogs

which differs from the directory specified in the exporter configuration file
/etc/prometheus-nginxlog-exporter.hcl

source = {
	files = [
	  "/var/log/nginx/access.log"
	]
}

That is, the correct command to launch the container and mount the folder with logs should be

$ docker run -d --name nginxlog-exporter -p 4040:4040 -v /var/log/nginx:/var/log/nginx -v /etc/prometheus-nginxlog-exporter.hcl:/etc/prometheus-nginxlog-exporter.hcl quay.io/martinhelmich/prometheus-nginxlog-exporter -config-file /etc/prometheus-nginxlog-exporter.hcl

This is why there were entries in the container log that the exporter is waiting for files to appear

2023-10-24T13:36:17.146Z info [email protected]/tail.go:212 Waiting for /var/log/nginx/access.log to appear...
2023-10-24T13:36:17.146Z info [email protected]/tail.go:212 Waiting for /var/log/nginx/access_itscript.ru.log to appear.

Please add this to the documentation!

from prometheus-nginxlog-exporter.

martin-helmich avatar martin-helmich commented on August 12, 2024 1

Looks like the log format configured in your exporter configuration doesn't match the actual log files; pay attention to the double quotes and the additional fields at the end of the log lines.

Hope that helps!

from prometheus-nginxlog-exporter.

 avatar commented on August 12, 2024

Looks like the log format configured in your exporter configuration doesn't match the actual log files; pay attention to the double quotes and the additional fields at the end of the log lines.

Hope that helps!

Adjusted the log format in the prometheus-nginxlog-exporter.hcl config to match the format specified in /etc/nginx/nginx.conf

/etc/nginx/nginx.conf

log_format upstream_time '$remote_addr - $remote_user [$time_local] '
					 '"$request" $status $body_bytes_sent '
					 '"$http_referer" "$http_user_agent" '
					 'rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"';

/etc/prometheus/prometheus-nginxlog-exporter.hcl

format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" rt=$request_time uct=\"$upstream_connect_time\" uht=\"$upstream_header_time\" urt=\"$upstream_response_time\""

The log is written like this:

85.354.777.7 - - [24/Oct/2023:16:37:09 +0300] "GET / HTTP/1.1" 200 163 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36" rt=0.001 uct="0.000" uht="0.000" urt="0.000"

I restarted NGINX and the prometheus-nginxlog-exporter container, but it didn’t last long...

in the container log

2023-10-24T13:36:16.760Z info prometheus-nginxlog-exporter/main.go:101 caught term terminated. exiting
2023-10-24T13:36:17.144Z info prometheus-nginxlog-exporter/main.go:162 loading configuration file /etc/prometheus-nginxlog-exporter.hcl
2023-10-24T13:36:17.145Z warn config/struct_namespace.go:98 No globs for /var/log/nginx/access.log
2023-10-24T13:36:17.145Z warn config/struct_namespace.go:98 No globs for /var/log/nginx/access_itscript.ru.log
2023-10-24T13:36:17.145Z info prometheus-nginxlog-exporter/main.go:139 starting listener for namespace all
2023-10-24T13:36:17.145Z info prometheus-nginxlog-exporter/main.go:139 starting listener for namespace itscript.ru
2023-10-24T13:36:17.145Z info prometheus-nginxlog-exporter/main.go:148 running HTTP server on address 0.0.0.0:4040, serving metrics at /metrics
2023-10-24T13:36:17.146Z info [email protected]/tail.go:212 Waiting for /var/log/nginx/access.log to appear...
2023-10-24T13:36:17.146Z info [email protected]/tail.go:212 Waiting for /var/log/nginx/access_itscript.ru.log to appear.

from prometheus-nginxlog-exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.