Comments (3)
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.
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.
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)
- no metrics but all nginx log parameters appear HOT 1
- join two labells HOT 1
- RPM package start,Memory continues to grow and never stops
- 404 error at startup HOT 2
- error while parsing $upstream_response_time: value '"0.001"' could not be parsed into float HOT 1
- Add `unmatch` for the `relabel` processor. HOT 2
- Metrics persistence HOT 4
- Unable to parse logs with common log format HOT 2
- Unable to open file /var/log/nginx/access.log: open /var/log/nginx/access.log: permission denied HOT 4
- Expose metrics using https
- Missing metrics
- match replacement rule is incorrect.
- not working HOT 1
- could not be parsed into float HOT 1
- Something wrong with relabel match regexp | not working in some cases
- prometheus-nginxlog-exporter made wrong regex for given format
- example json pasrsing HOT 1
- Relabel from path
- cannot read file nginxlog-exporter.conf
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prometheus-nginxlog-exporter.