Skip to content

Commit

Permalink
Merge pull request #99 from qclaogui:compose-configs
Browse files Browse the repository at this point in the history
[alloy]add docker compose configs support
  • Loading branch information
qclaogui committed Apr 14, 2024
2 parents dfa7b4c + 3c5f952 commit 6d11f4f
Show file tree
Hide file tree
Showing 41 changed files with 85 additions and 259 deletions.
14 changes: 0 additions & 14 deletions compose.override.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

# https://docs.docker.com/compose/multiple-compose-files/include/#include-and-overrides

# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
x-labels: &profiles-labels
profiles.grafana.com/cpu.scrape: true
Expand All @@ -14,18 +12,6 @@ x-environment: &jaeger-environment
JAEGER_SAMPLER_PARAM: 1

services:
alloy: # override compose.yaml included service alloy entrypoint to use all-in-one.alloy. default(metrics.alloy)
entrypoint:
- /bin/alloy
- run
- /etc/alloy/all-in-one.alloy
- --server.http.listen-addr=0.0.0.0:12345
- --cluster.enabled=true
- --cluster.join-addresses=alloy-cluster:12345
- --disable-reporting=true
- --stability.level=experimental
- --storage.path=/var/lib/alloy/data

# override compose.yaml included service loki's labels and environment to enabled profiles and traces data collection
loki:
labels:
Expand Down
4 changes: 4 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ include:
- path: ./docker-compose/common/compose-include/mimir.yaml
- path: ./docker-compose/common/compose-include/pyroscope.yaml

configs:
alloy_config_file:
file: ./docker-compose/common/config/alloy/all-in-one.alloy

services:
gateway:
labels:
Expand Down
14 changes: 6 additions & 8 deletions docker-compose/common/compose-include/alloy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,28 @@ services:
logs.grafana.com/log-format: logfmt
depends_on: { gateway: { condition: service_healthy } }
image: ${ALLOY_IMAGE:-docker.io/grafana/alloy:v1.0.0}
configs:
- source: alloy_config_file
target: /etc/alloy/config.alloy
volumes:
- ../config/alloy:/etc/alloy
- ../config/alloy/modules:/etc/alloy/modules
- /var/run/docker.sock:/var/run/docker.sock:ro
- /var/lib/docker:/var/lib/docker:ro
- /:/rootfs:ro
- /sys:/sys:ro
entrypoint:
- /bin/alloy
- run
- /etc/alloy/metrics.alloy
- /etc/alloy/config.alloy
- --server.http.listen-addr=0.0.0.0:12345
- --cluster.enabled=true
- --cluster.join-addresses=alloy-cluster:12345
- --disable-reporting=true
- --stability.level=experimental
- --storage.path=/var/lib/alloy/data
environment:
- ALLOY_CONFIG_FOLDER=/etc/alloy
- ALLOY_MODULES_FOLDER=/etc/alloy/modules
- ALLOY_LOG_LEVEL=warn
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:12345/ready || exit 1" ]
interval: 5s
timeout: 2s
retries: 10
ports:
- "12345:12345"
# - "12345-12348:12345" # Note: max replicas num is 3.
Expand Down
1 change: 1 addition & 0 deletions docker-compose/common/config/alloy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.alloy
10 changes: 5 additions & 5 deletions docker-compose/common/config/alloy/all-in-one.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ logging {
* Grafana LGTMP Stack Receiver Provider
********************************************/
import.file "provider" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/provider"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/provider"
}

// get lgtmp receivers provider
Expand All @@ -22,7 +22,7 @@ provider.self_hosted "compose" {
* Metrics
********************************************/
import.file "metrics" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/metrics"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/metrics"
}

// targets auto scrape by docker compose label
Expand Down Expand Up @@ -58,7 +58,7 @@ metrics.integrations_memcached "scrape" {
* Logs
********************************************/
import.file "logs" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/logs"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/logs"
}

logs.label_auto_scrape "default" {
Expand All @@ -75,7 +75,7 @@ logs.keep_labels "default" {
* Traces
********************************************/
import.file "traces" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/traces"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/traces"
}

// traces Processing And Transformation
Expand All @@ -94,7 +94,7 @@ tracing {
* Profiles
********************************************/
import.file "profiles" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/profiles"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/profiles"
}

// targets auto scrape by docker compose label
Expand Down
6 changes: 3 additions & 3 deletions docker-compose/common/config/alloy/logs.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ logging {
* Grafana LGTMP Stack Receiver Provider
********************************************/
import.file "provider" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/provider"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/provider"
}

// get lgtmp receivers provider
Expand All @@ -20,7 +20,7 @@ provider.self_hosted "compose" {
* Logs
********************************************/
import.file "logs" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/logs"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/logs"
}

logs.label_auto_scrape "default" {
Expand All @@ -37,7 +37,7 @@ logs.keep_labels "default" {
* Metrics
********************************************/
import.file "metrics" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/metrics"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/metrics"
}

// targets auto scrape by docker compose label
Expand Down
4 changes: 2 additions & 2 deletions docker-compose/common/config/alloy/metrics.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ logging {
* Grafana LGTMP Stack Receiver Provider
********************************************/
import.file "provider" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/provider"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/provider"
}

// get lgtmp receivers provider
Expand All @@ -19,7 +19,7 @@ provider.self_hosted "compose" {
* Metrics
********************************************/
import.file "metrics" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/metrics"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/metrics"
}

// targets auto scrape by docker compose label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,14 @@ declare "integrations_cadvisor" {

// set the cluster label
rule {
action = "replace"
replacement = argument.cluster.value
target_label = "cluster"
replacement = argument.cluster.value
}

// set the namespace label
rule {
action = "replace"
replacement = argument.namespace.value
target_label = "namespace"
replacement = argument.namespace.value
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,14 @@ declare "integrations_memcached" {

// set the cluster label
rule {
action = "replace"
replacement = argument.cluster.value
target_label = "cluster"
replacement = argument.cluster.value
}

// set the namespace label
rule {
action = "replace"
replacement = argument.namespace.value
target_label = "namespace"
replacement = argument.namespace.value
}

rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,14 @@ declare "integrations_node_exporter" {

// set the cluster label
rule {
action = "replace"
replacement = argument.cluster.value
target_label = "cluster"
replacement = argument.cluster.value
}

// set the namespace label
rule {
action = "replace"
replacement = argument.namespace.value
target_label = "namespace"
replacement = argument.namespace.value
}

rule {
Expand Down
6 changes: 3 additions & 3 deletions docker-compose/common/config/alloy/profiles.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ logging {
* Grafana LGTMP Stack Receiver Provider
********************************************/
import.file "provider" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/provider"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/provider"
}

// get lgtmp receivers provider
Expand All @@ -20,7 +20,7 @@ provider.self_hosted "compose" {
* Profiles
********************************************/
import.file "profiles" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/profiles"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/profiles"
}

// targets auto scrape by docker compose label
Expand All @@ -33,7 +33,7 @@ profiles.label_auto_scrape "default" {
* Metrics
********************************************/
import.file "metrics" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/metrics"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/metrics"
}

// targets auto scrape by docker compose label
Expand Down
6 changes: 3 additions & 3 deletions docker-compose/common/config/alloy/traces.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ logging {
* Grafana LGTMP Stack Receiver Provider
********************************************/
import.file "provider" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/provider"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/provider"
}

// get lgtmp receivers provider
Expand All @@ -21,7 +21,7 @@ provider.self_hosted "compose" {
* Traces
********************************************/
import.file "traces" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/traces"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/traces"
}

// traces Processing And Transformation
Expand All @@ -35,7 +35,7 @@ traces.pat "default" {
* Metrics
********************************************/
import.file "metrics" {
filename = coalesce(env("ALLOY_CONFIG_FOLDER"), "/etc/alloy") + "/modules/compose/metrics"
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/metrics"
}

// targets auto scrape by docker compose label
Expand Down
5 changes: 0 additions & 5 deletions docker-compose/microservices-mode/logs/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions docker-compose/microservices-mode/logs/alloy.override.yaml

This file was deleted.

8 changes: 5 additions & 3 deletions docker-compose/microservices-mode/logs/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ include:
- path: ../../common/compose-include/memcached.yaml
- path: ../../common/compose-include/mimir.yaml
- path: ../../common/compose-include/grafana.yaml
- path:
- ../../common/compose-include/alloy.yaml
- ./alloy.override.yaml
- path: ../../common/compose-include/alloy.yaml

# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
x-labels: &loki-labels
Expand All @@ -27,6 +25,10 @@ x-healthcheck: &status-healthcheck
timeout: 2s
retries: 10

configs:
alloy_config_file:
file: ../../common/config/alloy/logs.alloy

services:
gateway:
# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
Expand Down
7 changes: 0 additions & 7 deletions docker-compose/microservices-mode/metrics/.gitignore

This file was deleted.

4 changes: 4 additions & 0 deletions docker-compose/microservices-mode/metrics/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ x-healthcheck: &status-healthcheck
timeout: 2s
retries: 10

configs:
alloy_config_file:
file: ../../common/config/alloy/metrics.alloy

services:
gateway:
# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
Expand Down
5 changes: 0 additions & 5 deletions docker-compose/microservices-mode/profiles/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions docker-compose/microservices-mode/profiles/alloy.override.yaml

This file was deleted.

8 changes: 5 additions & 3 deletions docker-compose/microservices-mode/profiles/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ include:
- path: ../../common/compose-include/memcached.yaml
- path: ../../common/compose-include/mimir.yaml
- path: ../../common/compose-include/grafana.yaml
- path:
- ../../common/compose-include/alloy.yaml
- ./alloy.override.yaml
- path: ../../common/compose-include/alloy.yaml

# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
x-labels: &profiles-labels
Expand All @@ -29,6 +27,10 @@ x-healthcheck: &status-healthcheck
timeout: 2s
retries: 10

configs:
alloy_config_file:
file: ../../common/config/alloy/profiles.alloy

services:
gateway:
# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
Expand Down
5 changes: 0 additions & 5 deletions docker-compose/microservices-mode/traces/.gitignore

This file was deleted.

Loading

0 comments on commit 6d11f4f

Please sign in to comment.