Skip to content

fix monitoring dashboards and logging - #172

Merged
quarz12 merged 6 commits into
mainfrom
fix-monitoring
Jul 19, 2026
Merged

quarz12 merged 6 commits into
mainfrom
fix-monitoring

Conversation

@quarz12

@quarz12 quarz12 commented Jul 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added automatic log collection for Docker containers and Kubernetes workloads.
    • Added new Grafana dashboards for GenAI and Spring services.
    • Updated dashboard provisioning to use the new default dashboards.
  • Bug Fixes

    • Improved Promtail permissions and log collection reliability.
  • Chores

    • Added deployment-time Promtail diagnostics to simplify troubleshooting of missing logs and monitoring issues.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Promtail now runs as root, gains Docker and Kubernetes log discovery, and emits deployment diagnostics. Grafana provisioning replaces the sample dashboard with GenAI and Spring Services dashboards under a renamed provider.

Changes

Promtail monitoring

Layer / File(s) Summary
Promtail runtime access and diagnostics
infra/ansible/roles/app/templates/docker-compose.prod.yml.j2, infra/ansible/roles/app/tasks/main.yml
Promtail runs as root, while deployment tasks capture Promtail, Docker, container, host filesystem, and Loki diagnostics.
Promtail log discovery
infra/helm/aidan-monitoring/promtail.yml
Promtail discovers Docker containers and Kubernetes pods, relabeling discovered metadata and log paths.

Grafana dashboard provisioning

Layer / File(s) Summary
Dashboard provider and ConfigMap entries
infra/helm/aidan-monitoring/grafana/dashboards/dashboards.yml, infra/helm/aidan-monitoring/templates/configmaps.yaml
The provider name changes, and the ConfigMap provisions genai.json and spring-services.json instead of the sample dashboard.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: kirillinoz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main changes, which update monitoring dashboards and Promtail/logging configuration.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-monitoring

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@quarz12 quarz12 changed the title dashboard loading fix monitoring dashboards and logging Jul 19, 2026
@quarz12
quarz12 temporarily deployed to production-k8s July 19, 2026 15:07 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-azure July 19, 2026 15:07 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Preview deployment

Commit: ba325b6
Image tag: pr-172-ba325b63e9320110504e4e7bbcb4a449bec46435

Monitoring

⚠️ Both previews replace shared environments. A later preview or a deployment from main replaces them; removing the label or closing this PR does not restore main.

@quarz12
quarz12 temporarily deployed to production-k8s July 19, 2026 15:24 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-azure July 19, 2026 15:24 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-k8s July 19, 2026 17:41 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-azure July 19, 2026 17:41 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-k8s July 19, 2026 18:00 — with GitHub Actions Inactive
@quarz12
quarz12 had a problem deploying to production-azure July 19, 2026 18:00 — with GitHub Actions Failure
@quarz12
quarz12 temporarily deployed to production-azure July 19, 2026 18:29 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-k8s July 19, 2026 18:29 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-azure July 19, 2026 18:57 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-k8s July 19, 2026 18:57 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-k8s July 19, 2026 19:28 — with GitHub Actions Inactive
@quarz12
quarz12 had a problem deploying to production-azure July 19, 2026 19:28 — with GitHub Actions Failure
@quarz12
quarz12 temporarily deployed to production-azure July 19, 2026 19:44 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-k8s July 19, 2026 19:44 — with GitHub Actions Inactive
@quarz12
quarz12 marked this pull request as ready for review July 19, 2026 20:25
@quarz12
quarz12 temporarily deployed to production-k8s July 19, 2026 20:28 — with GitHub Actions Inactive
@quarz12
quarz12 temporarily deployed to production-azure July 19, 2026 20:28 — with GitHub Actions Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
infra/ansible/roles/app/templates/docker-compose.prod.yml.j2 (1)

128-130: 🔒 Security & Privacy | 🔵 Trivial

Consider native Docker logging instead of running Promtail as root.

