Skip to content

Commit aebf78b

Browse files
author
zubov
committed
add docker log source (enhanced pull request martin-helmich#125 from the original repository); updated dependencies and upgraded Go version to 1.23.
1 parent 7422e87 commit aebf78b

File tree

7 files changed

+377
-82
lines changed

7 files changed

+377
-82
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.20
1+
FROM golang:1.23
22

33
COPY . /work
44
WORKDIR /work

README.adoc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ image:https://img.shields.io/badge/donate-PayPal-yellow[link="https://www.paypal
1616

1717
Helper tool that continuously reads an NGINX log file (or any kind of similar log file) and exports metrics to https://prometheus.io/[Prometheus].
1818

19+
*Added the ability to export logs from Docker (enhanced pull request https://github.com/martin-helmich/prometheus-nginxlog-exporter/pull/125[#125] from the original repository).*
20+
21+
1922
[discrete]
2023
== Contents
2124

@@ -358,6 +361,48 @@ namespaces:
358361
359362
Advanced features
360363
-----------------
364+
365+
### Reading from Docker logs
366+
If Nginx is running in a docker container and is configured to log to `/dev/stdout` and `/dev/stderr` (this is the
367+
default configuration of the official `nginx` image), then you can export logs using Docker's default logging driver.
368+
To do this use a source configuration as follows:
369+
[source,hcl]
370+
----
371+
namespace "test" {
372+
source {
373+
docker {
374+
container = "nginx_container_name"
375+
}
376+
377+
// ...
378+
}
379+
}
380+
----
381+
[source,yaml]
382+
----
383+
#...
384+
385+
namespaces:
386+
- name: nginx
387+
format: "format"
388+
source:
389+
docker:
390+
container: nginx_container_name
391+
392+
#...
393+
----
394+
The host's docker socket needs to be mounted to the container. For example, if using the docker run command as follows:
395+
[source]
396+
----
397+
$ docker run \
398+
--name nginx-exporter \
399+
-v /var/run/docker.sock:/var/run/docker.sock \
400+
-v /path/to/config.hcl:/etc/prometheus-nginxlog-exporter.hcl \
401+
-p 4040:4040 \
402+
quay.io/martinhelmich/prometheus-nginxlog-exporter \
403+
-config-file /etc/prometheus-nginxlog-exporter.hcl \
404+
----
405+
361406
### Namespace as labels
362407

363408
For historic reasons, this exporter exports separate metrics for different

go.mod

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,73 @@
11
module github.com/martin-helmich/prometheus-nginxlog-exporter
22

3-
go 1.20
3+
go 1.23
44

55
require (
6-
github.com/hashicorp/consul/api v1.26.1
6+
github.com/docker/docker v27.3.1+incompatible
7+
github.com/hashicorp/consul/api v1.30.0
78
github.com/hashicorp/hcl v1.0.0
8-
github.com/nxadm/tail v1.4.8
9+
github.com/nxadm/tail v1.4.11
910
github.com/pkg/errors v0.9.1
10-
github.com/prometheus/client_golang v1.17.0
11-
github.com/prometheus/common v0.44.0
11+
github.com/prometheus/client_golang v1.20.5
1212
github.com/satyrius/gonx v1.4.0
13-
github.com/stretchr/testify v1.8.4
14-
go.uber.org/zap v1.24.0
13+
github.com/stretchr/testify v1.9.0
14+
go.uber.org/zap v1.27.0
15+
golang.org/x/net v0.30.0
1516
gopkg.in/mcuadros/go-syslog.v2 v2.3.0
1617
gopkg.in/yaml.v3 v3.0.1
1718
)
1819

1920
require (
21+
github.com/Microsoft/go-winio v0.6.2 // indirect
2022
github.com/armon/go-metrics v0.4.1 // indirect
2123
github.com/beorn7/perks v1.0.1 // indirect
22-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
24+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
25+
github.com/containerd/log v0.1.0 // indirect
2326
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
24-
github.com/fatih/color v1.14.1 // indirect
25-
github.com/fsnotify/fsnotify v1.4.9 // indirect
26-
github.com/golang/protobuf v1.5.3 // indirect
27+
github.com/distribution/reference v0.6.0 // indirect
28+
github.com/docker/go-connections v0.5.0 // indirect
29+
github.com/docker/go-units v0.5.0 // indirect
30+
github.com/fatih/color v1.18.0 // indirect
31+
github.com/felixge/httpsnoop v1.0.4 // indirect
32+
github.com/fsnotify/fsnotify v1.8.0 // indirect
33+
github.com/go-logr/logr v1.4.2 // indirect
34+
github.com/go-logr/stdr v1.2.2 // indirect
35+
github.com/gogo/protobuf v1.3.2 // indirect
2736
github.com/hashicorp/errwrap v1.1.0 // indirect
2837
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
29-
github.com/hashicorp/go-hclog v1.5.0 // indirect
38+
github.com/hashicorp/go-hclog v1.6.3 // indirect
3039
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
3140
github.com/hashicorp/go-multierror v1.1.1 // indirect
3241
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
33-
github.com/hashicorp/golang-lru v0.5.4 // indirect
42+
github.com/hashicorp/golang-lru v1.0.2 // indirect
3443
github.com/hashicorp/serf v0.10.1 // indirect
44+
github.com/klauspost/compress v1.17.11 // indirect
3545
github.com/mattn/go-colorable v0.1.13 // indirect
36-
github.com/mattn/go-isatty v0.0.17 // indirect
37-
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
46+
github.com/mattn/go-isatty v0.0.20 // indirect
3847
github.com/mitchellh/go-homedir v1.1.0 // indirect
3948
github.com/mitchellh/mapstructure v1.5.0 // indirect
49+
github.com/moby/docker-image-spec v1.3.1 // indirect
50+
github.com/moby/term v0.5.0 // indirect
51+
github.com/morikuni/aec v1.0.0 // indirect
52+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
53+
github.com/opencontainers/go-digest v1.0.0 // indirect
54+
github.com/opencontainers/image-spec v1.1.0 // indirect
4055
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
41-
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
42-
github.com/prometheus/procfs v0.11.1 // indirect
56+
github.com/prometheus/client_model v0.6.1 // indirect
57+
github.com/prometheus/common v0.60.1 // indirect
58+
github.com/prometheus/procfs v0.15.1 // indirect
4359
github.com/smartystreets/goconvey v1.8.1 // indirect
44-
go.uber.org/atomic v1.7.0 // indirect
45-
go.uber.org/multierr v1.6.0 // indirect
46-
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
47-
golang.org/x/sys v0.13.0 // indirect
48-
google.golang.org/protobuf v1.31.0 // indirect
60+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
61+
go.opentelemetry.io/otel v1.31.0 // indirect
62+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 // indirect
63+
go.opentelemetry.io/otel/metric v1.31.0 // indirect
64+
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
65+
go.opentelemetry.io/otel/trace v1.31.0 // indirect
66+
go.uber.org/multierr v1.11.0 // indirect
67+
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
68+
golang.org/x/sys v0.26.0 // indirect
69+
golang.org/x/time v0.7.0 // indirect
70+
google.golang.org/protobuf v1.35.1 // indirect
4971
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
72+
gotest.tools/v3 v3.5.1 // indirect
5073
)

0 commit comments

Comments
 (0)