Skip to content

Commit 5e79680

Browse files
authored
nginxlog_exporter: metrics from nginx access log (#911)
1 parent 45b8802 commit 5e79680

File tree

5 files changed

+107
-0
lines changed

5 files changed

+107
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DIST prometheus-nginxlog-exporter-1.11.0-deps.tar.xz 251260216 BLAKE2B f8b75c0255cbc5431c53080aefbb0201aa5e968a9e0b899a17e2feff4482ffe513a6a509d70e5a9b5a07a54efb7f89dfc6e8933bf7612b4de39e3bfc854057f5 SHA512 2d7a1c0916854dd84d7155a7759cc90403adb06db98cb840e95eca4e2e8d07cc29d25f88593b7259c13950e6f00ee7203ee7209286ea688f284febf270db8422
2+
DIST prometheus-nginxlog-exporter-1.11.0.tar.gz 51042 BLAKE2B 66b09a1753bb9aa7f6269600bd699ff057c5c9849792866b2c771fe27806357e85b6ad8ff7ad306e93a77105789df8ccce9747c56d013db7e189018d992686a9 SHA512 72720359f862ce8186e8ed7d2297197d998ffec48f076f8851e7166b3e6b3e95e6cfd0cef9afa6c18a6fb6712a9db6fb19624895569a301019c9e18d94fa9d15
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
listen {
2+
port = 4040
3+
address = "0.0.0.0"
4+
metrics_endpoint = "/metrics"
5+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/sbin/openrc-run
2+
# Copyright 2025 Gentoo Authors
3+
# Distributed under the terms of the GNU General Public License v2
4+
5+
name="prometheus-nginxlog-exporter daemon"
6+
description="Prometheus exporter for NGINX Log metrics."
7+
command="/usr/bin/prometheus-nginxlog-exporter"
8+
pidfile="/run/${RC_SVCNAME}.pid"
9+
output_log="/var/log/prometheus-nginxlog-exporter/prometheus-nginxlog-exporter.log"
10+
error_log="/var/log/prometheus-nginxlog-exporter/prometheus-nginxlog-exporter.log"
11+
command_background="yes"
12+
command_args="-config-file /etc/prometheus-nginxlog-exporter/config.hcl"
13+
command_user="${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx}:${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx}"
14+
15+
depend() {
16+
need net
17+
}
18+
19+
start_pre() {
20+
checkpath -d -m 0755 -o ${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx}:${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx} /var/log/prometheus-nginxlog-exporter
21+
checkpath -f -m 0644 -o ${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx}:${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx} "$output_log"
22+
checkpath -f -m 0644 -o ${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx}:${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx} "$error_log"
23+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
3+
<pkgmetadata>
4+
<maintainer type="person">
5+
<email>ops@adjust.com</email>
6+
<name>Adjust Ops</name>
7+
</maintainer>
8+
<upstream>
9+
<remote-id type="github">martin-helmich/prometheus-nginxlog-exporter</remote-id>
10+
</upstream>
11+
</pkgmetadata>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Copyright 2025 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=8
5+
6+
inherit go-module
7+
8+
# Project name and version
9+
DESCRIPTION="Prometheus NGINX log exporter"
10+
HOMEPAGE="https://github.com/martin-helmich/prometheus-nginxlog-exporter"
11+
SRC_URI="
12+
${HOMEPAGE}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
13+
https://files.adjust.com/${P}.tar.xz -> ${P}-deps.tar.xz
14+
"
15+
16+
LICENSE="Apache-2.0 license"
17+
KEYWORDS="~amd64"
18+
SLOT="0"
19+
IUSE="doc"
20+
21+
DEPEND="
22+
acct-group/nginx
23+
acct-user/nginx
24+
>=dev-lang/go-1.20
25+
"
26+
27+
RDEPEND="${DEPEND}"
28+
SRC_DIR="${WORKDIR}/${P}"
29+
30+
RESTRICT="network-sandbox"
31+
32+
src_unpack() {
33+
default
34+
}
35+
36+
src_prepare() {
37+
default
38+
}
39+
40+
src_compile() {
41+
export GOPATH="${SRC_DIR}"
42+
cd "${SRC_DIR}"
43+
ego build
44+
}
45+
46+
src_test() {
47+
cd "${SRC_DIR}"
48+
go test -v ./...
49+
}
50+
51+
src_install() {
52+
dobin "${PN}"
53+
54+
newinitd "${FILESDIR}/${PN}.initd" ${PN}
55+
dosym /etc/init.d/${PN} /etc/runlevels/default/${PN}
56+
57+
insinto /etc/${PN}
58+
doins "${FILESDIR}/config.hcl"
59+
60+
# Create log directory and file
61+
keepdir /var/log/${PN}
62+
63+
# Change ownership of the log file to nginx:nginx
64+
fowners ${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx}:${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx} /var/log/${PN}
65+
fowners ${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx}:${PROMETHEUS_NGINXLOG_EXPORTER_USER:-nginx} /etc/${PN}/config.hcl
66+
}

0 commit comments

Comments
 (0)