Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Grafana Agent Flow to Grafana Alloy #95

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ copyright: $(COPYRIGHT) ## Add Copyright header to .go files.
CONFIG_FILES = $(shell find . -type f -name '*.river')
CONFIG_FILES_IN_DOCKER = $(subst ./, /data/, $(CONFIG_FILES))
.PHONY: fmt
fmt: ## Uses Grafana Agent to fmt the river config
fmt: alloy-fmt ## Uses Grafana Agent to fmt the river config
@for c in $(CONFIG_FILES_IN_DOCKER); do \
echo "$$c"; \
docker run -e AGENT_MODE=flow --rm --volume "$(shell pwd):/data" -u $(shell id -u) grafana/agent:v0.40.3 fmt -w $$c ; \
done

ALLOY_CONFIG_FILES = $(shell find . -type f -name '*.alloy')
ALLOY_CONFIG_FILES_IN_DOCKER = $(subst ./, /data/, $(ALLOY_CONFIG_FILES))
.PHONY: alloy-fmt
alloy-fmt: ## Uses Grafana Alloy to fmt the config
@for c in $(ALLOY_CONFIG_FILES_IN_DOCKER); do \
echo "$$c"; \
docker run --rm --volume "$(shell pwd):/data" -u $(shell id -u) grafana/alloy:v1.0.0 fmt -w $$c ; \
done

##@ Docker compose

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include: # include is available in Docker Compose version 2.20 and later, and Do

services:
github-exporter:
labels: # https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/agent-flow/modules/docker/README.md
labels: # https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
metrics.agent.grafana.com/scrape: true
image: githubexporter/github-exporter:1.1.0
environment:
Expand Down
15 changes: 8 additions & 7 deletions compose.override.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@

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

# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/agent-flow/modules/docker/README.md
# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
x-labels: &profiles-labels
profiles.agent.grafana.com/cpu.scrape: true
profiles.agent.grafana.com/memory.scrape: true
profiles.agent.grafana.com/goroutine.scrape: true

x-environment: &jaeger-environment
JAEGER_AGENT_HOST: grafana-agent
JAEGER_AGENT_HOST: alloy
JAEGER_AGENT_PORT: 6831
JAEGER_SAMPLER_TYPE: const
JAEGER_SAMPLER_PARAM: 1

services:
# override compose.yaml included service grafana-agent's entrypoint to use monolithic-mode-all.river. default(metrics.river)
grafana-agent:
alloy: # override compose.yaml included service alloy entrypoint to use all-in-one.alloy. default(metrics.alloy)
entrypoint:
- /bin/grafana-agent
- /bin/alloy
- run
- /etc/agent-config/monolithic-mode-all.river # Note: Agent use monolithic-mode-all.river
- /etc/alloy/all-in-one.alloy
- --server.http.listen-addr=0.0.0.0:12345
- --cluster.enabled=true
- --cluster.join-addresses=grafana-agent-cluster:12345
- --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:
Expand Down
4 changes: 2 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ version: '3.9'
include:
- path: ./docker-compose/common/compose-include/minio.yaml
- path: ./docker-compose/common/compose-include/memcached.yaml
# Grafana LGTMP Stack Components
- path: ./docker-compose/common/compose-include/alloy.yaml
# Self Hosted Grafana LGTMP Stack
- path: ./docker-compose/common/compose-include/loki.yaml
- path: ./docker-compose/common/compose-include/grafana-agent.yaml
- path: ./docker-compose/common/compose-include/grafana.yaml
- path: ./docker-compose/common/compose-include/tempo.yaml
- path: ./docker-compose/common/compose-include/mimir.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@

