🌱 Add alloy log collectors - #3610
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
35048e0 to
7ff128f
Compare
|
/copilot-review |
|
Copilot code review has been requested by @UncivilizedGhost. Please allow a few moments for the review to be added. |
There was a problem hiding this comment.
Pull request overview
Adds optional Grafana Alloy collectors for shipping Kubernetes and host Docker logs to Loki.
Changes:
- Integrates Alloy deployment into kind and E2E workflows.
- Adds standalone setup, verification, and cleanup tooling.
- Configures Kubernetes and Docker log discovery and forwarding.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
Makefile |
Adds log-collection targets. |
scripts/ci-e2e.sh |
Deploys Alloy during E2E setup. |
hack/kind_with_registry.sh |
Adds Alloy to kind setup. |
hack/log-collection/deploy-alloy.sh |
Deploys Alloy via Helm. |
hack/log-collection/setup.sh |
Creates a standalone test cluster. |
hack/log-collection/verify.sh |
Provides collector diagnostics. |
hack/log-collection/cleanup.sh |
Deletes the test cluster. |
hack/log-collection/kind-config.yaml |
Defines the three-node kind cluster. |
hack/log-collection/alloy-values.yaml |
Configures Kubernetes log collection. |
hack/log-collection/setup-host-docker-logs.sh |
Starts host Docker collection. |
hack/log-collection/cleanup-host-docker-logs.sh |
Stops host Docker collection. |
hack/log-collection/docker-compose.host-logs.yml |
Defines the host Alloy container. |
hack/log-collection/alloy-docker-config.alloy |
Configures Docker log forwarding. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
b7cdd8f to
88c32a5
Compare
88c32a5 to
2897ccc
Compare
|
/copilot-review |
|
Copilot code review has been requested by @UncivilizedGhost. Please allow a few moments for the review to be added. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
hack/log-collection/verify.sh:57
wc -lcommonly outputs leading whitespace (e.g.,\" 3\"). In[[ ... -ne ... ]]numeric comparisons, that can triggerinteger expression expectederrors on some shells/environments. Prefer counting withoutwcpadding (e.g.,awk 'END{print NR}', or strip whitespace withtr -d '[:space:]') so the numeric comparison is robust.
log "Verifying pod count matches node count..."
NODE_COUNT=$(kubectl --context "${CTX}" get nodes --no-headers | wc -l)
POD_COUNT=$(kubectl --context "${CTX}" -n "${NAMESPACE}" get pods -l app.kubernetes.io/name=alloy --no-headers | wc -l)
if [[ "${POD_COUNT}" -ne "${NODE_COUNT}" ]]; then
err "Expected ${NODE_COUNT} Alloy pods (one per node), but found ${POD_COUNT}."
hack/kind_with_registry.sh:29
- The Alloy deployment block is duplicated in this script (once in the 'cluster already exists' path, and again after cluster creation). Consider extracting this into a small helper function (or a single common block) to reduce duplication and avoid future drift between the two code paths.
if [[ "$(kind get clusters)" =~ .*"${KIND_CLUSTER_NAME}".* ]]; then
echo "cluster already exists, moving on"
# Deploy Alloy on existing clusters
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export ALLOY_KUBE_CONTEXT="kind-${KIND_CLUSTER_NAME}"
"${SCRIPT_DIR}/log-collection/deploy-alloy.sh"
exit 0
|
/test metal3-centos-e2e-integration-test-main |
|
/test metal3-centos-e2e-integration-test-main |
adilGhaffarDev
left a comment
There was a problem hiding this comment.
This is currently missing collection of libvirt/QEMU logs, we can do it separate PR. Just wanted to point out so we dont miss it.
| ALLOY_KUBE_CONTEXT="$(kubectl config current-context 2>/dev/null || echo "")" | ||
| export ALLOY_KUBE_CONTEXT | ||
| "${REPO_ROOT}/hack/log-collection/deploy-alloy.sh" | ||
|
|
There was a problem hiding this comment.
This only deploys Alloy to the current bootstrap context, so logs from every target cluster are missed. Please move bootstrap deployment into the Go bootstrap lifecycle and deploy Alloy from CreateTargetCluster after each workload cluster is ready, ensuring all target clusters get the DaemonSet.
2897ccc to
9be9e0b
Compare
|
/test metal3-centos-e2e-integration-test-main |
9be9e0b to
3fab9c1
Compare
|
/test metal3-centos-e2e-integration-test-main |
|
/test metal3-ubuntu-e2e-integration-test-main |
3fab9c1 to
76a139d
Compare
|
/test metal3-centos-e2e-integration-test-main |
76a139d to
2dd2235
Compare
|
/test metal3-ubuntu-e2e-integration-test-main |
1 similar comment
|
/test metal3-ubuntu-e2e-integration-test-main |
2dd2235 to
f167011
Compare
|
/test metal3-ubuntu-e2e-integration-test-main |
f167011 to
01d6f11
Compare
|
/test metal3-ubuntu-e2e-integration-test-main |
01d6f11 to
12735b2
Compare
|
/test metal3-ubuntu-e2e-integration-test-main |
12735b2 to
fb845b2
Compare
|
/test metal3-ubuntu-e2e-integration-test-main |
fb845b2 to
834e7ab
Compare
|
/test metal3-ubuntu-e2e-integration-test-main |
834e7ab to
d0b9a57
Compare
|
/test metal3-ubuntu-e2e-integration-test-main |
d0b9a57 to
9b6ffab
Compare
deploy-alloy.sh is used to have Grafana Alloy runs as a DaemonSet inside the clusters used by E2E tests. The set runs one alloy pod per node Discovers pods on the local node and gets theurlog files from /var/log/pods/... It pushes them to Loki with external labels setup-host-docker-logs.sh creates a standalone Alloy container with the Docker socket mounted It discovery.docker to find containers, filters to only known Metal3 infra containers (ironic, dnsmasq, vbmc, etc.) and gets their logs via the Docker API Pushes to the same Loki endpoint with the same external labels Create scipts to test log collection by creating a log and deploying cluster to it Signed-off-by: Saad Zia <saad.zia@est.tech>
9b6ffab to
f8298a7
Compare
this is just to test them. will clean script later
What this PR does / why we need it:
deploy-alloy.sh is used to have Grafana Alloy runs as a DaemonSet inside
the clusters used by E2E tests.
The set runs one alloy pod per node
Discovers pods on the local node and gets theurlog files from /var/log/pods/...
It pushes them to Loki with external labels
setup-host-docker-logs.sh creates a standalone Alloy container
with the Docker socket mounted
It discovery.docker to find containers, filters to
only known Metal3 infra containers (ironic, dnsmasq, vbmc, etc.)
and gets their logs via the Docker API
Pushes to the same Loki endpoint with the same external labels
Create scripts to test log collection by creating a log and deploying
cluster to it
Fixes #
Checklist: