Nginx service discovery to use with Prometheus and the Blackbox Exporter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.9 KiB

Nginx site discovery

This repo provides a tool to use as both a service discovery sidecar for Prometheus and a discovery agent. The tool watches Nginx configuration file for changes and either write the service discovery file to the provided path or send it to a server for centralisation.

To disable a single website from being scraped append # ignore after the listen directive.

listen; # ignore

Command line usage

usage: nginx-sites-discovery [-h] [-l [LABELS [LABELS ...]]] [-s [LISTEN]] [-o OUTPUT_FILE] [-d OUTPUT_DIR] [-u SERVER_URL] [-e SITES_ENABLED] [-n] [-x EXTENSION]

Watch Nginx configuration to create files for service discovery

optional arguments:
  -h, --help            show this help message and exit
  -l [LABELS [LABELS ...]], --labels [LABELS [LABELS ...]]
                        Optional, extra labels to add to the jobs in the format key=value
  -s [LISTEN], --listen [LISTEN]
                        Optional, tart a web server to listen for discovery files, if no listening address is provided the default is
  -o OUTPUT_FILE, --output-file OUTPUT_FILE
                        Optional, output the discovery file to the provided path
  -d OUTPUT_DIR, --output-dir OUTPUT_DIR
                        Only valid with --listen, the directory in wich the files are dumped, default to current working directory
  -u SERVER_URL, --server-url SERVER_URL
                        Optional, post the discovery file to the provided url, should be https://<server>/<service name>/<key>.
  -e SITES_ENABLED, --sites-enabled SITES_ENABLED
                        Path to the Nginx configuration file directory, default to /etc/nginx/sites-enabled
  -n, --no-watch        Disable watching, useful for the server only mode
  -x EXTENSION, --extension EXTENSION
                        Configuration file extension, default to empty string