Skip to content

Commit 79b3f40

Browse files
authored
Improve Loki (#305)
* Add names to docker projects * Add build log to loki * Fix collector * Fix script * Fix build log * Rename grafana folder * Fix grafana * Fix script better * Improve script * Decrease loki logging * Really decrease loki logs * turn off grafana access logs * fix build log collection
1 parent 2859909 commit 79b3f40

10 files changed

Lines changed: 34 additions & 14 deletions

File tree

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ auth_enabled: false
22

33
server:
44
http_listen_port: 3100
5+
log_level: "warn"
56

67
common:
78
instance_addr: 127.0.0.1

compose/production/grafana/otelcol-config.yaml renamed to compose/production/telemetry/otelcol-config.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@ receivers:
44
grpc:
55
endpoint: 0.0.0.0:4317
66

7-
filelog:
7+
filelog/host:
8+
include: [/var/log/build.log]
9+
poll_interval: 200ms
10+
start_at: end
11+
include_file_name: false
12+
include_file_path: false
13+
operators:
14+
- type: add
15+
field: resource["service.name"]
16+
value: "host"
17+
18+
filelog/docker:
819
include: [/var/lib/docker/containers/*/*-json.log]
920
poll_interval: 200ms
1021
start_at: beginning
@@ -23,7 +34,7 @@ receivers:
2334
if: "attributes?.attrs?.tag != nil"
2435
- id: extract_service_from_docker_tag
2536
parse_from: attributes.name
26-
regex: ^democrasite-(?<service>[^-]+)-(?<instance>\d+)$
37+
regex: ^(democrasite|telemetry)-(?<service>[^-]+)-(?<instance>\d+)$
2738
type: regex_parser
2839
if: "attributes?.name != nil"
2940
- from: attributes.service
@@ -91,7 +102,7 @@ exporters:
91102
service:
92103
pipelines:
93104
logs:
94-
receivers: [otlp, filelog]
105+
receivers: [otlp, filelog/host, filelog/docker]
95106
processors: [batch]
96107
exporters: [otlp_http/loki]
97108

File renamed without changes.

compose/production/traefik/traefik.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ http:
6767
service: telemetry
6868
tls:
6969
certResolver: letsencrypt
70+
observability:
71+
accessLogs: false
7072

7173
middlewares:
7274
csrf:

docker-compose.production.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: democrasite
2+
13
volumes:
24
production_postgres_data:
35
production_postgres_data_backups:

docker-compose.telemetry.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: telemetry
2+
13
volumes:
24
production_prometheus_data:
35
production_loki_data:
@@ -23,7 +25,7 @@ services:
2325
command:
2426
- --web.enable-otlp-receiver
2527
volumes:
26-
- ./compose/production/grafana/prometheus.yml:/prometheus/prometheus.yml
28+
- ./compose/production/telemetry/prometheus.yml:/prometheus/prometheus.yml
2729
- production_prometheus_data:/prometheus
2830
networks:
2931
- democrasite_metrics
@@ -32,17 +34,18 @@ services:
3234
loki:
3335
image: grafana/loki:3.6.4
3436
volumes:
35-
- ./compose/production/grafana/loki.yaml:/etc/loki/loki.yaml
37+
- ./compose/production/telemetry/loki.yaml:/etc/loki/loki.yaml
3638
- production_loki_data:/loki
3739
networks:
3840
- democrasite_metrics
41+
command: ["--log.level=warn", "--config.file=/etc/loki/loki.yaml"]
3942
logging: *logging
4043

4144
tempo:
4245
image: grafana/tempo:2.10.0
4346
command: -config.file=/etc/tempo/tempo.yaml
4447
volumes:
45-
- ./compose/production/grafana/tempo.yaml:/etc/tempo/tempo.yaml
48+
- ./compose/production/telemetry/tempo.yaml:/etc/tempo/tempo.yaml
4649
- production_tempo_data:/var/tempo
4750
networks:
4851
- democrasite_metrics
@@ -54,8 +57,9 @@ services:
5457
group_add:
5558
- "999" # to access docker socket
5659
volumes:
57-
- ./compose/production/grafana/otelcol-config.yaml:/etc/otelcol-contrib/config.yaml
60+
- ./compose/production/telemetry/otelcol-config.yaml:/etc/otelcol-contrib/config.yaml
5861
- /var/lib/docker/containers:/var/lib/docker/containers:ro
62+
- /var/log/build.log:/var/log/build.log
5963
- /var/run/docker.sock:/var/run/docker.sock
6064
- /:/hostfs:ro
6165
networks:
@@ -68,7 +72,7 @@ services:
6872
grafana:
6973
image: grafana/grafana:12.3.2
7074
volumes:
71-
- ./compose/production/grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
75+
- ./compose/production/telemetry/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
7276
- production_grafana_data:/var/lib/grafana
7377
env_file:
7478
- ./.envs/.production/.grafana

scripts/conditional-deploy.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
# Scripts adapted from https://www.youtube.com/watch?v=jFrGhodqC08 by Tom Delande
44
# Licensed under https://creativecommons.org/licenses/by/4.0/
55

6-
echo "$(date --utc +%FT%TZ): Fetching remote repository..."
76
git fetch
87

98
UPSTREAM=${1:-'@{u}'}
109
LOCAL=$(git rev-parse @)
1110
REMOTE=$(git rev-parse "$UPSTREAM")
1211
BASE=$(git merge-base @ "$UPSTREAM")
1312

14-
if [ $LOCAL = $REMOTE ]; then
15-
echo "$(date --utc +%FT%TZ): No changes detected in git"
16-
elif [ $LOCAL = $BASE ]; then
13+
if [ "$LOCAL" = "$REMOTE" ]; then
14+
true
15+
# echo "$(date --utc +%FT%TZ): No changes detected in git"
16+
elif [ "$LOCAL" = "$BASE" ]; then
1717
git pull
1818
scripts/deploy.sh
19-
elif [ $REMOTE = $BASE ]; then
19+
elif [ "$REMOTE" = "$BASE" ]; then
2020
echo "$(date --utc +%FT%TZ): Local changes detected, you may need to stash"
2121
else
2222
echo "$(date --utc +%FT%TZ): Git is diverged, this is unexpected."

scripts/cron-deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# Licensed under https://creativecommons.org/licenses/by/4.0/
55

66
cd /home/matthew/democrasite
7-
flock -n ~/deploy.lock scripts/conditional-deploy.sh >> ~/build.log 2>&1
7+
flock -n ~/deploy.lock scripts/conditional-deploy.sh >> /var/log/build.log 2>&1

0 commit comments

Comments
 (0)