Contents for lecture 6-2
This commit is contained in:
parent
118a09bcf2
commit
b86e377b8a
30
6-2-grafana-alerts/docker-compose.yml
Normal file
30
6-2-grafana-alerts/docker-compose.yml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
grafana:
|
||||||
|
image: "grafana/grafana:8.4.2"
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
volumes:
|
||||||
|
- ./provisioning:/etc/grafana/provisioning
|
||||||
|
environment:
|
||||||
|
- GF_SMTP_ENABLED=true
|
||||||
|
- GF_SMTP_HOST=mail:1025
|
||||||
|
|
||||||
|
loki:
|
||||||
|
image: "grafana/loki:2.4.2"
|
||||||
|
command: --config.file=/mnt/config/loki.yml
|
||||||
|
ports:
|
||||||
|
- "3100:3100"
|
||||||
|
volumes:
|
||||||
|
- ./loki.yml:/mnt/config/loki.yml
|
||||||
|
- ./rules.yml:/etc/loki/rules/fake/rules.yml
|
||||||
|
|
||||||
|
mail:
|
||||||
|
image: "dockage/mailcatcher:0.7.1"
|
||||||
|
ports:
|
||||||
|
- "1080:1080"
|
||||||
|
- "1025:1025"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
logs_dir:
|
38
6-2-grafana-alerts/loki.yml
Normal file
38
6-2-grafana-alerts/loki.yml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
auth_enabled: false
|
||||||
|
|
||||||
|
server:
|
||||||
|
http_listen_port: 3100
|
||||||
|
http_listen_address: 0.0.0.0
|
||||||
|
|
||||||
|
ruler:
|
||||||
|
evaluation_interval: 10s
|
||||||
|
poll_interval: 10s
|
||||||
|
storage:
|
||||||
|
type: local
|
||||||
|
local:
|
||||||
|
directory: /etc/loki/rules
|
||||||
|
rule_path: /tmp/loki/rules-temp
|
||||||
|
enable_api: true
|
||||||
|
enable_alertmanager_v2: true
|
||||||
|
|
||||||
|
schema_config:
|
||||||
|
configs:
|
||||||
|
- from: 2020-08-01
|
||||||
|
store: boltdb-shipper
|
||||||
|
object_store: filesystem
|
||||||
|
schema: v11
|
||||||
|
index:
|
||||||
|
prefix: index_
|
||||||
|
period: 24h
|
||||||
|
|
||||||
|
common:
|
||||||
|
path_prefix: /tmp/loki
|
||||||
|
storage:
|
||||||
|
filesystem:
|
||||||
|
chunks_directory: /tmp/loki/chunks
|
||||||
|
rules_directory: /tmp/loki/rules
|
||||||
|
replication_factor: 1
|
||||||
|
ring:
|
||||||
|
instance_addr: 127.0.0.1
|
||||||
|
kvstore:
|
||||||
|
store: inmemory
|
11
6-2-grafana-alerts/promtail.yml
Normal file
11
6-2-grafana-alerts/promtail.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
clients:
|
||||||
|
- url: http://loki:3100/loki/api/v1/push
|
||||||
|
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: flog
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
- localhost
|
||||||
|
labels:
|
||||||
|
job: flogs
|
||||||
|
__path__: /tmp/log/*.log
|
8
6-2-grafana-alerts/provisioning/datasources/loki.yml
Normal file
8
6-2-grafana-alerts/provisioning/datasources/loki.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
|
||||||
|
datasources:
|
||||||
|
- name: Loki
|
||||||
|
type: loki
|
||||||
|
url: http://loki:3100
|
||||||
|
isDefault: true
|
||||||
|
editable: true
|
10
6-2-grafana-alerts/rules.yml
Normal file
10
6-2-grafana-alerts/rules.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
groups:
|
||||||
|
- name: credentials_leak
|
||||||
|
rules:
|
||||||
|
- alert: http-credentials-leaked
|
||||||
|
annotations:
|
||||||
|
message: "{{ $labels.job }} is leaking http basic auth credentials."
|
||||||
|
expr: 'sum by (job) (count_over_time({job="myservice"} |~ "http(s?)://(\\w+):(\\w+)@" [5m]) > 0)'
|
||||||
|
for: 10s
|
||||||
|
labels:
|
||||||
|
severity: critical
|
Loading…
Reference in New Issue
Block a user