mirror of
https://github.com/tiennm99/composes.git
synced 2026-10-18 18:15:14 +00:00
fix: address review findings (network ns, journal path, CI semantics)
- network_mode: host so prometheus.exporter.unix reports real host interfaces (eth0...) rather than the alloy container's veth pair. - loki.source.journal: set path = "/var/log/journal" explicitly so it doesn't silently fall through to /run/log/journal on volatile-journal hosts. - cadvisor keep-list: add container_memory_working_set_bytes (drives several panels on the standard Docker dashboard). - Drop /dev/kmsg device + extra_hosts:host.docker.internal — neither is needed by the current keep-lists, and host-network mode makes the extra_hosts entry meaningless. - CI: extend Alloy validation beyond `fmt` (syntax-only) by booting alloy with the embedded config and asserting it stays running, which catches bad component refs / wrong arg names that fmt accepts. - README: refresh Mounts table + Security note to match.
This commit is contained in:
1 parent
fed5d6f8c7
commit
8a7f156487
3 files changed
+28
-11
No files matched your search
Vendored
+19
@@ -34,3 +34,22 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
docker run --rm -v "$PWD/config.alloy:/config.alloy:ro" \
|
docker run --rm -v "$PWD/config.alloy:/config.alloy:ro" \
|
||||||
grafana/alloy:v1.10.0 fmt /config.alloy > /dev/null
|
grafana/alloy:v1.10.0 fmt /config.alloy > /dev/null
|
||||||
|
|
||||||
|
- name: Validate Alloy config semantics (parse + load components)
|
||||||
|
# `fmt` is syntax-only; this catches bad component refs, wrong arg
|
||||||
|
# types, and unknown component types by actually loading the graph.
|
||||||
|
# Components log scrape errors against the dummy URLs but alloy
|
||||||
|
# itself stays running, so liveness after sleep == config valid.
|
||||||
|
run: |
|
||||||
|
docker run --rm -d --name alloy-test \
|
||||||
|
-e ALLOY_HOSTNAME -e REMOTECFG_URL -e REMOTECFG_ID -e REMOTECFG_USER \
|
||||||
|
-e PROM_URL -e PROM_USER -e LOKI_URL -e LOKI_USER -e GRAFANA_TOKEN \
|
||||||
|
-v "$PWD/config.alloy:/etc/alloy/config.alloy:ro" \
|
||||||
|
grafana/alloy:v1.10.0 \
|
||||||
|
run --server.http.listen-addr=127.0.0.1:0 /etc/alloy/config.alloy
|
||||||
|
sleep 8
|
||||||
|
if [ "$(docker inspect -f '{{.State.Running}}' alloy-test 2>/dev/null)" != "true" ]; then
|
||||||
|
docker logs alloy-test
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
docker stop alloy-test >/dev/null
|
||||||
+6
-6
@@ -45,20 +45,20 @@ Same compose file on every host — change `ALLOY_HOSTNAME` and `REMOTECFG_ID` p
|
|||||||
|
|
||||||
## Security note
|
## Security note
|
||||||
|
|
||||||
Runs as `privileged: true` (matching the upstream Grafana Cloud docker integration). This is required for cadvisor to read cgroups via `/sys` and for `/dev/kmsg` access. If you need least-privilege, see the upstream Alloy docker integration docs and tighten capabilities.
|
Runs `privileged: true` + `network_mode: host`, matching the upstream Grafana Cloud docker integration. `network_mode: host` is required so `prometheus.exporter.unix` reports the host's real network interfaces (eth0…) instead of the alloy container's veth pair. If you need least-privilege, see the upstream Alloy docker integration docs and tighten capabilities.
|
||||||
|
|
||||||
## Mounts
|
## Mounts
|
||||||
|
|
||||||
| Mount | Why |
|
| Mount | Why |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `/proc:/rootproc:ro` | node-exporter cpu/mem/load |
|
| `/proc:/rootproc:ro` | node-exporter cpu/mem/load (referenced via `procfs_path`) |
|
||||||
| `/sys:/sys:ro` | node-exporter + cadvisor cgroups |
|
| `/sys:/sys:ro` | node-exporter + cadvisor cgroups |
|
||||||
| `/:/rootfs:ro` | filesystem collector |
|
| `/:/rootfs:ro` | filesystem collector (referenced via `rootfs_path`) |
|
||||||
| `/dev/disk/:/dev/disk:ro` | diskstats device labels |
|
| `/dev/disk/:/dev/disk:ro` | node-exporter diskstats device labels |
|
||||||
| `/var/run/docker.sock` | docker discovery + log streaming |
|
| `/var/run/docker.sock` | `discovery.docker` + `loki.source.docker` |
|
||||||
| `/var/lib/docker:ro` | cadvisor container metadata |
|
| `/var/lib/docker:ro` | cadvisor container metadata |
|
||||||
| `/var/log/journal:ro` | `loki.source.journal` |
|
| `/var/log/journal:ro` | `loki.source.journal` |
|
||||||
| `/dev/kmsg` (device) | cadvisor OOM detection |
|
| `/etc/machine-id:ro` | stable host id for the journal reader |
|
||||||
| `alloy-data` (named volume) | WAL + remotecfg cache |
|
| `alloy-data` (named volume) | WAL + remotecfg cache |
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
hostname: ${ALLOY_HOSTNAME:?required}
|
hostname: ${ALLOY_HOSTNAME:?required}
|
||||||
privileged: true
|
privileged: true
|
||||||
|
network_mode: host # node_exporter netdev/netstat sees real host interfaces (eth0…) not veth
|
||||||
environment:
|
environment:
|
||||||
ALLOY_DEPLOY_MODE: docker
|
ALLOY_DEPLOY_MODE: docker
|
||||||
REMOTECFG_URL: ${REMOTECFG_URL:?required}
|
REMOTECFG_URL: ${REMOTECFG_URL:?required}
|
||||||
@@ -29,10 +30,6 @@ services:
|
|||||||
- /var/lib/docker/:/var/lib/docker:ro
|
- /var/lib/docker/:/var/lib/docker:ro
|
||||||
- /var/log/journal:/var/log/journal:ro
|
- /var/log/journal:/var/log/journal:ro
|
||||||
- /etc/machine-id:/etc/machine-id:ro # stable host id for systemd journal reader
|
- /etc/machine-id:/etc/machine-id:ro # stable host id for systemd journal reader
|
||||||
extra_hosts:
|
|
||||||
- 'host.docker.internal:host-gateway'
|
|
||||||
devices:
|
|
||||||
- /dev/kmsg
|
|
||||||
configs:
|
configs:
|
||||||
- { source: alloy_config, target: /etc/alloy/config.alloy }
|
- { source: alloy_config, target: /etc/alloy/config.alloy }
|
||||||
command: 'run --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy'
|
command: 'run --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy'
|
||||||
@@ -151,6 +148,7 @@ configs:
|
|||||||
|
|
||||||
loki.source.journal "default" {
|
loki.source.journal "default" {
|
||||||
max_age = "12h0m0s"
|
max_age = "12h0m0s"
|
||||||
|
path = "/var/log/journal"
|
||||||
forward_to = [loki.process.default.receiver]
|
forward_to = [loki.process.default.receiver]
|
||||||
relabel_rules = loki.relabel.default.rules
|
relabel_rules = loki.relabel.default.rules
|
||||||
}
|
}
|
||||||
@@ -201,7 +199,7 @@ configs:
|
|||||||
|
|
||||||
rule {
|
rule {
|
||||||
source_labels = ["__name__"]
|
source_labels = ["__name__"]
|
||||||
regex = "container_cpu_usage_seconds_total|container_fs_reads_total|container_fs_usage_bytes|container_fs_writes_total|container_last_seen|container_memory_usage_bytes|container_network_receive_bytes_total|container_network_receive_errors_total|container_network_receive_packets_dropped_total|container_network_transmit_bytes_total|container_network_transmit_errors_total|container_network_transmit_packets_dropped_total|container_spec_memory_reservation_limit_bytes|machine_memory_bytes|machine_scrape_error|up"
|
regex = "container_cpu_usage_seconds_total|container_fs_reads_total|container_fs_usage_bytes|container_fs_writes_total|container_last_seen|container_memory_usage_bytes|container_memory_working_set_bytes|container_network_receive_bytes_total|container_network_receive_errors_total|container_network_receive_packets_dropped_total|container_network_transmit_bytes_total|container_network_transmit_errors_total|container_network_transmit_packets_dropped_total|container_spec_memory_reservation_limit_bytes|machine_memory_bytes|machine_scrape_error|up"
|
||||||
action = "keep"
|
action = "keep"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user