Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
# Inventory and configuration files
inventory.ini
/roles/prometheus_config/files/hosts
/roles/prometheus_config/files/prometheus.yml
/roles/prometheus_config/templates/prometheus.yml.j2
config_hosts.yml

# Prometheus configuration files
roles/prometheus_config/files/hosts
roles/prometheus_config/files/prometheus.yml
roles/prometheus_config/templates/prometheus.yml.j2

# Sample files
samples/inventory.sample
samples/hosts.sample
samples/prometheus.yml.sample

# Ansible-related files
*.retry
*.log

# System files
.DS_Store
Thumbs.db

# Editor swap files
*.swp
*.swo
*.bak
*.tmp

# Python cache
__pycache__/
*.pyc
*.pyo
*.pyd

# Virtual environment
venv/
.env/
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ cp samples/hosts.sample roles/prometheus_config/files/hosts
cp samples/prometheus.yml.sample roles/prometheus_config/templates/prometheus.yml.j2
```

The config_hosts.yml file is how we set up internal DNS lookup by editing /etc/hosts file. This will make the Grafana dashboard easier to read as each server has its human-readable name rather than an IP address like "10.0.0.1"
The `config_hosts.yml` file is how we set up internal DNS lookup by editing `/etc/hosts` file. This will make the Grafana dashboard easier to read as each server has its human-readable name rather than an IP address like `10.0.0.1`

# Step 3: Run main playbook to set up a fresh monitor

The main monitor ansible file is main.yml, which sets up a new fresh monitor from scratch. It will set up firewall, install Prometheus, Grafana and Alert Manager.
The main monitor ansible file is `main.yml`, which sets up a new fresh monitor from scratch. It will set up firewall, install Prometheus, Grafana and Alert Manager.

```bash
ansible-playbook -i inventory main.yml
ansible-playbook -i inventory playbooks/main.yml
```

That's it!
That's it!
9 changes: 9 additions & 0 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
alertmanager_port: 9093
nginx_listen_port: 80
nginx_server_name: monitor.polkachu.com
nginx_server_name_prometheus: prometheus.polkachu.com
nginx_prometheus_port: 9090
nginx_proxy_grafana_port: 3000
nginx_proxy_loki_port: 3100
loki_grpc_listen_port: 9096
loki_http_listen_port: 9080
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion roles/alert_manager/files/alertmanager.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ After=network-online.target
User=root
Group=root
Type=simple
ExecStart=/usr/local/bin/alertmanager --config.file /etc/alertmanager/alertmanager.yml --web.external-url=http://localhost:9093 --cluster.advertise-address='0.0.0.0:9093'
ExecStart=/usr/local/bin/alertmanager --config.file /etc/alertmanager/alertmanager.yml --web.external-url=http://localhost:{{ alertmanager_port }} --cluster.advertise-address='0.0.0.0:{{ alertmanager_port }}'

[Install]
WantedBy=multi-user.target
8 changes: 4 additions & 4 deletions roles/grafana/files/grafana.nginx.conf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
server {
listen 80 default_server;
server_name monitor.polkachu.com;
listen {{ nginx_listen_port }} default_server;
server_name {{ nginx_server_name }};

root /usr/share/nginx/html;
index index.html index.htm;

location / {
proxy_pass http://localhost:3000/;
proxy_pass http://localhost:{{ nginx_proxy_grafana_port }}/;
proxy_set_header Host $http_host;
}

location /loki/ {
proxy_pass http://localhost:3100/;
proxy_pass http://localhost:{{ nginx_proxy_loki_port }}/;
auth_basic "Prometheus";
auth_basic_user_file ".loki";
}
Expand Down
6 changes: 3 additions & 3 deletions roles/loki/files/loki.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
auth_enabled: false

server:
http_listen_port: 3100
grpc_listen_port: 9096
http_listen_port: {{ nginx_proxy_loki_port }}
grpc_listen_port: {{ loki_grpc_listen_port }}

ingester:
wal:
Expand Down Expand Up @@ -61,7 +61,7 @@ ruler:
local:
directory: /tmp/loki/rules
rule_path: /tmp/loki/rules-temp
alertmanager_url: http://localhost:9093
alertmanager_url: http://localhost:{{ alertmanager_port }}
ring:
kvstore:
store: inmemory
Expand Down
6 changes: 3 additions & 3 deletions roles/prometheus/files/prometheus.nginx.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
server {
listen 80;
server_name prometheus.polkachu.com;
listen {{ nginx_listen_port }};
server_name {{ nginx_server_name_prometheus }};

root /usr/share/nginx/html;
index index.html index.htm;

location / {
proxy_pass http://localhost:9090/;
proxy_pass http://localhost:{{ nginx_prometheus_port }}/;

auth_basic "Prometheus";
auth_basic_user_file ".prometheus";
Expand Down
2 changes: 1 addition & 1 deletion roles/prometheus/files/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
- localhost:{{ alertmanager_port }}
4 changes: 2 additions & 2 deletions roles/promtail/files/promtail.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
server:
http_listen_port: 9080
http_listen_port: {{ loki_http_listen_port }}
grpc_listen_port: 0

positions:
filename: /tmp/positions.yaml

clients:
- url: http://127.0.0.1:3100/loki/api/v1/push
- url: http://127.0.0.1:{{ nginx_proxy_loki_port }}/loki/api/v1/push

scrape_configs:
- job_name: journal
Expand Down