services:
grafana-agent:
alloy:
labels:
logs.agent.grafana.com/log-format: logfmt
depends_on: { gateway: { condition: service_healthy } }
image: ${AGENT_IMAGE:-docker.io/grafana/agent:v0.40.3}
image: ${ALLOY_IMAGE:-docker.io/grafana/alloy:v1.0.0}
volumes:
- ../config/agent-flow:/etc/agent-config
- ../config/alloy:/etc/alloy
- /var/run/docker.sock:/var/run/docker.sock:ro
- /:/rootfs:ro
- /sys:/sys:ro
- /var/lib/docker:/var/lib/docker:ro
entrypoint:
- /bin/grafana-agent
- /bin/alloy
- run
- /etc/agent-config/metrics.river
- /etc/alloy/metrics.alloy
- --server.http.listen-addr=0.0.0.0:12345
- --cluster.enabled=true
- --cluster.join-addresses=grafana-agent-cluster:12345
- --cluster.join-addresses=alloy-cluster:12345
- --disable-reporting=true
- --stability.level=experimental
- --storage.path=/var/lib/alloy/data
environment:
- AGENT_MODE=flow
- AGENT_CONFIG_FOLDER=/etc/agent-config
- ALLOY_CONFIG_FOLDER=/etc/alloy
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"
# scale up support
# - "12345-12348:12345" # Note: max replicas num is 3.
deploy:
replicas: 1
networks:
default:
aliases:
- grafana-agent-cluster
- alloy-cluster
2 changes: 1 addition & 1 deletion docker-compose/common/compose-include/grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
- ../config/grafana/grafana.ini:/etc/grafana-config/grafana.ini
- ../config/grafana/dashboards:/var/lib/grafana/dashboards
- ../config/grafana/provisioning:/etc/grafana/provisioning
- ../../../monitoring-mixins/agent-flow-mixin/deploy/dashboards_out:/var/lib/grafana/dashboards/agent-flow-mixin
- ../../../monitoring-mixins/alloy-mixin/deploy/dashboards_out:/var/lib/grafana/dashboards/alloy-mixin
- ../../../monitoring-mixins/go-runtime-mixin/deploy/dashboards_out:/var/lib/grafana/dashboards/go-runtime-mixin
- ../../../monitoring-mixins/mimir-mixin/deploy/dashboards_out:/var/lib/grafana/dashboards/mimir-mixin
- ../../../monitoring-mixins/memcached-mixin/deploy/dashboards_out:/var/lib/grafana/dashboards/memcached-mixin
Expand Down
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 @@ -3,7 +3,7 @@ services:
labels:
- logs.agent.grafana.com/log-format=json
depends_on: { minio: { condition: service_healthy } }
image: ${LOKI_IMAGE:-docker.io/grafana/loki:2.9.6}
image: ${LOKI_IMAGE:-docker.io/grafana/loki:3.0.0}
volumes:
- ../config/loki:/etc/loki
command:
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 @@ -25,10 +25,10 @@ services:
mimirtool:
labels:
metrics.agent.grafana.com/scrape: false
image: ${MIMIRTOOL_IMAGE:-docker.io/grafana/mimirtool:2.11.0}
image: ${MIMIRTOOL_IMAGE:-docker.io/grafana/mimirtool:2.12.0}
volumes:
- ../../../monitoring-mixins/crontab:/etc/crontabs/root
- ../../../monitoring-mixins/agent-flow-mixin/deploy/agent-flow-mixin-alerts.yaml:/rules/agent-flow-mixin-alerts.yaml
- ../../../monitoring-mixins/alloy-mixin/deploy/alloy-mixin-alerts.yaml:/rules/alloy-mixin-alerts.yaml
- ../../../monitoring-mixins/memcached-mixin/deploy/memcached-mixin-alerts.yaml:/rules/memcached-mixin-alerts.yaml
- ../../../monitoring-mixins/mimir-mixin/deploy/mimir-mixin-rules.yaml:/rules/mimir-mixin-rules.yaml
- ../../../monitoring-mixins/mimir-mixin/deploy/mimir-mixin-alerts.yaml:/rules/mimir-mixin-alerts.yaml
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/common/compose-include/minio.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

services:
minio:
# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/agent-flow/modules/docker/README.md
# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/alloy/modules/compose/README.md
labels:
- logs.agent.grafana.com/scrape=false
- metrics.agent.grafana.com/scrape=true
Expand Down
1 change: 1 addition & 0 deletions docker-compose/common/config/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ALLOY_IMAGE=grafana/alloy:v1.0.0
AGENT_IMAGE=grafana/agent:v0.40.3
LOKI_IMAGE=grafana/loki:3.0.0
GRAFANA_IMAGE=grafana/grafana:11.0.0-preview
Expand Down
40 changes: 0 additions & 40 deletions docker-compose/common/config/agent-flow/logs.river

This file was deleted.

28 changes: 0 additions & 28 deletions docker-compose/common/config/agent-flow/metrics.river

This file was deleted.

This file was deleted.

Loading