Skip to content

Tutorial: Prometheus#3023

Merged
rrayst merged 3 commits into
masterfrom
tutorial-prometheus
Jun 28, 2026
Merged

Tutorial: Prometheus#3023
rrayst merged 3 commits into
masterfrom
tutorial-prometheus

Conversation

@predic8

@predic8 predic8 commented Jun 28, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added a Prometheus tutorial step with a /metrics scraping example and backend traffic to produce observable counters.
    • Added a Grafana tutorial step with Docker Compose setup, including Prometheus scraping and a pre-provisioned “Membrane Minimal” dashboard.
  • Tests
    • Added integration tests verifying the metrics endpoint is reachable and returns Prometheus-formatted output including membrane_count.
  • Documentation
    • Introduced tutorial YAMLs and Grafana/Prometheus configuration snippets to guide scraping and dashboard visualization.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9ebdeaea-bbf6-4e5e-b3d3-35361e2df3f0

📥 Commits

Reviewing files that changed from the base of the PR and between fc9e201 and 3f65150.

📒 Files selected for processing (4)
  • distribution/src/test/java/com/predic8/membrane/tutorials/operation/PrometheusTutorialTest.java
  • distribution/tutorials/operation/50-Prometheus.yaml
  • distribution/tutorials/operation/grafana/docker-compose.yml
  • distribution/tutorials/operation/grafana/provisioning/datasources/datasource.yml
✅ Files skipped from review due to trivial changes (2)
  • distribution/tutorials/operation/grafana/docker-compose.yml
  • distribution/src/test/java/com/predic8/membrane/tutorials/operation/PrometheusTutorialTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • distribution/tutorials/operation/grafana/provisioning/datasources/datasource.yml
  • distribution/tutorials/operation/50-Prometheus.yaml

📝 Walkthrough

Walkthrough

Adds Prometheus and Grafana tutorial steps with metrics scraping, dashboard provisioning, and integration tests that verify the tutorial endpoints and metrics output.

Changes

Metrics Tutorials

Layer / File(s) Summary
Prometheus tutorial and scrape config
distribution/tutorials/operation/50-Prometheus.yaml, distribution/tutorials/operation/prometheus/prometheus.yml
Defines the Prometheus tutorial APIs for the metrics endpoint and backend traffic, plus the Prometheus scrape job targeting the metrics endpoint.
Prometheus tutorial test
distribution/src/test/java/com/predic8/membrane/tutorials/operation/PrometheusTutorialTest.java
PrometheusTutorialTest loads the Prometheus tutorial YAML, triggers backend traffic, and asserts the metrics endpoint returns HTTP 200 with membrane_count.
Grafana tutorial and dashboard stack
distribution/tutorials/operation/60-Grafana.yaml, distribution/tutorials/operation/grafana/docker-compose.yml, distribution/tutorials/operation/grafana/prometheus/prometheus.yml, distribution/tutorials/operation/grafana/provisioning/dashboards/dashboards.yml, distribution/tutorials/operation/grafana/provisioning/datasources/datasource.yml, distribution/tutorials/operation/grafana/dashboards/membrane.json
Defines the Grafana tutorial APIs, Docker Compose services, Prometheus scrape config, Grafana datasource and dashboard provisioning, and the Membrane dashboard JSON.
Grafana tutorial test
distribution/src/test/java/com/predic8/membrane/tutorials/operation/GrafanaTutorialTest.java
GrafanaTutorialTest loads the Grafana tutorial YAML and checks the local endpoints and metrics response used by the tutorial flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • rrayst

Poem

🐇 I hopped through metrics, quick and bright,
Prometheus and Grafana now feel right.
With counters, dashboards, beans of cheer,
The rabbit’s whiskers twitch: “logs are clear!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a Prometheus tutorial and related configs.
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.
✨ 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 tutorial-prometheus

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.

@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: 2

🤖 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
`@distribution/src/test/java/com/predic8/membrane/tutorials/operation/PrometheusTutorialTest.java`:
- Around line 22-25: Update the Javadoc in PrometheusTutorialTest so it matches
the actual endpoint used by the tutorial and assertions. The current reference
to /actuator/prometheus is outdated; change it to /metrics to align with the
test’s behavior and the tutorial config, keeping the description consistent with
the Prometheus tutorial’s real endpoint.

In `@distribution/tutorials/operation/50-Prometheus.yaml`:
- Around line 23-27: The Docker example in the Prometheus tutorial is missing
the host mapping needed for `host.docker.internal` to resolve on Linux. Update
the documented `docker run` command in the Prometheus tutorial so it includes
the host-gateway mapping, or explicitly note a platform-specific alternative,
and keep the example aligned with the scrape config that targets
`host.docker.internal:2000`.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0bb563e8-fb25-4721-9d1b-c2fceae817bc

