Add grafana quickstart
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ log.html
|
||||
node_modules/
|
||||
./front/coverage
|
||||
.venv
|
||||
grafana/.data
|
||||
|
||||
194
grafana/docker-compose.yaml
Normal file
194
grafana/docker-compose.yaml
Normal file
@@ -0,0 +1,194 @@
|
||||
---
|
||||
version: "3"
|
||||
|
||||
networks:
|
||||
loki:
|
||||
|
||||
services:
|
||||
read:
|
||||
image: grafana/loki:2.8.2
|
||||
command: "-config.file=/etc/loki/config.yaml -target=read"
|
||||
ports:
|
||||
- 3101:3100
|
||||
- 7946
|
||||
- 9095
|
||||
volumes:
|
||||
- ./loki-config.yaml:/etc/loki/config.yaml
|
||||
depends_on:
|
||||
- minio
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1" ]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks: &loki-dns
|
||||
loki:
|
||||
aliases:
|
||||
- loki
|
||||
|
||||
write:
|
||||
image: grafana/loki:2.8.2
|
||||
command: "-config.file=/etc/loki/config.yaml -target=write"
|
||||
ports:
|
||||
- 3102:3100
|
||||
- 7946
|
||||
- 9095
|
||||
volumes:
|
||||
- ./loki-config.yaml:/etc/loki/config.yaml
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1" ]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
depends_on:
|
||||
- minio
|
||||
networks:
|
||||
<<: *loki-dns
|
||||
|
||||
promtail:
|
||||
image: grafana/promtail:2.8.2
|
||||
volumes:
|
||||
- ./promtail-local-config.yaml:/etc/promtail/config.yaml:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
command: -config.file=/etc/promtail/config.yaml
|
||||
depends_on:
|
||||
- gateway
|
||||
networks:
|
||||
- loki
|
||||
|
||||
minio:
|
||||
image: minio/minio
|
||||
entrypoint:
|
||||
- sh
|
||||
- -euc
|
||||
- |
|
||||
mkdir -p /data/loki-data && \
|
||||
mkdir -p /data/loki-ruler && \
|
||||
minio server /data
|
||||
environment:
|
||||
- MINIO_ROOT_USER=loki
|
||||
- MINIO_ROOT_PASSWORD=supersecret
|
||||
- MINIO_PROMETHEUS_AUTH_TYPE=public
|
||||
- MINIO_UPDATE=off
|
||||
ports:
|
||||
- 9000
|
||||
volumes:
|
||||
- ./.data/minio:/data
|
||||
healthcheck:
|
||||
test: [ "CMD", "curl", "-f", "http://localhost:9000/minio/health/live" ]
|
||||
interval: 15s
|
||||
timeout: 20s
|
||||
retries: 5
|
||||
networks:
|
||||
- loki
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
environment:
|
||||
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
|
||||
- GF_AUTH_ANONYMOUS_ENABLED=true
|
||||
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
|
||||
depends_on:
|
||||
- gateway
|
||||
entrypoint:
|
||||
- sh
|
||||
- -euc
|
||||
- |
|
||||
mkdir -p /etc/grafana/provisioning/datasources
|
||||
cat <<EOF > /etc/grafana/provisioning/datasources/ds.yaml
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://gateway:3100
|
||||
jsonData:
|
||||
httpHeaderName1: "X-Scope-OrgID"
|
||||
secureJsonData:
|
||||
httpHeaderValue1: "tenant1"
|
||||
EOF
|
||||
/run.sh
|
||||
ports:
|
||||
- "3000:3000"
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1" ]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- loki
|
||||
|
||||
gateway:
|
||||
image: nginx:latest
|
||||
depends_on:
|
||||
- read
|
||||
- write
|
||||
entrypoint:
|
||||
- sh
|
||||
- -euc
|
||||
- |
|
||||
cat <<EOF > /etc/nginx/nginx.conf
|
||||
user nginx;
|
||||
worker_processes 5; ## Default: 1
|
||||
|
||||
events {
|
||||
worker_connections 1000;
|
||||
}
|
||||
|
||||
http {
|
||||
resolver 127.0.0.11;
|
||||
|
||||
server {
|
||||
listen 3100;
|
||||
|
||||
location = / {
|
||||
return 200 'OK';
|
||||
auth_basic off;
|
||||
}
|
||||
|
||||
location = /api/prom/push {
|
||||
proxy_pass http://write:3100\$$request_uri;
|
||||
}
|
||||
|
||||
location = /api/prom/tail {
|
||||
proxy_pass http://read:3100\$$request_uri;
|
||||
proxy_set_header Upgrade \$$http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location ~ /api/prom/.* {
|
||||
proxy_pass http://read:3100\$$request_uri;
|
||||
}
|
||||
|
||||
location = /loki/api/v1/push {
|
||||
proxy_pass http://write:3100\$$request_uri;
|
||||
}
|
||||
|
||||
location = /loki/api/v1/tail {
|
||||
proxy_pass http://read:3100\$$request_uri;
|
||||
proxy_set_header Upgrade \$$http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location ~ /loki/api/.* {
|
||||
proxy_pass http://read:3100\$$request_uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
/docker-entrypoint.sh nginx -g "daemon off;"
|
||||
ports:
|
||||
- "3100:3100"
|
||||
healthcheck:
|
||||
test: ["CMD", "service", "nginx", "status"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- loki
|
||||
|
||||
flog:
|
||||
image: mingrammer/flog
|
||||
command: -f json -d 1s -l
|
||||
networks:
|
||||
- loki
|
||||
33
grafana/loki-config.yaml
Normal file
33
grafana/loki-config.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
memberlist:
|
||||
join_members:
|
||||
- loki:7946
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2021-08-01
|
||||
store: boltdb-shipper
|
||||
object_store: s3
|
||||
schema: v11
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
common:
|
||||
path_prefix: /loki
|
||||
replication_factor: 1
|
||||
storage:
|
||||
s3:
|
||||
endpoint: minio:9000
|
||||
insecure: true
|
||||
bucketnames: loki-data
|
||||
access_key_id: loki
|
||||
secret_access_key: supersecret
|
||||
s3forcepathstyle: true
|
||||
ring:
|
||||
kvstore:
|
||||
store: memberlist
|
||||
ruler:
|
||||
storage:
|
||||
s3:
|
||||
bucketnames: loki-ruler
|
||||
22
grafana/promtail-local-config.yaml
Normal file
22
grafana/promtail-local-config.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
server:
|
||||
http_listen_port: 9080
|
||||
grpc_listen_port: 0
|
||||
|
||||
positions:
|
||||
filename: /tmp/positions.yaml
|
||||
|
||||
clients:
|
||||
- url: http://gateway:3100/loki/api/v1/push
|
||||
tenant_id: tenant1
|
||||
|
||||
scrape_configs:
|
||||
- job_name: flog_scrape
|
||||
docker_sd_configs:
|
||||
- host: unix:///var/run/docker.sock
|
||||
refresh_interval: 5s
|
||||
relabel_configs:
|
||||
- source_labels: ['__meta_docker_container_name']
|
||||
regex: '/(.*)'
|
||||
target_label: 'container'
|
||||
|
||||
Reference in New Issue
Block a user