Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexanderlapygin/spring-boot-prometheus

Spring Boot HelloWorld with monitoring on Prometheus
https://github.com/alexanderlapygin/spring-boot-prometheus

actuator java monitoring prometheus softspiders spring spring-boot ss starter template

Last synced: 13 days ago
JSON representation

Spring Boot HelloWorld with monitoring on Prometheus

Awesome Lists containing this project

README

        





# Spring Boot application starter exporting metrics for Prometheus

## Feature tags

- actuator
- maven
- prometheus
- spring-boot
- starter
- swagger
- template

---

## Direct ancestor

[- prometheus](https://github.com/AlexanderLapygin/spring-boot-actuator#readme)

---

## Author

[Alexander Lapygin](https://github.com/AlexanderLapygin) <>

---

## Run

```sh
mvnw spring-boot:run
```

# Check Swagger

Take a look at http://localhost:8080/swagger-ui.html.

# Check Actuator

Take a look at actuator endpoints at http://localhost:8080/actuator.

# Check how the actuator exports metrics for Prometheus

Take a look at actuator endpoints at http://localhost:8080/actuator/prometheus.

# Setting up and running Prometheus locally

To set up Prometheus for monitoring your Spring Boot application, follow these steps:

1. Download the [latest release](https://prometheus.io/download/) of Prometheus for your operating system.
2. Extract the files from the archive.
3. Open the `prometheus.yml` configuration file in a text editor.
4. Add the following job to the `scrape_configs` section:
```yaml
- 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:
```shell
prometheus --config.file=prometheus.yml
```
6. Open Prometheus in your web browser by going to `http://localhost:9090`.
7. 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"}
```
8. Select "Graph" from the top menu.
9. Click the "Execute" button.

That's it! Now you have Prometheus set up to monitor your Spring Boot application and collect metrics.

# Setting up and running Grafana locally

To set up Grafana for monitoring your Spring Boot application, follow these steps:

1. Download the [latest release](https://grafana.com/grafana/download) of Grafana for your operating system.
2. Run the installer and follow the instructions on the screen. Select the installation path and other settings as needed.
3. Start Grafana located in the bin directory from the command line:
```sh
grafana-server
```
4. Open a browser and enter http://localhost:3000/ to open the Grafana web interface.
5. On first launch, you will be prompted to log in. The default administrator username and password is *admin*.
6. After logging in, you can set up data sources and create dashboards to visualize metrics.

### License

Licensed under the [MIT license](./LICENSE)

---

[SOFTSPIDERS](https://github.com/softspiders/softspiders)