mirror of
https://github.com/netbox-community/netbox-docker.git
synced 2025-06-26 21:01:55 +02:00
Created Monitoring (markdown)
parent
fd2eda9bcf
commit
8decdc2644
134
Monitoring.md
Normal file
134
Monitoring.md
Normal file
@ -0,0 +1,134 @@
|
||||
**IMPORTANT: These features require Netbox Docker v0.25.0 or later, which is – at the time of writing – not yet released.**
|
||||
|
||||
## Setup
|
||||
|
||||
Add the following to your `docker-compose.override.yml` (or create that file if you haven't done so):
|
||||
|
||||
```yml
|
||||
version: '3.4'
|
||||
services:
|
||||
# netbox
|
||||
netbox:
|
||||
environment:
|
||||
METRICS_ENABLED: true
|
||||
volumes:
|
||||
- type: tmpfs
|
||||
target: /tmp/metrics
|
||||
read_only: false
|
||||
|
||||
# nginx
|
||||
nginx-exporter:
|
||||
image: nginx/nginx-prometheus-exporter
|
||||
depends_on:
|
||||
- nginx
|
||||
command:
|
||||
- -nginx.scrape-uri
|
||||
- http://nginx:8081/stub_status
|
||||
|
||||
# postgres
|
||||
postgres-exporter:
|
||||
image: wrouesnel/postgres_exporter:v0.8.0
|
||||
depends_on:
|
||||
- postgres
|
||||
environment:
|
||||
DATA_SOURCE_URI: postgres?sslmode=disable
|
||||
DATA_SOURCE_USER: netbox
|
||||
DATA_SOURCE_PASS: J5brHrAXFLQSif0K
|
||||
PG_EXPORTER_AUTO_DISCOVER_DATABASES: true
|
||||
|
||||
# redis
|
||||
redis-worker-exporter:
|
||||
image: oliver006/redis_exporter
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
REDIS_ADDR: redis://redis:6379
|
||||
REDIS_PASSWORD: H733Kdjndks81
|
||||
redis-cache-exporter:
|
||||
image: oliver006/redis_exporter
|
||||
depends_on:
|
||||
- redis-cache
|
||||
environment:
|
||||
REDIS_ADDR: redis://redis-cache:6379
|
||||
REDIS_PASSWORD: t4Ph722qJ5QHeQ1qfu36
|
||||
|
||||
# prometheus
|
||||
prometheus:
|
||||
image: prom/prometheus:v2.22.0
|
||||
depends_on:
|
||||
- postgres-exporter
|
||||
- redis-cache-exporter
|
||||
- redis-worker-exporter
|
||||
- nginx-exporter
|
||||
- netbox
|
||||
ports:
|
||||
- '9090:9090'
|
||||
volumes:
|
||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus-data:/prometheus/data
|
||||
|
||||
# grafana
|
||||
grafana:
|
||||
image: grafana/grafana:7.2.1
|
||||
depends_on:
|
||||
- prometheus
|
||||
environment:
|
||||
GF_SECURITY_ADMIN_USER: admin
|
||||
GF_SECURITY_ADMIN_PASSWORD: admin
|
||||
GF_SECURITY_SECRET_KEY: oew5RCBGGBba0MdsEKrj
|
||||
ports:
|
||||
- '3000:3000'
|
||||
volumes:
|
||||
#- ./monitoring/grafana/plugins/:/var/lib/grafana/plugins/:z,ro
|
||||
#- ./monitoring/grafana/provisioning/:/etc/grafana/provisioning/:z,ro
|
||||
#- ./monitoring/grafana/dashboards/:/etc/grafana/dashboards/:z,ro
|
||||
- grafana-data:/var/lib/grafana
|
||||
|
||||
volumes:
|
||||
prometheus-data:
|
||||
driver: local
|
||||
grafana-data:
|
||||
driver: local
|
||||
```
|
||||
|
||||
Then create the new file `prometheus.yml`:
|
||||
|
||||
```yml
|
||||
scrape_configs:
|
||||
- job_name: prometheus
|
||||
static_configs:
|
||||
- targets: ['localhost:9090']
|
||||
|
||||
- job_name: netbox
|
||||
static_configs:
|
||||
- targets: ['netbox:8001']
|
||||
|
||||
- job_name: nginx
|
||||
static_configs:
|
||||
- targets: ['nginx-exporter:9113']
|
||||
|
||||
- job_name: postgresql
|
||||
static_configs:
|
||||
- targets: ['postgres-exporter:9187']
|
||||
|
||||
- job_name: redis
|
||||
static_configs:
|
||||
- targets: ['redis-worker-exporter:9121', 'redis-cache-exporter:9121']
|
||||
```
|
||||
|
||||
Then run `docker-compose up`.
|
||||
|
||||
## Prometheus
|
||||
|
||||
Prometheus grabs the data once every minute from each service (Netbox, Nginx, PostgreSQL, 2x Redis, Prometheus itself) and stores it in a [TSDB](https://en.wikipedia.org/wiki/Time_series_database).
|
||||
You can access [Prometheus on port 9090](http://localhost:9090).
|
||||
|
||||
## Grafana
|
||||
|
||||
Grafana provides visualization of the data, which can be composed into dashboard.
|
||||
To fetch the data it talks directly to the Prometheus service.
|
||||
You can access [Grafana on port 3000](http://localhost:3000).
|
||||
|
||||
You will find several user-made [dashboards on the Grafana page](https://grafana.com/grafana/dashboards?dataSource=prometheus) which are easy to import using the Grafana Dashboard ID.
|
||||
There are already dashboard for Nginx, PostgreSQL, Redis, Prometheus and also Django (which is the framework on which Netbox is built).
|
||||
For more information see the [_importing a dashboard_ and _discover dashboards on grafana.com_ articles](https://grafana.com/docs/grafana/latest/dashboards/export-import/#importing-a-dashboard).
|
Loading…
x
Reference in New Issue
Block a user