Contents for lecture 6-2

This commit is contained in:
Joan López de la Franca Beltran 2022-04-28 10:34:23 +02:00
parent 118a09bcf2
commit b86e377b8a
5 changed files with 97 additions and 0 deletions

View 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:

View 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

View 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

View File

@ -0,0 +1,8 @@
apiVersion: 1
datasources:
- name: Loki
type: loki
url: http://loki:3100
isDefault: true
editable: true

View 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