Promtail is configured to run as root and mount the Docker socket to discover and tail container logs. While the socket mount is read-only (mitigating some risks), running as root grants Promtail the ability to read all container environment variables, secrets, and host log directories.

If your primary goal is to ship Docker Compose logs to Loki, consider using the native Docker Loki logging driver instead. This architecture pushes logs directly from the Docker daemon to Loki, entirely eliminating the need for Promtail, root privileges, and socket mounts in your Compose stack.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@infra/ansible/roles/app/templates/docker-compose.prod.yml.j2` around lines
128 - 130, Replace the root-running promtail service with Docker’s native Loki
logging driver for Compose services that need log shipping. Configure the driver
and its Loki connection options at the appropriate Compose scope, then remove
the promtail service and its Docker socket, log-directory, and related mounts
while preserving Loki delivery behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@infra/ansible/roles/app/tasks/main.yml`:
- Around line 207-208: Update the diagnostic command in the task’s container log
directory section to run the /var/lib/docker/containers listing through sudo,
preserving the existing head -20 output limit and diagnostic message.

In `@infra/helm/aidan-monitoring/promtail.yml`:
- Around line 12-16: Update the docker-containers scrape job’s relabel_configs
to construct the Docker container log __path__ from the discovered container ID,
enabling Promtail to read the files. Also add the docker pipeline stage to parse
JSON-wrapped Docker logs correctly, while preserving the existing Docker
discovery configuration.
- Around line 35-40: Update the __path__ relabel rule to use the single capture
group produced by its default regex, removing the invalid $2 reference and
ensuring the replacement glob correctly incorporates the combined pod
UID/container name value.

---

Nitpick comments:
In `@infra/ansible/roles/app/templates/docker-compose.prod.yml.j2`:
- Around line 128-130: Replace the root-running promtail service with Docker’s
native Loki logging driver for Compose services that need log shipping.
Configure the driver and its Loki connection options at the appropriate Compose
scope, then remove the promtail service and its Docker socket, log-directory,
and related mounts while preserving Loki delivery behavior.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c05a957-46d4-47f1-96fb-dc783c8328d7

📥 Commits

Reviewing files that changed from the base of the PR and between b1f358f and ba325b6.

📒 Files selected for processing (5)
  • infra/ansible/roles/app/tasks/main.yml
  • infra/ansible/roles/app/templates/docker-compose.prod.yml.j2
  • infra/helm/aidan-monitoring/grafana/dashboards/dashboards.yml
  • infra/helm/aidan-monitoring/promtail.yml
  • infra/helm/aidan-monitoring/templates/configmaps.yaml

Comment on lines +207 to +208
echo "=== container log dir on host ==="
ls -la /var/lib/docker/containers | head -20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use sudo to access the protected Docker log directory.

The /var/lib/docker/containers directory is typically restricted to root access on the host. Because this task executes as azureuser (become_user: azureuser), this command will fail with a Permission denied error and the intended diagnostic output will be lost.

🛠️ Proposed fix
         echo "=== container log dir on host ==="
-        ls -la /var/lib/docker/containers | head -20
+        sudo ls -la /var/lib/docker/containers | head -20
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "=== container log dir on host ==="
ls -la /var/lib/docker/containers | head -20
echo "=== container log dir on host ==="
sudo ls -la /var/lib/docker/containers | head -20
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@infra/ansible/roles/app/tasks/main.yml` around lines 207 - 208, Update the
diagnostic command in the task’s container log directory section to run the
/var/lib/docker/containers listing through sudo, preserving the existing head
-20 output limit and diagnostic message.

Comment on lines +12 to +16
- job_name: docker-containers
docker_sd_configs:
- host: unix:///var/run/docker.sock
refresh_interval: 5s
relabel_configs:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Set the __path__ label to enable log ingestion for Docker containers.

The docker-containers scrape job discovers container metadata via the Docker socket, but it never sets the __path__ label. Unlike Prometheus, Promtail strictly requires __path__ to know which files to read on the filesystem. Without it, this job will discover targets but fail to ingest any logs.

You must add a relabel rule to construct the log path from the container ID. Additionally, including the docker pipeline stage ensures the JSON-wrapped Docker logs are parsed correctly.

🛠️ Proposed fix
   - job_name: docker-containers
+    pipeline_stages:
+      - docker: {}
     docker_sd_configs:
       - host: unix:///var/run/docker.sock
         refresh_interval: 5s
     relabel_configs:
+      - source_labels: ['__meta_docker_container_id']
+        target_label: '__path__'
+        replacement: '/var/lib/docker/containers/$1/*-json.log'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- job_name: docker-containers
docker_sd_configs:
- host: unix:///var/run/docker.sock
refresh_interval: 5s
relabel_configs:
- job_name: docker-containers
pipeline_stages:
- docker: {}
docker_sd_configs:
- host: unix:///var/run/docker.sock
refresh_interval: 5s
relabel_configs:
- source_labels: ['__meta_docker_container_id']
target_label: '__path__'
replacement: '/var/lib/docker/containers/$1/*-json.log'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@infra/helm/aidan-monitoring/promtail.yml` around lines 12 - 16, Update the
docker-containers scrape job’s relabel_configs to construct the Docker container
log __path__ from the discovered container ID, enabling Promtail to read the
files. Also add the docker pipeline stage to parse JSON-wrapped Docker logs
correctly, while preserving the existing Docker discovery configuration.

Comment on lines +35 to +40
# 3. Automatically map the K8s API log path (Promtail handles the path details behind the scenes)
- action: replace
source_labels: ['__meta_kubernetes_pod_uid', '__meta_kubernetes_pod_container_name']
separator: '/'
target_label: '__path__'
replacement: '/var/log/pods/*$1*/*$2*/*.log'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Fix the logically broken __path__ replacement syntax.

The replacement string '/var/log/pods/*$1*/*$2*/*.log' is broken because no regex is provided. By default, the regex is (.*), which captures the entire concatenated string (<uid>/<container_name>) into $1 and leaves $2 empty.

The resulting __path__ evaluates to /var/log/pods/*<uid>/<container_name>*//*/*.log, which is an invalid glob pattern that will fail to match any K8s pod logs. You can fix this by simplifying the replacement to utilize the single captured group.

🛠️ Proposed fix
       # 3. Automatically map the K8s API log path (Promtail handles the path details behind the scenes)
       - action: replace
         source_labels: ['__meta_kubernetes_pod_uid', '__meta_kubernetes_pod_container_name']
         separator: '/'
         target_label: '__path__'
-        replacement: '/var/log/pods/*$1*/*$2*/*.log'
+        replacement: '/var/log/pods/*$1/*.log'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# 3. Automatically map the K8s API log path (Promtail handles the path details behind the scenes)
- action: replace
source_labels: ['__meta_kubernetes_pod_uid', '__meta_kubernetes_pod_container_name']
separator: '/'
target_label: '__path__'
replacement: '/var/log/pods/*$1*/*$2*/*.log'
# 3. Automatically map the K8s API log path (Promtail handles the path details behind the scenes)
- action: replace
source_labels: ['__meta_kubernetes_pod_uid', '__meta_kubernetes_pod_container_name']
separator: '/'
target_label: '__path__'
replacement: '/var/log/pods/*$1/*.log'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@infra/helm/aidan-monitoring/promtail.yml` around lines 35 - 40, Update the
__path__ relabel rule to use the single capture group produced by its default
regex, removing the invalid $2 reference and ensuring the replacement glob
correctly incorporates the combined pod UID/container name value.

@quarz12
quarz12 requested a review from kirillinoz July 19, 2026 20:37
@quarz12
quarz12 merged commit c070637 into main Jul 19, 2026
45 checks passed
@quarz12
quarz12 deleted the fix-monitoring branch July 19, 2026 21:42

This branch was previously deployed

2 inactive deployments
production-azure — ba325b63 Deployed Jul 19, 2026 by quarz12 via deploy-azure #30
production-k8s — ba325b63 Deployed Jul 19, 2026 by quarz12 via deploy-k8s #30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant