Skip to content

Conversation

@igorcampos-dev
Copy link
Owner

@igorcampos-dev igorcampos-dev commented Jul 26, 2025

Summary by CodeRabbit

  • New Features

    • Introduced integrated monitoring with Prometheus and Grafana, including pre-configured dashboards for JVM metrics.
    • Added a REST API endpoint at /v1/test that returns a simple "ok" response.
  • Documentation

    • Added comprehensive project documentation with setup instructions, service URLs, and related resources.
  • Chores

    • Enhanced container orchestration to automatically start and health-check Prometheus and Grafana alongside the application.
    • Updated GitHub labeler configuration to include the new monitoring project and adjust label naming.

@coderabbitai
Copy link

coderabbitai bot commented Jul 26, 2025

Walkthrough

This 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

Files/Paths Change Summary
.github/workflows/spring-prometheus-grafana-example.yml Updated workflow to health-check Prometheus and Grafana containers alongside the app container.
spring-prometheus-grafana-example/compose.yaml Added Prometheus and Grafana services, environment variables, and dependencies to Docker Compose configuration.
spring-prometheus-grafana-example/README.md Added project documentation covering setup, technology stack, service URLs, credentials, and dashboard details.
spring-prometheus-grafana-example/docker/prometheus.yml Added Prometheus scrape configuration targeting the Spring Boot app metrics endpoint.
spring-prometheus-grafana-example/docker/provisioning/datasources/prometheus.yaml Added Grafana datasource configuration for Prometheus.
spring-prometheus-grafana-example/docker/provisioning/dashboards/dashboards.yml Added Grafana dashboard provisioning configuration.
spring-prometheus-grafana-example/docker/dashboards/jvm-metrics-dashboard.json Added comprehensive Grafana dashboard JSON for JVM metrics visualization.
spring-prometheus-grafana-example/src/main/java/com/io/example/controller/TestController.java Added a new REST controller exposing a simple "ok" endpoint at /v1/test.
.github/labeler.yml Updated labeler config to add project label for spring-prometheus-grafana-example and rename existing labels.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

component : spring-kafka-example, doc: documentation

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/spring-prometheus-grafana

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0754308 and 504f26a.

📒 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 accessibility

The Prometheus configuration is valid, but consider the following for production:

  1. 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: 15s
  2. Target host:
    host.docker.internal works on Docker Desktop but isn’t universally supported.
    – Ensure Prometheus can reach your Spring Boot app’s /actuator/prometheus endpoint 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.targets to 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.

Copy link

@coderabbitai coderabbitai bot left a 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_on direction 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_on from app and add depends_on: - app under Prometheus/Grafana if strict ordering is required.


18-21: Prometheus tag v3.5.0 does not exist

The 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

📥 Commits

Reviewing files that changed from the base of the PR and between 504f26a and 01ecbc5.

📒 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.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 01ecbc5 and 2e94e24.

📒 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 good

The additional spring-prometheus-grafana-example/pom.xml path is correctly added and the indentation matches the surrounding YAML.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2e94e24 and 65dab16.

📒 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 matches compose.yaml – good catch

The Grafana credentials were updated to admin/admin, resolving the mismatch raised in the earlier review.
No further action needed here.

@coderabbitai
Copy link

coderabbitai bot commented Jul 26, 2025

Skipped: Cannot respond to another bot.

@igorcampos-dev igorcampos-dev merged commit 4f2cfd5 into master Jul 26, 2025
5 checks passed
@igorcampos-dev igorcampos-dev deleted the feature/spring-prometheus-grafana branch July 26, 2025 02:47
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.

2 participants