1
0
mirror of https://github.com/nginxinc/nginx-prometheus-exporter.git synced 2025-07-30 10:03:04 +03:00

Add completions and manpages (#580)

This commit is contained in:
Luca Comellini
2023-12-27 06:51:54 -08:00
committed by GitHub
parent 93f17f47f0
commit 94f563d523
5 changed files with 32 additions and 4 deletions

3
.gitignore vendored
View File

@ -8,3 +8,6 @@
# the binary # the binary
nginx-prometheus-exporter nginx-prometheus-exporter
dist/ dist/
completions/
manpages/

View File

@ -1,3 +1,8 @@
before:
hooks:
- ./scripts/completions.sh
- ./scripts/manpages.sh
builds: builds:
- env: - env:
- CGO_ENABLED=0 - CGO_ENABLED=0
@ -38,6 +43,11 @@ archives:
- format_overrides: - format_overrides:
- goos: windows - goos: windows
format: zip format: zip
files:
- README.md
- LICENSE.md
- completions/*
- manpages/*
sboms: sboms:
- artifacts: archive - artifacts: archive
@ -53,11 +63,13 @@ brews:
homepage: https://www.nginx.com/ homepage: https://www.nginx.com/
description: NGINX Prometheus Exporter for NGINX and NGINX Plus description: NGINX Prometheus Exporter for NGINX and NGINX Plus
license: Apache-2.0 license: Apache-2.0
install: |
bin.install "nginx-prometheus-exporter"
commit_author: commit_author:
name: nginx-bot name: nginx-bot
email: integrations@nginx.com email: integrations@nginx.com
extra_install: |-
bash_completion.install "completions/nginx-prometheus-exporter.bash" => "nginx-prometheus-exporter"
zsh_completion.install "completions/nginx-prometheus-exporter.zsh" => "_nginx-prometheus-exporter"
man1.install "manpages/nginx-prometheus-exporter.1.gz"
signs: signs:
- cmd: cosign - cmd: cosign
@ -99,4 +111,5 @@ snapcrafts:
nginx-prometheus-exporter: nginx-prometheus-exporter:
command: nginx-prometheus-exporter command: nginx-prometheus-exporter
plugs: ["network", "network-bind"] plugs: ["network", "network-bind"]
completer: completions/nginx-prometheus-exporter.bash
disable: "{{ if .IsSnapshot }}true{{ end }}" disable: "{{ if .IsSnapshot }}true{{ end }}"

View File

@ -85,14 +85,14 @@ var (
webConfig = kingpinflag.AddFlags(kingpin.CommandLine, ":9113") webConfig = kingpinflag.AddFlags(kingpin.CommandLine, ":9113")
metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").Envar("TELEMETRY_PATH").String() metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").Envar("TELEMETRY_PATH").String()
nginxPlus = kingpin.Flag("nginx.plus", "Start the exporter for NGINX Plus. By default, the exporter is started for NGINX.").Default("false").Envar("NGINX_PLUS").Bool() nginxPlus = kingpin.Flag("nginx.plus", "Start the exporter for NGINX Plus. By default, the exporter is started for NGINX.").Default("false").Envar("NGINX_PLUS").Bool()
scrapeURIs = kingpin.Flag("nginx.scrape-uri", "A URI or unix domain socket path for scraping NGINX or NGINX Plus metrics. For NGINX, the stub_status page must be available through the URI. For NGINX Plus -- the API. Repeatable for multiple URIs.").Default("http://127.0.0.1:8080/stub_status").Strings() scrapeURIs = kingpin.Flag("nginx.scrape-uri", "A URI or unix domain socket path for scraping NGINX or NGINX Plus metrics. For NGINX, the stub_status page must be available through the URI. For NGINX Plus -- the API. Repeatable for multiple URIs.").Default("http://127.0.0.1:8080/stub_status").HintOptions("http://127.0.0.1:8080/stub_status", "http://127.0.0.1:8080/api").Strings()
sslVerify = kingpin.Flag("nginx.ssl-verify", "Perform SSL certificate verification.").Default("false").Envar("SSL_VERIFY").Bool() sslVerify = kingpin.Flag("nginx.ssl-verify", "Perform SSL certificate verification.").Default("false").Envar("SSL_VERIFY").Bool()
sslCaCert = kingpin.Flag("nginx.ssl-ca-cert", "Path to the PEM encoded CA certificate file used to validate the servers SSL certificate.").Default("").Envar("SSL_CA_CERT").String() sslCaCert = kingpin.Flag("nginx.ssl-ca-cert", "Path to the PEM encoded CA certificate file used to validate the servers SSL certificate.").Default("").Envar("SSL_CA_CERT").String()
sslClientCert = kingpin.Flag("nginx.ssl-client-cert", "Path to the PEM encoded client certificate file to use when connecting to the server.").Default("").Envar("SSL_CLIENT_CERT").String() sslClientCert = kingpin.Flag("nginx.ssl-client-cert", "Path to the PEM encoded client certificate file to use when connecting to the server.").Default("").Envar("SSL_CLIENT_CERT").String()
sslClientKey = kingpin.Flag("nginx.ssl-client-key", "Path to the PEM encoded client certificate key file to use when connecting to the server.").Default("").Envar("SSL_CLIENT_KEY").String() sslClientKey = kingpin.Flag("nginx.ssl-client-key", "Path to the PEM encoded client certificate key file to use when connecting to the server.").Default("").Envar("SSL_CLIENT_KEY").String()
// Custom command-line flags // Custom command-line flags
timeout = createPositiveDurationFlag(kingpin.Flag("nginx.timeout", "A timeout for scraping metrics from NGINX or NGINX Plus.").Default("5s").Envar("TIMEOUT")) timeout = createPositiveDurationFlag(kingpin.Flag("nginx.timeout", "A timeout for scraping metrics from NGINX or NGINX Plus.").Default("5s").Envar("TIMEOUT").HintOptions("5s", "10s", "30s", "1m", "5m"))
) )
const exporterName = "nginx_exporter" const exporterName = "nginx_exporter"

7
scripts/completions.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
set -e
rm -rf completions
mkdir completions
for shell in bash zsh; do
go run . --completion-script-$shell >completions/nginx-prometheus-exporter.$shell
done

5
scripts/manpages.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
set -e
rm -rf manpages
mkdir manpages
go run . --help-man | gzip -c -9 >manpages/nginx-prometheus-exporter.1.gz