📥 Commits

Reviewing files that changed from the base of the PR and between d7e3dfa and 0d81fd9.

📒 Files selected for processing (3)
  • distribution/src/test/java/com/predic8/membrane/tutorials/operation/PrometheusTutorialTest.java
  • distribution/tutorials/operation/50-Prometheus.yaml
  • distribution/tutorials/operation/prometheus/prometheus.yml

Comment thread distribution/tutorials/operation/50-Prometheus.yaml

@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: 2

🧹 Nitpick comments (1)
distribution/src/test/java/com/predic8/membrane/tutorials/operation/GrafanaTutorialTest.java (1)

33-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover backend B as well.

60-Grafana.yaml adds a second API on port 2002 returning 404, but this test never hits it. That leaves the tutorial’s status-code path unverified.

Proposed fix
         given()
         .when()
             .get("http://localhost:2001")
         .then()
             .statusCode(200);
+
+        given()
+        .when()
+            .get("http://localhost:2002")
+        .then()
+            .statusCode(404);
 
         given()
         .when()
             .get("http://localhost:2000/metrics")
🤖 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
`@distribution/src/test/java/com/predic8/membrane/tutorials/operation/GrafanaTutorialTest.java`
around lines 33 - 47, The Grafana tutorial test only verifies the backend on
ports 2001 and 2000, so the new backend B status-code path from 60-Grafana.yaml
is not covered. Update metricsEndpointReachableForScraping in
GrafanaTutorialTest to also exercise the API on port 2002 and assert the
expected 404 response, keeping the existing checks for the other endpoints
intact.
🤖 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 `@distribution/tutorials/operation/grafana/dashboards/membrane.json`:
- Around line 26-29: The dashboard panels in membrane.json hard-code a
Prometheus datasource UID that is not provisioned, so update the datasource
references used by the affected panel definitions to match the
provisioned/default datasource instead of PBFA97CFB590B2093. Check the repeated
panel datasource blocks and make the dashboard resolve via the datasource
provisioned in datasource.yml or another stable provisioned reference, so all
queries use the same valid datasource entry.

In `@distribution/tutorials/operation/grafana/docker-compose.yml`:
- Around line 2-9: The Prometheus service in the Grafana docker-compose setup
needs a Linux-compatible host-gateway mapping because it scrapes
host.docker.internal:2000. Update the prometheus service definition to include
an extra_hosts entry mapping host.docker.internal to host-gateway, matching the
tutorial path used by 60-Grafana.yaml so it works reliably on Linux as well as
Docker Desktop.

---

Nitpick comments:
In
`@distribution/src/test/java/com/predic8/membrane/tutorials/operation/GrafanaTutorialTest.java`:
- Around line 33-47: The Grafana tutorial test only verifies the backend on
ports 2001 and 2000, so the new backend B status-code path from 60-Grafana.yaml
is not covered. Update metricsEndpointReachableForScraping in
GrafanaTutorialTest to also exercise the API on port 2002 and assert the
expected 404 response, keeping the existing checks for the other endpoints
intact.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e3e0e5b8-1b2f-42b3-b754-70a3a0fcd998

📥 Commits

Reviewing files that changed from the base of the PR and between 0d81fd9 and fc9e201.

📒 Files selected for processing (7)
  • distribution/src/test/java/com/predic8/membrane/tutorials/operation/GrafanaTutorialTest.java
  • distribution/tutorials/operation/60-Grafana.yaml
  • distribution/tutorials/operation/grafana/dashboards/membrane.json
  • distribution/tutorials/operation/grafana/docker-compose.yml
  • distribution/tutorials/operation/grafana/prometheus/prometheus.yml
  • distribution/tutorials/operation/grafana/provisioning/dashboards/dashboards.yml
  • distribution/tutorials/operation/grafana/provisioning/datasources/datasource.yml
✅ Files skipped from review due to trivial changes (3)
  • distribution/tutorials/operation/grafana/provisioning/datasources/datasource.yml
  • distribution/tutorials/operation/grafana/provisioning/dashboards/dashboards.yml
  • distribution/tutorials/operation/grafana/prometheus/prometheus.yml

Comment thread distribution/tutorials/operation/grafana/dashboards/membrane.json
Comment thread distribution/tutorials/operation/grafana/docker-compose.yml
@predic8 predic8 requested a review from rrayst June 28, 2026 11:36
@predic8 predic8 added this to the 7.3.0 milestone Jun 28, 2026
@rrayst

rrayst commented Jun 28, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@rrayst rrayst merged commit c6256b0 into master Jun 28, 2026
5 checks passed
@rrayst rrayst deleted the tutorial-prometheus branch June 28, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants