Analyze Nginx Proxy Manager logs and send metrics to InfluxDB.
Currently, it sends:
domainschemeipcitycountrylatitudelongitude
As Nginx Proxy Manager is only shipped trough docker, the better option to use this monitor is to use docker too. However, it can be used directly.
This monitor use a cache system to avoid reading full log files each time it is started, and protect back to the future log entry.
A yaml configuration file and/or environment variables can be use. Configuration is read first, then environment variables may override values.
logs: # NPM logs section
dir: '' # Path to NPM logs directory
domain_rx: '' # Regex to filter domain and sub-domains
cache: # NPM-Monitor cache section
dir: '' # Path to cache directory
maxmind: # MaxMind section
id: '' # User ID for querying GeoIP trough Web API
pk: '' # User PrivateKey for querying GeoIP trough Web API
db: '' # Path to MaxMind city database
prefer_db: False # Use local database instead of Web API
influxdb: # InfluxDB section
host: '' # Host
token: '' # Token
org: '' # Organization
bucket: '' # Bucket to send metricsEnvironment variables follows YAML schema with this logic: NPMMON_<section>_<key>.
So this gives:
NPMMON_LOGS_DIRNPMMON_LOGS_DOMAIN_RXNPMMON_CACHE_DIRNPMMON_MAXMIND_IDNPMMON_MAXMIND_PKNPMMON_MAXMIND_DBNPMMON_MAXMIND_PREFER_DBNPMMON_INFLUXDB_HOSTNPMMON_INFLUXDB_TOKENNPMMON_INFLUXDB_ORGNPMMON_INFLUXDB_BUCKET
Docker image is available by using alptj/npm-mon.
In addition to previous environment variables, NPMMON_CONFIG is available to set configuration file path.
Two volumes are available:
/npmmon/cache: Where monitoring cache files are stored./npmmon/logs: Where NPM logs should be found.
Default configuration sets NPMMON_CACHE_DIR to /npmmon/cache and NPMMON_LOGS_DIR to /npmmon/logs/logs (because default npm image use a global volume for data).
jc21/nginx-proxy-manager container is reduced to bare minimal for illustration
version: '3.6'
services:
app:
image: jc21/nginx-proxy-manager
ports:
- '443:443'
- '81:81'
volumes:
- data:/data
mon:
image: alptj/npm-mon
environment:
NPMMON_LOGS_DOMAIN_RX: '\w+\.example\.org'
NPMMON_MAXMIND_DB: /npmmon/GeoLite2-City.mmdb
NPMMON_MAXMIND_PREFER_DB: 'True'
NPMMON_INFLUXDB_HOST: influx.mylocal.lan
NPMMON_INFLUXDB_TOKEN: abcdef
NPMMON_INFLUXDB_ORG: mylocal
NPMMON_INFLUXDB_BUCKET: npmmon
volumes:
- data:/npmmon/logs:ro
- moncache:/npmmon/cache
- ./GeoLite2-City.mmdb:/npmmon/GeoLite2-City.mmdb
volumes:
data:
moncache:- Add Grafana example