Skip to content

Commit

Permalink
Merge pull request #110 from martin-helmich/feature/build-pkgs
Browse files Browse the repository at this point in the history
Include DEB+RPM package in release
  • Loading branch information
martin-helmich authored Apr 26, 2020
2 parents 78a506a + e12f46a commit 486415f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
17 changes: 17 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,20 @@ dockers:
- prometheus-nginxlog-exporter
goos: linux
goarch: amd64
nfpms:
- vendor: Martin Helmich
homepage: https://github.com/martin-helmich/prometheus-nginxlog-exporter
description: Export Prometheus metrics from NGINX (or compatible) log files
license: Apache 2.0
formats:
- deb
- rpm
dependencies:
- systemd
bindir: /usr/sbin
files:
res/package/prometheus-nginxlog-exporter.service: /lib/systemd/system/prometheus-nginxlog-exporter.service
config_files:
res/package/default-config.hcl: /etc/prometheus-nginxlog-exporter.hcl
scripts:
postinstall: res/package/scripts/postinstall.sh
31 changes: 25 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ image:https://img.shields.io/github/workflow/status/martin-helmich/prometheus-ng
image:https://quay.io/repository/martinhelmich/prometheus-nginxlog-exporter/status[link="https://quay.io/repository/martinhelmich/prometheus-nginxlog-exporter",Docker Repository on Quay]
image:https://goreportcard.com/badge/github.com/martin-helmich/prometheus-nginxlog-exporter[link="https://goreportcard.com/report/github.com/martin-helmich/prometheus-nginxlog-exporter", Go Report Card]
image:https://img.shields.io/github/license/martin-helmich/prometheus-nginxlog-exporter[GitHub]
image:https://img.shields.io/badge/donate-PayPal-yellow[link="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SEARYHPVS9U5N&source=url", Donate]

Helper tool that continuously reads an NGINX log file and exports metrics to https://prometheus.io/[Prometheus].

Expand Down Expand Up @@ -289,18 +290,36 @@ relabel "request_uri" {
}
----

Running the collector
---------------------
Installing & running the collector
----------------------------------
### DEB/RPM packages
In the https://github.com/martin-helmich/prometheus-nginxlog-exporter/releases[releases section],
you can find both DEB and RPM packages for download. These come with a dependency on systemd and
configure the exporter to be running automatically:
$ wget https://github.com/martin-helmich/prometheus-nginxlog-exporter/releases/download/v1.5.0/prometheus-nginxlog-exporter_v1.5.0_linux_amd64.deb
$ apt install ./prometheus-nginxlog-exporter_v1.5.0_linux_amd64.deb
The packages drop a configuration file to `/etc/prometheus-nginxlog-exporter.hcl` which you can
adjust to your own needs.
### Systemd
### Manual installation, with systemd
You can find an example unit file for this service https://github.com/martin-helmich/prometheus-nginxlog-exporter/blob/master/systemd/prometheus-nginxlog-exporter.service[in this repository]. Simply copy the unit file to `/etc/systemd/system`:
If you do not want to use one of the pre-built packages, you can download the binary itself and
manually configure systemd to start it. You can find an example unit file for this service
https://github.com/martin-helmich/prometheus-nginxlog-exporter/blob/master/res/package/prometheus-nginxlog-exporter.service[in this repository].
Simply copy the unit file to `/etc/systemd/system`:
$ wget -O /etc/systemd/system/prometheus-nginxlog-exporter.service https://raw.githubusercontent.com/martin-helmich/prometheus-nginxlog-exporter/master/systemd/prometheus-nginxlog-exporter.service
$ wget -O /etc/systemd/system/prometheus-nginxlog-exporter.service https://raw.githubusercontent.com/martin-helmich/prometheus-nginxlog-exporter/master/res/package/prometheus-nginxlog-exporter.service
$ systemctl enable prometheus-nginxlog-exporter
$ systemctl start prometheus-nginxlog-exporter
The shipped unit file expects the binary to be located in `/usr/local/bin/prometheus-nginxlog-exporter` and the configuration file in `/etc/prometheus-nginxlog-exporter.hcl`. Adjust to your own needs.
The shipped unit file expects the binary to be located in `/usr/sbin/prometheus-nginxlog-exporter`
(if you sideload the exporter without using your package manager, you might want to put it to
`/usr/local`, instead) and the configuration file in `/etc/prometheus-nginxlog-exporter.hcl`. Adjust
to your own needs.
### Docker
Expand Down
17 changes: 17 additions & 0 deletions res/package/default-config.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
listen {
port = 4040
}

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

format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""

labels {
app = "default"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description=NGINX metrics exporter for Prometheus
After=network-online.target

[Service]
ExecStart=/usr/local/bin/prometheus-nginxlog-exporter -config-file /etc/prometheus-nginxlog-exporter.hcl
ExecStart=/usr/sbin/prometheus-nginxlog-exporter -config-file /etc/prometheus-nginxlog-exporter.hcl
Restart=always
ProtectSystem=full
CapabilityBoundingSet=
Expand Down
4 changes: 4 additions & 0 deletions res/package/scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

systemctl daemon-reload
systemctl enable prometheus-nginxlog-exporter

0 comments on commit 486415f

Please sign in to comment.