PLG Stack Steps
VM Setup
VM Settings
Name: prod-watch-01
Clone from template
DOCKER --> 16GB Ram, 4 vCPU, 100GB HDD ub-24-min-docker
Create a Docker Compose Setup
Create a project folder
mkdir ~/plg-stack && cd ~/plg-stackCreate a docker-compose.yml file
sudo vim docker-compose.ymlCopy the following content into the file:
version: "3.7"
services:
grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
restart: always
loki:
image: grafana/loki:2.9.0
container_name: loki
ports:
- "3100:3100"
command: -config.file=/etc/loki/local-config.yaml
volumes:
- loki_data:/loki
restart: always
promtail:
image: grafana/promtail:2.9.0
container_name: promtail
volumes:
- /var/log:/var/log
- ./promtail-config.yaml:/etc/promtail/config.yaml
command: -config.file=/etc/promtail/config.yaml
restart: always
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- "9090:9090"
volumes:
- prometheus_data:/prometheus
- ./prometheus.yml:/etc/prometheus/prometheus.yml
restart: always
volumes:
grafana_data:
loki_data:
prometheus_data:Create a Promtail config file
sudo vim promtail-config.ymlCopy the following content into the file:
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://loki:3100/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*.logCreate a Prometheus config file
sudo vim prometheus.ymlCopy the following content into the file:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']Start the Docker Compose setup
Run from the ~/plg-stack directory:
sudo docker-compose up -dConfirm all services are running:
sudo docker psAccess Grafana:
http://192.168.8.170:3000Default login: admin/admin
Change the default password admin and login again.
Loki: runs at port 3100
Prometheus: runs at port 9090
http://192.168.8.170:9090Set Up Grafana Data Source
Go to Grafana UI → Gear Icon (Settings) → Data Sources
Add new data source:
Name: Loki
Type: Loki
URL:
http://loki:3100Save & Test