Move Alloy metrics agent to hover sidecar#334
Conversation
|
Updates to Preview Branch (feat/alloy-sidecar) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds Grafana Alloy observability: new River config tracked in repo, image and entrypoint updated to include an Alloy sidecar, startup script to manage processes and signals, and CI workflows updated to load and sync Grafana Cloud credentials to Fly. Changes
sequenceDiagram
participant Start as Start script (start.sh)
participant App as Application (./main)
participant Alloy as Grafana Alloy agent
participant Grafana as Grafana Cloud
Start->>Start: set ulimit, check GRAFANA_CLOUD_USER/API_KEY
alt Grafana creds present
Start->>Alloy: launch Alloy with /app/alloy.river (background)
Alloy->>Grafana: remote_write (HTTPS + basic auth)
else no creds
Start->>Start: log "skipping Alloy"
end
Start->>App: start ./main (background)
App->>Start: expose metrics on localhost:9464
Start->>Start: wait for App exit
Start->>Alloy: forward termination signal and wait (if running)
Start->>Start: exit with App status
Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Release VersionsApp patch: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
🐝 Review App Deployed Homepage: https://hover-pr-334.fly.dev |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@alloy.river`:
- Around line 13-16: Replace calls to the non-existent env() with sys.env() for
all environment variable lookups in the basic_auth block (update username and
password assignments to use sys.env("GRAFANA_CLOUD_USER") and
sys.env("GRAFANA_CLOUD_API_KEY")), and move the wal block out of the endpoint
block so that wal is a direct child of the prometheus.remote_write component
(i.e., place wal at the same level as endpoint rather than nested inside
endpoint) to satisfy Alloy schema validation.
In `@Dockerfile`:
- Line 2: Replace the non-deterministic base image declaration "FROM
grafana/alloy:latest AS alloy" with a pinned image by specifying an explicit tag
and digest (e.g., use "grafana/alloy:<version>@sha256:<digest>") so builds are
reproducible; update the FROM line in the Dockerfile to reference the chosen
version and its sha256 digest (obtain the digest from the image registry) and
ensure the alias "AS alloy" remains unchanged.
In `@scripts/start.sh`:
- Around line 7-11: The startup gate currently only checks GRAFANA_CLOUD_API_KEY
so Alloy may start without the required user credential; change the condition in
scripts/start.sh to require both GRAFANA_CLOUD_API_KEY and GRAFANA_CLOUD_USER
before launching the alloy process (the branch that echoes "Starting Alloy
metrics agent" and runs "/usr/local/bin/alloy run --storage.path=/tmp/alloy-wal
/app/alloy.river &"). If either GRAFANA_CLOUD_USER or GRAFANA_CLOUD_API_KEY is
missing, skip starting alloy and log a clear message indicating which
credential(s) are absent.
- Around line 6-15: The script starts Alloy in background and then execs the
main app, so signals aren't forwarded and Alloy can't be shut down gracefully;
modify scripts/start.sh to capture Alloy's PID (e.g., after launching
/usr/local/bin/alloy ... &), install a shell trap for TERM/INT that forwards
signals to the Alloy PID (kill -TERM $ALLOY_PID) and waits for it before
exiting, and run the main application without using exec so the script remains
PID 1 to coordinate shutdown (or ensure the trap also forwards signals to the
main app PID and waits for both); update references around the alloy launch line
and the final exec ./main invocation to implement PID tracking, kill in trap,
and wait.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6cfe3e41-0d8d-4b83-b83d-40b6d06bad1e
📒 Files selected for processing (7)
.github/workflows/fly-deploy.yml.github/workflows/review-apps.yml.gitignoreDockerfilealloy.riverfly.tomlscripts/start.sh
💤 Files with no reviewable changes (1)
- .gitignore
|
🐝 Review App Deployed Homepage: https://hover-pr-334.fly.dev |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Dockerfile`:
- Around line 29-30: The RUN installing ca-certificates and gcompat currently
uses unpinned packages—update that Dockerfile RUN (the line with "apk --no-cache
add ca-certificates gcompat") to pin each package to the Alpine v3.19 package
versions (e.g., ca-certificates=<version> and gcompat=<version>) so rebuilds are
reproducible; use the exact version strings from Alpine v3.19 package index and
keep the same apk flags (--no-cache) when replacing the unpinned names.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5678eea7-6432-47f2-a527-153db354cedd
📒 Files selected for processing (3)
Dockerfilealloy.riverscripts/start.sh
|
🐝 Review App Deployed Homepage: https://hover-pr-334.fly.dev |
Summary
bee-observabilityFly app and runs Grafana Alloy as a sidecar process inside thehoverVMlocalhost:9464(same machine, no network hop) and pushes to Grafana CloudGRAFANA_CLOUD_API_KEYis present — review apps automatically skip it unless the secret is set (it now is, so all envs get metrics)bee-observabilityChanges
Dockerfile— adds Alloy binary fromgrafana/alloy:latestbuild stagealloy.river— new config (was gitignored when it contained hardcoded secrets; now usesenv())scripts/start.sh— new startup script; handles ulimit, starts Alloy in background, thenexec ./mainfly.toml— process updated to./start.shfly-deploy.yml+review-apps.yml—GRAFANA_CLOUD_USERandGRAFANA_CLOUD_API_KEYadded from 1Passwordhover-runtime.gitignore— removedalloy.riverexclusionAfter merging
Suspend the old app once production is confirmed healthy:
Summary by CodeRabbit
New Features
Chores