0% found this document useful (0 votes)
3 views3 pages

Prometheus Implementation

This document provides a step-by-step guide on integrating Prometheus with a Spring Boot application using Spring Boot Actuator and Micrometer. It covers adding necessary dependencies for both Maven and Gradle, configuring application properties, verifying the Prometheus endpoint, and setting up a local Prometheus server. Finally, it explains how to start Prometheus and access its UI for querying metrics.

Uploaded by

Learn NewSkill
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Prometheus Implementation

This document provides a step-by-step guide on integrating Prometheus with a Spring Boot application using Spring Boot Actuator and Micrometer. It covers adding necessary dependencies for both Maven and Gradle, configuring application properties, verifying the Prometheus endpoint, and setting up a local Prometheus server. Finally, it explains how to start Prometheus and access its UI for querying metrics.

Uploaded by

Learn NewSkill
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

How to Add Prometheus to a Spring Boot Application

1. Introduction .......................................................................................................... 1
2. Add Required Dependencies (Maven) ...................................................................... 1
3. Add Required Dependencies (Gradle) ..................................................................... 1
4. Configure [Link] ............................................................................ 2
5. Verify the Prometheus Endpoint.............................................................................. 2
6. Configure Prometheus Server (For Locally) .............................................................. 2
7. Start Prometheus .................................................................................................. 3

1. Introduction

Prometheus is an open-source monitoring and alerting toolkit commonly


used with Spring Boot applications. In Spring Boot, Prometheus integration is
typically done using Spring Boot Actuator and Micrometer.

2. Add Required Dependencies (Maven)

Add the following dependencies to your [Link] file:

<dependencies>
<!-- Spring Boot Actuator -->
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- Prometheus Registry -->


<dependency>
<groupId>[Link]</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies>

3. Add Required Dependencies (Gradle)

For Gradle users, add the following to [Link]:

implementation '[Link]:spring-boot-starter-actuator'
implementation '[Link]:micrometer-registry-prometheus'

4. Configure [Link]

Add the following configuration to [Link]:

[Link]=health,info,metrics,prometheus

[Link]=true
[Link]=true
[Link]=true
[Link]=true

[Link]=true
[Link]=true
[Link]=${[Link]}

[Link]-path=/actuator

5. Verify the Prometheus Endpoint

Run your Spring Boot application and access:

[Link]
6. Configure Prometheus Server (For Locally)

Download and install Prometheus.

Edit [Link]:

global:
scrape_interval: 15s

scrape_configs:
- job_name: 'spring-boot-app'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['localhost:8080']

7. Start Prometheus

Run:

prometheus --[Link]=[Link]

Open Prometheus UI:

[Link]

You can now query metrics like:

http_server_requests_seconds_count
jvm_memory_used_bytes

You might also like