Refactoring the directory structure and added the ability to run with docker-compose

This commit is contained in:
IgorKha 2021-10-08 03:03:16 +03:00
parent 7aba11db31
commit ef3aab6cdb
No known key found for this signature in database
GPG key ID: F283C5AB2D59E902
8 changed files with 7884 additions and 5 deletions

2
.env Normal file
View file

@ -0,0 +1,2 @@
GF_ADMIN_USER=admin
GF_ADMIN_PASSWORD=mikrotik

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
prometheus/data/*

View file

@ -8,6 +8,21 @@ Grafana dashboard for Mikrotik/routerOS. [prometheus/snmp_exporter](https://gith
|---|---| |---|---|
| snmp_exporter | `>=0.20.0` | | snmp_exporter | `>=0.20.0` |
| Grafana | `>=8.1.7` | | Grafana | `>=8.1.7` |
## 🐳 Deploy with docker-compose
1. Change targets ip (192.168.88.1) into file prometheus/prometheus.yml
2. Run
```console
docker-compose up -d
```
3. Open [localhost:3000](http://localhost:3000)
Grafana login: admin, password: mikrotik
If you want to change the credentials, then edit the ".env" file
-----------
## Manual deploy
1.add into prometheus.yml 1.add into prometheus.yml
@ -15,7 +30,7 @@ Grafana dashboard for Mikrotik/routerOS. [prometheus/snmp_exporter](https://gith
- job_name: Mikrotik - job_name: Mikrotik
static_configs: static_configs:
- targets: - targets:
- 0.0.0.0 # SNMP device IP. - 192.168.88.1 # SNMP device IP.
metrics_path: /snmp metrics_path: /snmp
params: params:
module: [mikrotik] module: [mikrotik]
@ -34,7 +49,7 @@ Grafana dashboard for Mikrotik/routerOS. [prometheus/snmp_exporter](https://gith
----------- -----------
## Docker snmp_exporter ### Docker snmp_exporter
[![Docker Pulls](https://img.shields.io/docker/pulls/mashinkopochinko/snmp_exporter_mikrotik?logo=docker)](https://hub.docker.com/repository/docker/mashinkopochinko/snmp_exporter_mikrotik) [![Docker Pulls](https://img.shields.io/docker/pulls/mashinkopochinko/snmp_exporter_mikrotik?logo=docker)](https://hub.docker.com/repository/docker/mashinkopochinko/snmp_exporter_mikrotik)

34
docker-compose.yml Normal file
View file

@ -0,0 +1,34 @@
version: '3.9'
services:
grafana:
image: grafana/grafana:8.1.7
container_name: mk_grafana
restart: always
volumes:
- ./grafana/provisioning/:/etc/grafana/provisioning/
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=${GF_ADMIN_USER}
- GF_SECURITY_ADMIN_PASSWORD=${GF_ADMIN_PASSWORD}
- GF_USERS_ALLOW_SIGN_UP=false
prometheus:
image: prom/prometheus
container_name: mk_prometheus
restart: always
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus/data/:/prometheus
ports:
- "9090:9090"
snmp_exporter:
image: mashinkopochinko/snmp_exporter_mikrotik
container_name: mk_snmp_exporter
restart: always
ports:
- "9116:9116"
depends_on:
- prometheus

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,11 @@
apiVersion: 1
providers:
- name: 'Prometheus'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/provisioning/dashboards

View file

@ -0,0 +1,50 @@
# config file version
apiVersion: 1
# list of datasources that should be deleted from the database
deleteDatasources:
- name: Prometheus
orgId: 1
# list of datasources to insert/update depending
# whats available in the database
datasources:
# <string, required> name of the datasource. Required
- name: Prometheus
# <string, required> datasource type. Required
type: prometheus
# <string, required> access mode. direct or proxy. Required
access: proxy
# <int> org id. will default to orgId 1 if not specified
orgId: 1
# <string> url
url: http://mk_prometheus:9090
# <string> database password, if used
password:
# <string> database user, if used
user:
# <string> database name, if used
database:
# <bool> enable/disable basic auth
basicAuth: false
# <string> basic auth username, if used
basicAuthUser:
# <string> basic auth password, if used
basicAuthPassword:
# <bool> enable/disable with credentials headers
withCredentials:
# <bool> mark as default datasource. Max one per org
isDefault: true
# <map> fields that will be converted to json and stored in json_data
jsonData:
graphiteVersion: "1.1"
tlsAuth: false
tlsAuthWithCACert: false
# <string> json object of data that will be encrypted.
secureJsonData:
tlsCACert: "..."
tlsClientCert: "..."
tlsClientKey: "..."
version: 1
# <bool> allow users to edit datasources from the UI.
editable: true

View file

@ -8,7 +8,7 @@ global:
# Attach these labels to any time series or alerts when communicating with # Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager). # external systems (federation, remote storage, Alertmanager).
external_labels: external_labels:
monitor: 'example' monitor: 'Mikrotik'
# Alertmanager configuration # Alertmanager configuration
alerting: alerting:
@ -40,7 +40,7 @@ scrape_configs:
- job_name: Mikrotik - job_name: Mikrotik
static_configs: static_configs:
- targets: - targets:
- 0.0.0.0 # SNMP device IP. - 192.168.88.1 # SNMP device IP.
metrics_path: /snmp metrics_path: /snmp
params: params:
module: [mikrotik] module: [mikrotik]
@ -50,4 +50,4 @@ scrape_configs:
- source_labels: [__param_target] - source_labels: [__param_target]
target_label: instance target_label: instance
- target_label: __address__ - target_label: __address__
replacement: localhost:9116 # The SNMP exporter's real hostname:port. replacement: mk_snmp_exporter:9116 # The SNMP exporter's real hostname:port.