Personal Homelab
1logging {
2 level = "info"
3 format = "json"
4}
5
6livedebugging {
7 enabled = true
8}
9
10discovery.docker "fcos" {
11 host = "unix:///var/run/docker.sock"
12}
13
14discovery.relabel "docker" {
15 targets = discovery.docker.fcos.targets
16
17 rule {
18 action = "labelmap"
19 regex = "^__meta_docker_(.*)$"
20 }
21}
22
23loki.source.docker "podman" {
24 host = "unix:///var/run/docker.sock"
25 targets = discovery.docker.fcos.targets
26 labels = { "source_name" = "podman" }
27 forward_to = [loki.process.copy_msg.receiver]
28 relabel_rules = discovery.relabel.docker.rules
29}
30
31loki.process "copy_msg" {
32 forward_to = [loki.write.victoria_logs.receiver]
33
34 // Some services require to manually remap message field to _msg.
35 stage.match {
36 selector = "{_msg=\"\"}"
37
38 stage.match {
39 selector = "{container_name=\"/matrix-synapse\"}"
40
41 stage.json {
42 expressions = { "log" = "" }
43 }
44
45 stage.labels {
46 values = { "_msg" = "log" }
47 }
48 }
49
50 stage.match {
51 selector = "{container_name=\"/grafana\"}"
52
53 stage.json {
54 expressions = { "msg" = "" }
55 }
56
57 stage.labels {
58 values = { "_msg" = "msg" }
59 }
60 }
61
62 stage.match {
63 selector = "{container_name=\"/grafana-alloy\"}"
64
65 stage.json {
66 expressions = { "msg" = "" }
67 }
68
69 stage.labels {
70 values = { "_msg" = "msg" }
71 }
72 }
73
74 stage.match {
75 selector = "{container_name=\"/bluesky-pds\"}"
76
77 stage.json {
78 expressions = { "msg" = "" }
79 }
80
81 stage.labels {
82 values = { "_msg" = "msg" }
83 }
84 }
85 }
86}
87
88loki.write "victoria_logs" {
89 endpoint {
90 url = "http://victoria:9428/insert/loki/api/v1/push?_stream_fields=source_name,container_name"
91 }
92}
93
94prometheus.scrape "scrape_metrics" {
95 targets = [
96 { __address__ = "192.168.100.2:9290" }, // ipmi_exporter
97 { __address__ = "host.containers.internal:9100" }, // node_exporter
98 { __address__ = "host.containers.internal:9558" }, // systemd_exporter
99 { __address__ = "host.containers.internal:9091" }, // LiveKit
100 { __address__ = "prometheus-podman-exporter:9882" },
101 { __address__ = "victoria:8428" },
102 { __address__ = "victoria:9428" },
103 { __address__ = "victoria:10428" },
104 { __address__ = "immich:8081" },
105 { __address__ = "immich:8082" },
106 { __address__ = "opencloud:9205" },
107 { __address__ = "opencloud:9304" },
108 { __address__ = "matrix:9000" },
109 { __address__ = "rmqtt:6060", __metrics_path__ = "/api/v1/metrics/prometheus" },
110 ]
111 forward_to = [prometheus.remote_write.victoria_metrics.receiver]
112 scrape_interval = "10s"
113}
114
115prometheus.remote_write "victoria_metrics" {
116 endpoint {
117 url = "http://victoria:8428/prometheus/api/v1/write"
118 }
119}
120
121otelcol.receiver.otlp "default" {
122 http {}
123 grpc {}
124
125 output {
126 metrics = [otelcol.processor.batch.default.input]
127 logs = [otelcol.processor.batch.default.input]
128 traces = [otelcol.processor.batch.default.input]
129 }
130}
131
132otelcol.processor.batch "default" {
133 output {
134 metrics = [otelcol.exporter.otlphttp.victoria_metrics.input]
135 logs = [otelcol.exporter.otlphttp.victoria_logs.input]
136 traces = [otelcol.exporter.otlphttp.victoria_traces.input]
137 }
138}
139
140otelcol.exporter.otlphttp "victoria_metrics" {
141 client {
142 endpoint = "http://victoria:8428/opentelemetry"
143 }
144}
145
146otelcol.exporter.otlphttp "victoria_logs" {
147 client {
148 endpoint = "http://victoria:9428/insert/opentelemetry"
149 }
150}
151
152otelcol.exporter.otlphttp "victoria_traces" {
153 client {
154 endpoint = "http://victoria:10428/insert/opentelemetry"
155 }
156}