Skip to content

Instantly share code, notes, and snippets.

@ppcano

ppcano/loki.diff Secret

Last active October 4, 2023 14:32
Show Gist options
  • Save ppcano/2792e26b251b9bc88af9249b31dd8833 to your computer and use it in GitHub Desktop.
Save ppcano/2792e26b251b9bc88af9249b31dd8833 to your computer and use it in GitHub Desktop.
diff --git i/contrib/agent-local.river w/contrib/agent-local.river
index 7a7d1b8..9c7fca9 100644
--- i/contrib/agent-local.river
+++ w/contrib/agent-local.river
@@ -37,7 +37,6 @@ prometheus.scrape "default" {
]
}
-
// Collect profiles
pyroscope.scrape "scrape_profiles" {
forward_to = [
@@ -76,3 +75,33 @@ pyroscope.write "default" {
url = env("PROFILES_ENDPOINT")
}
}
+
+discovery.docker "linux" {
+ host = "unix:///var/run/docker.sock"
+}
+
+discovery.relabel "docker" {
+ targets = discovery.docker.linux.targets
+
+ rule {
+ source_labels = ["__meta_docker_container_name"]
+ target_label = "container_name"
+ }
+
+ rule {
+ source_labels = ["__meta_docker_container_id"]
+ target_label = "container_id"
+ }
+}
+
+loki.source.docker "default" {
+ host = "unix:///var/run/docker.sock"
+ targets = discovery.relabel.docker.output
+ forward_to = [loki.write.default.receiver]
+}
+
+loki.write "default" {
+ endpoint {
+ url = env("LOGS_ENDPOINT")
+ }
+}
diff --git i/docker-compose-local.yaml w/docker-compose-local.yaml
index c07fb23..5252889 100644
--- i/docker-compose-local.yaml
+++ w/docker-compose-local.yaml
@@ -9,6 +9,12 @@ services:
QUICKPIZZA_OTLP_ENDPOINT: http://agent:4318
QUICKPIZZA_TRUST_CLIENT_TRACEID: 1
+ loki:
+ image: grafana/loki:2.8.3
+ command: -config.file=/etc/loki/local-config.yaml
+ ports:
+ - "3100:3100"
+
prometheus:
image: prom/prometheus:v2.47.0
command:
@@ -53,9 +59,10 @@ services:
AGENT_MODE: flow
QUICKPIZZA_HOST: quickpizza:3333
METRICS_ENDPOINT: http://prometheus:9090/api/v1/write
+ LOGS_ENDPOINT: http://loki:3100/loki/api/v1/push
TRACES_ENDPOINT: http://tempo:4317
- PROFILES_ENDPOINT: http://pyroscope:4040
depends_on:
- prometheus
- quickpizza
- - tempo
\ No newline at end of file
+ - tempo
+ - loki
\ No newline at end of file
diff --git i/grafana/datasources/datasource.yaml w/grafana/datasources/datasource.yaml
index a8d87fc..a00a809 100644
--- i/grafana/datasources/datasource.yaml
+++ w/grafana/datasources/datasource.yaml
@@ -25,4 +25,13 @@ datasources:
version: 1
editable: false
apiVersion: 1
- uid: tempo
\ No newline at end of file
+ uid: tempo
+ - name: Loki
+ type: loki
+ access: proxy
+ orgId: 1
+ url: http://loki:3100
+ basicAuth: false
+ isDefault: false
+ version: 1
+ editable: false
\ No newline at end of file
@ppcano
Copy link
Author

ppcano commented Oct 4, 2023

On Mac, it fails to connect the docker daemon:

quickpizza-agent-1 | ts=2023-10-04T13:49:11.509707887Z level=error component=discovery.docker.linux msg="Unable to refresh target groups" err="error while listing containers: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"

Lot of different possible solutions that didn't work for me https://stackoverflow.com/questions/44678725/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker

docker/desktop-linux#20 (comment)

Don't seem a reliable solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment