Skip to content

Commit

Permalink
Merge pull request #102 from qclaogui/alloy-integrations
Browse files Browse the repository at this point in the history
Imrpove Alloy integrations
  • Loading branch information
qclaogui authored Apr 15, 2024
2 parents 6d11f4f + 1bd7037 commit bea35b8
Show file tree
Hide file tree
Showing 21 changed files with 198 additions and 179 deletions.
2 changes: 1 addition & 1 deletion docker-compose/common/compose-include/loki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- -config.expand-env=true
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1" ]
interval: 5s
interval: 3s
timeout: 2s
retries: 10
# expose 33100 port so we can directly access loki inside container
Expand Down
4 changes: 2 additions & 2 deletions docker-compose/common/compose-include/mimir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ services:
- -config.expand-env=true
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8080/ready || exit 1" ]
interval: 5s
interval: 3s
timeout: 2s
retries: 5
retries: 10
# expose 38080 port so we can directly access mimir inside container
ports:
- "38080:8080"
Expand Down
18 changes: 9 additions & 9 deletions docker-compose/common/compose-include/minio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ services:
minio:
# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
labels:
- logs.grafana.com/scrape=false
- metrics.grafana.com/scrape=true
- metrics.grafana.com/job=minio-job
- metrics.grafana.com/path=/minio/v2/metrics/cluster
- metrics.grafana.com/port=9000
- metrics.grafana.com/interval=15s
- metrics.grafana.com/timeout=10s
logs.grafana.com/scrape: false
metrics.grafana.com/scrape: true
metrics.grafana.com/job: minio-job
metrics.grafana.com/path: /minio/v2/metrics/cluster
metrics.grafana.com/port: 9000
metrics.grafana.com/interval: 15s
metrics.grafana.com/timeout: 10s
image: ${MINIO_IMAGE:-docker.io/minio/minio:RELEASE.2024-03-15T01-07-19Z}
entrypoint:
- sh
Expand All @@ -32,9 +32,9 @@ services:
- minio_data:/data:delegated
healthcheck:
test: ["CMD-SHELL", "mc ready local"]
interval: 5s
interval: 3s
timeout: 2s
retries: 5
retries: 10
ports:
- "9001:9001"

Expand Down
2 changes: 1 addition & 1 deletion docker-compose/common/compose-include/pyroscope.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
# - -runtime-config.file=/etc/pyroscope/overrides.yaml
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:4040/ready || exit 1" ]
interval: 5s
interval: 3s
timeout: 2s
retries: 10
# expose 34040 port so we can directly access pyroscope inside container
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/common/compose-include/tempo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- -config.expand-env=true
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3200/ready || exit 1" ]
interval: 5s
interval: 3s
timeout: 2s
retries: 10
start_period: 10s
Expand Down
30 changes: 8 additions & 22 deletions docker-compose/common/config/alloy/all-in-one.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import.file "provider" {
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/provider"
}

// get lgtmp receivers provider
// get self hosted receivers provider
provider.self_hosted "compose" {
logs_endpoint = "http://gateway:3100"
metrics_endpoint = "http://gateway:8080"
Expand All @@ -25,43 +25,30 @@ import.file "metrics" {
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/metrics"
}

// targets auto scrape by docker compose label
metrics.label_auto_scrape "default" {
metrics.labels_scrape "all" {
label_prefix = "metrics.grafana.com"
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.jobs_minio "scrape" {
metrics.jobs_scrape "all" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.integrations_cadvisor "scrape" {
metrics.integrations_scrape "all" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.integrations_node_exporter "scrape" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.integrations_memcached "scrape" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"

memcached_address = "memcached:11211"
}

/********************************************
* Logs
********************************************/
import.file "logs" {
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/logs"
}

logs.label_auto_scrape "default" {
logs.labels_scrape "all" {
label_prefix = "logs.grafana.com"
forward_to = [logs.keep_labels.default.receiver]
}
Expand All @@ -79,15 +66,15 @@ import.file "traces" {
}

// traces Processing And Transformation
traces.pat "default" {
traces.pat "all" {
metrics_forward_to = [provider.self_hosted.compose.metrics_receiver]
logs_forward_to = [provider.self_hosted.compose.logs_receiver]
traces_forward_to = [provider.self_hosted.compose.traces_receiver]
}

tracing {
sampling_fraction = 0.8
write_to = [traces.pat.default.alloy_traces_input]
write_to = [traces.pat.all.alloy_traces_input]
}

/********************************************
Expand All @@ -97,8 +84,7 @@ import.file "profiles" {
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/profiles"
}

// targets auto scrape by docker compose label
profiles.label_auto_scrape "default" {
profiles.labels_scrape "all" {
label_prefix = "profiles.grafana.com"
forward_to = [provider.self_hosted.compose.profiles_receiver]
}
21 changes: 4 additions & 17 deletions docker-compose/common/config/alloy/logs.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import.file "logs" {
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/logs"
}

logs.label_auto_scrape "default" {
logs.labels_scrape "all" {
label_prefix = "logs.grafana.com"
forward_to = [logs.keep_labels.default.receiver]
}
Expand All @@ -40,31 +40,18 @@ import.file "metrics" {
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/metrics"
}

// targets auto scrape by docker compose label
metrics.label_auto_scrape "default" {
metrics.labels_scrape "all" {
label_prefix = "metrics.grafana.com"
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.jobs_minio "scrape" {
metrics.jobs_scrape "all" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.integrations_cadvisor "scrape" {
metrics.integrations_scrape "all" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.integrations_node_exporter "scrape" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.integrations_memcached "scrape" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"

memcached_address = "memcached:11211"
}
19 changes: 3 additions & 16 deletions docker-compose/common/config/alloy/metrics.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,18 @@ import.file "metrics" {
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/compose/metrics"
}

// targets auto scrape by docker compose label
metrics.label_auto_scrape "default" {
metrics.labels_scrape "all" {
label_prefix = "metrics.grafana.com"
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.jobs_minio "scrape" {
metrics.jobs_scrape "all" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.integrations_cadvisor "scrape" {
metrics.integrations_scrape "all" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.integrations_node_exporter "scrape" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"
}

metrics.integrations_memcached "scrape" {
forward_to = [provider.self_hosted.compose.metrics_receiver]
scrape_interval = "15s"

memcached_address = "memcached:11211"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/************************************************
* Component: integrations_cadvisor
* Integrations Component: component_cadvisor
*************************************************/

declare "integrations_cadvisor" {
declare "component_cadvisor" {

/********************************************
* ARGUMENTS
Expand Down Expand Up @@ -41,7 +41,7 @@ declare "integrations_cadvisor" {
/********************************************
* Integrations cAdvisor
********************************************/
prometheus.exporter.cadvisor "integrations_cadvisor" {
prometheus.exporter.cadvisor "component_cadvisor" {
docker_host = "unix:///var/run/docker.sock"

store_container_labels = false
Expand All @@ -62,8 +62,8 @@ declare "integrations_cadvisor" {
/********************************************
* Discovery Relabelings (pre-scrape)
********************************************/
discovery.relabel "integrations_cadvisor" {
targets = prometheus.exporter.cadvisor.integrations_cadvisor.targets
discovery.relabel "component_cadvisor" {
targets = prometheus.exporter.cadvisor.component_cadvisor.targets

// set the cluster label
rule {
Expand All @@ -81,9 +81,9 @@ declare "integrations_cadvisor" {
/********************************************
* Prometheus Scrape Integrations Targets
********************************************/
prometheus.scrape "integrations_cadvisor" {
prometheus.scrape "component_cadvisor" {
targets = concat(
discovery.relabel.integrations_cadvisor.output,
discovery.relabel.component_cadvisor.output,
)

enable_protobuf_negotiation = true
Expand All @@ -96,13 +96,13 @@ declare "integrations_cadvisor" {
enabled = true
}

forward_to = [prometheus.relabel.integrations_cadvisor.receiver]
forward_to = [prometheus.relabel.component_cadvisor.receiver]
}

/********************************************
* Prometheus Metric Relabelings (post-scrape)
********************************************/
prometheus.relabel "integrations_cadvisor" {
prometheus.relabel "component_cadvisor" {
forward_to = argument.forward_to.value

// drop unused metric label
Expand Down
Loading

0 comments on commit bea35b8

Please sign in to comment.