This repository contains a sample Spring Boot application configured to collect metrics using Prometheus and visualize them using Grafana.
Make sure you have the following installed on your system:
- Java Development Kit (JDK) version 8 or later
- Maven build tool
- Docker (for running Prometheus and Grafana containers)
-
Clone this repository to your local machine:
git clone https://github.com/tusharlimbhore/spring-boot-grafana.git
-
Navigate to the project directory:
cd prometheus-demo
-
Build the Spring Boot application using Maven:
mvn clean package
-
Run the Spring Boot application:
java -jar target/prometheus-demo.jar
-
Start Prometheus and Grafana using Docker Compose:
docker-compose up -d
-
Access Prometheus at http://localhost:9090 and Grafana at http://localhost:3000. Default credentials for Grafana are admin/admin.
-
Configure Prometheus to scrape metrics from the Spring Boot application by adding the following to your
prometheus.yml
file:scrape_configs: - job_name: 'spring-boot-app' metrics_path: '/actuator/prometheus' static_configs: - targets: ['spring-boot-app:8080']
-
Import the Prometheus and Grafana dashboards available in the
dashboards
directory.
- Once the Spring Boot application is running and Prometheus and Grafana are set up, you can access various metrics exposed by the application through Prometheus and visualize them using Grafana dashboards.
- Explore and customize Grafana dashboards as per your requirements.
Contributions are welcome! Please fork this repository, make your changes, and submit a pull request.