-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/spring prometheus grafana #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis change integrates Prometheus and Grafana monitoring into a Spring Boot example application by adding corresponding Docker Compose services, configuring Grafana provisioning and dashboards, updating the GitHub Actions workflow to health-check all three containers, and providing project documentation along with a simple REST controller. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (8)
.github/workflows/spring-prometheus-grafana-example.yml(2 hunks)spring-prometheus-grafana-example/README.md(1 hunks)spring-prometheus-grafana-example/compose.yaml(1 hunks)spring-prometheus-grafana-example/docker/dashboards/jvm-metrics-dashboard.json(1 hunks)spring-prometheus-grafana-example/docker/prometheus.yml(1 hunks)spring-prometheus-grafana-example/docker/provisioning/dashboards/dashboards.yml(1 hunks)spring-prometheus-grafana-example/docker/provisioning/datasources/prometheus.yaml(1 hunks)spring-prometheus-grafana-example/src/main/java/com/io/example/controller/TestController.java(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#21
File: spring-kafka-example/README.md:12-17
Timestamp: 2025-07-22T01:35:41.406Z
Learning: User igorcampos-dev prefers minimal, high-level documentation in README files without detailed version specifications, choosing to keep tech stack information simple rather than adding precise version numbers.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#26
File: spring-kafka-example/compose.yaml:3-4
Timestamp: 2025-07-24T01:40:49.337Z
Learning: User igorcampos-dev requires hard-coded container names in Docker Compose files (like `container_name: app`) for CI pipeline validation purposes, which is a valid operational requirement that overrides the general best practice of avoiding hard-coded container names.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#21
File: spring-kafka-example/compose.yaml:30-32
Timestamp: 2025-07-22T01:30:57.054Z
Learning: User igorcampos-dev prefers to maintain environment parity between local development and production, avoiding development-specific configurations like ALLOW_PLAINTEXT_LISTENER even when they might provide clearer intent or safety nets.
spring-prometheus-grafana-example/compose.yaml (1)
Learnt from: igorcampos-dev
PR: #26
File: spring-kafka-example/compose.yaml:3-4
Timestamp: 2025-07-24T01:40:49.337Z
Learning: User igorcampos-dev requires hard-coded container names in Docker Compose files (like container_name: app) for CI pipeline validation purposes, which is a valid operational requirement that overrides the general best practice of avoiding hard-coded container names.
🪛 YAMLlint (1.37.1)
spring-prometheus-grafana-example/docker/provisioning/dashboards/dashboards.yml
[error] 8-8: no new line character at the end of file
(new-line-at-end-of-file)
🪛 LanguageTool
spring-prometheus-grafana-example/README.md
[grammar] ~1-~1: Use correct spacing
Context: # spring-prometheus-grafana-example --- ## Overview This is a basic Java Spring pr...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~10-~10: Use correct spacing
Context: ...ayed in customizable dashboards using Grafana. --- ## Tech stack - Spring Boot - Spring actua...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~14-~14: Use correct spacing
Context: ...dashboards using Grafana. --- ## Tech stack - Spring Boot - Spring actuator - Java 21 ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~20-~20: Use correct spacing
Context: ...Java 21 - Prometheus (Docker) - Grafana (Docker) --- ## Ports | Service | Local URL ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~29-~29: Use correct spacing
Context: ...p://localhost:3000) | none/none | --- ## Related Resources | Description ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~33-~33: Use correct spacing
Context: ... | none/none | --- ## Related Resources | Description ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~42-~42: Use correct spacing
Context: ... | --- ## Dashboards Configured | Name | File Path ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~46-~46: Use correct spacing
Context: ...rafana/dashboards/4701-jvm-micrometer/) | ---
(QB_NEW_EN_OTHER_ERROR_IDS_5)
🔇 Additional comments (3)
spring-prometheus-grafana-example/docker/provisioning/datasources/prometheus.yaml (1)
1-8: LGTM! Well-configured Prometheus datasource.The Prometheus datasource configuration follows best practices:
- Uses Docker service name for internal communication
- Proxy access mode is appropriate for the containerized environment
- Set as default datasource for convenience
spring-prometheus-grafana-example/docker/prometheus.yml (1)
1-8: Adjust scrape interval and verify target accessibilityThe Prometheus configuration is valid, but consider the following for production:
Scrape interval:
– 5s is very aggressive. A 15–30s interval is typically sufficient and more resource-efficient.
– Suggested change:global: - scrape_interval: 5s + scrape_interval: 15sTarget host:
–host.docker.internalworks on Docker Desktop but isn’t universally supported.
– Ensure Prometheus can reach your Spring Boot app’s/actuator/prometheusendpoint in your environment. For example:docker-compose -f spring-prometheus-grafana-example/compose.yaml exec prometheus \ sh -c "curl -f http://host.docker.internal:80/actuator/prometheus | head -5"If this fails, update
static_configs.targetsto a reachable hostname or IP..github/workflows/spring-prometheus-grafana-example.yml (1)
51-76: LGTM! Comprehensive health check integration.The workflow correctly extends the health check to include all monitoring stack components. The implementation properly:
- Adds prometheus and grafana services to the compose action
- Verifies all three containers are running
- Provides clear status output
- Fails appropriately if any service is unhealthy
The hard-coded container names align with your CI pipeline requirements.
spring-prometheus-grafana-example/docker/dashboards/jvm-metrics-dashboard.json
Show resolved
Hide resolved
spring-prometheus-grafana-example/docker/provisioning/dashboards/dashboards.yml
Show resolved
Hide resolved
spring-prometheus-grafana-example/src/main/java/com/io/example/controller/TestController.java
Show resolved
Hide resolved
…ustment name of projects labelers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
♻️ Duplicate comments (2)
spring-prometheus-grafana-example/compose.yaml (2)
13-16:depends_ondirection is still inverted
Prometheus scrapes app and Grafana queries Prometheus, so the dependencies should be the other way around. Retaining this block can delay the app for no reason and even block startup if Prometheus fails.See previous review – recommendation remains to remove
depends_onfromappand adddepends_on: - appunder Prometheus/Grafana if strict ordering is required.
18-21: Prometheus tagv3.5.0does not existThe official image tags follow the
v2.*scheme (e.g.prom/prometheus:v2.52.0). This tag will 404 in CI.-image: prom/prometheus:v3.5.0 +image: prom/prometheus:v2.52.0 # latest stable at time of writing
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/spring-prometheus-grafana-example.yml(2 hunks)spring-prometheus-grafana-example/compose.yaml(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#21
File: spring-kafka-example/README.md:12-17
Timestamp: 2025-07-22T01:35:41.406Z
Learning: User igorcampos-dev prefers minimal, high-level documentation in README files without detailed version specifications, choosing to keep tech stack information simple rather than adding precise version numbers.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#26
File: spring-kafka-example/compose.yaml:3-4
Timestamp: 2025-07-24T01:40:49.337Z
Learning: User igorcampos-dev requires hard-coded container names in Docker Compose files (like `container_name: app`) for CI pipeline validation purposes, which is a valid operational requirement that overrides the general best practice of avoiding hard-coded container names.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#21
File: spring-kafka-example/compose.yaml:30-32
Timestamp: 2025-07-22T01:30:57.054Z
Learning: User igorcampos-dev prefers to maintain environment parity between local development and production, avoiding development-specific configurations like ALLOW_PLAINTEXT_LISTENER even when they might provide clearer intent or safety nets.
.github/workflows/spring-prometheus-grafana-example.yml (1)
Learnt from: igorcampos-dev
PR: #26
File: spring-kafka-example/compose.yaml:3-4
Timestamp: 2025-07-24T01:40:49.337Z
Learning: User igorcampos-dev requires hard-coded container names in Docker Compose files (like container_name: app) for CI pipeline validation purposes, which is a valid operational requirement that overrides the general best practice of avoiding hard-coded container names.
spring-prometheus-grafana-example/compose.yaml (1)
Learnt from: igorcampos-dev
PR: #26
File: spring-kafka-example/compose.yaml:3-4
Timestamp: 2025-07-24T01:40:49.337Z
Learning: User igorcampos-dev requires hard-coded container names in Docker Compose files (like container_name: app) for CI pipeline validation purposes, which is a valid operational requirement that overrides the general best practice of avoiding hard-coded container names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
.github/labeler.yml(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#21
File: spring-kafka-example/README.md:12-17
Timestamp: 2025-07-22T01:35:41.406Z
Learning: User igorcampos-dev prefers minimal, high-level documentation in README files without detailed version specifications, choosing to keep tech stack information simple rather than adding precise version numbers.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#26
File: spring-kafka-example/compose.yaml:3-4
Timestamp: 2025-07-24T01:40:49.337Z
Learning: User igorcampos-dev requires hard-coded container names in Docker Compose files (like `container_name: app`) for CI pipeline validation purposes, which is a valid operational requirement that overrides the general best practice of avoiding hard-coded container names.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#33
File: spring-prometheus-grafana-example/compose.yaml:19-21
Timestamp: 2025-07-26T02:21:49.371Z
Learning: Prometheus Docker images version v3.5.0 and other v3.x.x versions are available on Quay.io (quay.io/prometheus/prometheus) rather than Docker Hub (prom/prometheus), which only hosts v2.x.x versions. The v3.x.x tags may work with prom/prometheus prefix depending on Docker registry resolution configuration.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#21
File: spring-kafka-example/compose.yaml:30-32
Timestamp: 2025-07-22T01:30:57.054Z
Learning: User igorcampos-dev prefers to maintain environment parity between local development and production, avoiding development-specific configurations like ALLOW_PLAINTEXT_LISTENER even when they might provide clearer intent or safety nets.
🔇 Additional comments (1)
.github/labeler.yml (1)
11-13: 👍 Dependency-upgrade label extension looks goodThe additional
spring-prometheus-grafana-example/pom.xmlpath is correctly added and the indentation matches the surrounding YAML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
spring-prometheus-grafana-example/README.md(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#21
File: spring-kafka-example/README.md:12-17
Timestamp: 2025-07-22T01:35:41.406Z
Learning: User igorcampos-dev prefers minimal, high-level documentation in README files without detailed version specifications, choosing to keep tech stack information simple rather than adding precise version numbers.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#26
File: spring-kafka-example/compose.yaml:3-4
Timestamp: 2025-07-24T01:40:49.337Z
Learning: User igorcampos-dev requires hard-coded container names in Docker Compose files (like `container_name: app`) for CI pipeline validation purposes, which is a valid operational requirement that overrides the general best practice of avoiding hard-coded container names.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#33
File: spring-prometheus-grafana-example/compose.yaml:19-21
Timestamp: 2025-07-26T02:21:49.418Z
Learning: Prometheus Docker images version v3.5.0 and other v3.x.x versions are available on Quay.io (quay.io/prometheus/prometheus) rather than Docker Hub (prom/prometheus), which only hosts v2.x.x versions. The v3.x.x tags may work with prom/prometheus prefix depending on Docker registry resolution configuration.
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#21
File: spring-kafka-example/compose.yaml:30-32
Timestamp: 2025-07-22T01:30:57.054Z
Learning: User igorcampos-dev prefers to maintain environment parity between local development and production, avoiding development-specific configurations like ALLOW_PLAINTEXT_LISTENER even when they might provide clearer intent or safety nets.
🪛 LanguageTool
spring-prometheus-grafana-example/README.md
[grammar] ~1-~1: Use correct spacing
Context: # spring-prometheus-grafana-example --- ## Overview This is a basic Java Spring pr...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~10-~10: Use correct spacing
Context: ...ayed in customizable dashboards using Grafana. --- ## Tech stack - Spring Boot - Spring actua...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~14-~14: Use correct spacing
Context: ...dashboards using Grafana. --- ## Tech stack - Spring Boot - Spring actuator - Java 21 ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~20-~20: Use correct spacing
Context: ...Java 21 - Prometheus (Docker) - Grafana (Docker) --- ## Ports | Service | Local URL ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~29-~29: Use correct spacing
Context: ...p://localhost:3000) | admin/admin | --- ## Related Resources | Description ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~33-~33: Use correct spacing
Context: ... | admin/admin | --- ## Related Resources | Description ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~42-~42: Use correct spacing
Context: ... | --- ## Dashboards Configured | Name | File Path ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~46-~46: Use correct spacing
Context: ...rafana/dashboards/4701-jvm-micrometer/) | ---
(QB_NEW_EN_OTHER_ERROR_IDS_5)
🔇 Additional comments (1)
spring-prometheus-grafana-example/README.md (1)
26-30: Table row now matchescompose.yaml– good catch ✅The Grafana credentials were updated to
admin/admin, resolving the mismatch raised in the earlier review.
No further action needed here.
|
Skipped: Cannot respond to another bot. |
Summary by CodeRabbit
New Features
/v1/testthat returns a simple "ok" response.Documentation
Chores