Skip to content

Commit

Permalink
add docker log source (enhanced pull request #125 from the original r…
Browse files Browse the repository at this point in the history
…epository); updated dependencies and upgraded Go version to 1.23.
  • Loading branch information
zubov committed Nov 2, 2024
1 parent 7422e87 commit aebf78b
Show file tree
Hide file tree
Showing 7 changed files with 377 additions and 82 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20
FROM golang:1.23

COPY . /work
WORKDIR /work
Expand Down
45 changes: 45 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ image:https://img.shields.io/badge/donate-PayPal-yellow[link="https://www.paypal

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

*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).*


[discrete]
== Contents

Expand Down Expand Up @@ -358,6 +361,48 @@ namespaces:
Advanced features
-----------------

### Reading from Docker logs
If Nginx is running in a docker container and is configured to log to `/dev/stdout` and `/dev/stderr` (this is the
default configuration of the official `nginx` image), then you can export logs using Docker's default logging driver.
To do this use a source configuration as follows:
[source,hcl]
----
namespace "test" {
source {
docker {
container = "nginx_container_name"
}
// ...
}
}
----
[source,yaml]
----
#...
namespaces:
- name: nginx
format: "format"
source:
docker:
container: nginx_container_name
#...
----
The host's docker socket needs to be mounted to the container. For example, if using the docker run command as follows:
[source]
----
$ docker run \
--name nginx-exporter \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /path/to/config.hcl:/etc/prometheus-nginxlog-exporter.hcl \
-p 4040:4040 \
quay.io/martinhelmich/prometheus-nginxlog-exporter \
-config-file /etc/prometheus-nginxlog-exporter.hcl \
----

### Namespace as labels

For historic reasons, this exporter exports separate metrics for different
Expand Down
67 changes: 45 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,50 +1,73 @@
module github.com/martin-helmich/prometheus-nginxlog-exporter

go 1.20
go 1.23

require (
github.com/hashicorp/consul/api v1.26.1
github.com/docker/docker v27.3.1+incompatible
github.com/hashicorp/consul/api v1.30.0
github.com/hashicorp/hcl v1.0.0
github.com/nxadm/tail v1.4.8
github.com/nxadm/tail v1.4.11
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/common v0.44.0
github.com/prometheus/client_golang v1.20.5
github.com/satyrius/gonx v1.4.0
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.24.0
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.27.0
golang.org/x/net v0.30.0
gopkg.in/mcuadros/go-syslog.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/smartystreets/goconvey v1.8.1 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/sys v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gotest.tools/v3 v3.5.1 // indirect
)
Loading

0 comments on commit aebf78b

Please # to comment.