- actuator
- maven
- prometheus
- spring-boot
- starter
- swagger
- template
Alexander Lapygin <alexanderlapygin@gmail.com>
mvnw spring-boot:runTake a look at http://localhost:8080/swagger-ui.html.
Take a look at actuator endpoints at http://localhost:8080/actuator.
Take a look at actuator endpoints at http://localhost:8080/actuator/prometheus.
To set up Prometheus for monitoring your Spring Boot application, follow these steps:
- Download the latest release of Prometheus for your operating system.
- Extract the files from the archive.
- Open the
prometheus.ymlconfiguration file in a text editor. - Add the following job to the
scrape_configssection:
- job_name: 'spring'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['localhost:8080']This configuration tells Prometheus to scrape metrics from the /actuator/prometheus endpoint of your Spring Boot application running on localhost:8080.
5. Save the prometheus.yml file and start Prometheus locally by running the prometheus executable:
prometheus --config.file=prometheus.yml- Open Prometheus in your web browser by going to
http://localhost:9090. - In the query field ("Expression"), enter the name of the metric associated with the /hello query. For example, if you used the following configuration to enable /hello monitoring:
http_server_requests_seconds_bucket{uri="/hello"}
- Select "Graph" from the top menu.
- Click the "Execute" button.
That's it! Now you have Prometheus set up to monitor your Spring Boot application and collect metrics.
To set up Grafana for monitoring your Spring Boot application, follow these steps:
- Download the latest release of Grafana for your operating system.
- Run the installer and follow the instructions on the screen. Select the installation path and other settings as needed.
- Start Grafana located in the bin directory from the command line:
grafana-server- Open a browser and enter http://localhost:3000/ to open the Grafana web interface.
- On first launch, you will be prompted to log in. The default administrator username and password is admin.
- After logging in, you can set up data sources and create dashboards to visualize metrics.
Licensed under the MIT license