Skip to content

Latest commit

 

History

History
101 lines (62 loc) · 4.25 KB

grafana-prometheus.md

File metadata and controls

101 lines (62 loc) · 4.25 KB

GRAFANA AND PROMETHEUS INTEGRATION INTO SPRINGBOOT APPLICATION

STEP -1 : Installation of Grafana And Prometheus

You can download these application by using the below link and follow along the installation guide for your particular type of OS and complete the installation:

https://grafana.com/grafana/download?platform

STEP -2 : Setup inside the Spring Boot Project

Now add the Spring Boot Actuator and Prometheus dependencies in the pom.xml file or you can just copy paste the below dependencies:

SPRING BOOT ACTUATOR DEPENDENCY
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter actuator </artifactId>
</dependency>
PROMETHEUS DEPENDENCY
<dependency>
	<groupId>io.micrometer</groupId>
	<artifactId>micrometer-registry-prometheus</artifactId>
	<scope>runtime</scope>
</dependency>

-After adding the dependency you have to head in to the prometheus folder(check the directory where the prometheus is being installed and open the prometheus folder once it is found and head to the prometheus.yml and add the following:

  • job_name: "spring-actuator"

    metrics_path: "/actuator/prometheus"

    scrape_interval: 5s

    static_configs :

    • targets: ["localhost:8080"]

-It should look something like below.

Screen Shot 2022-08-01 at 2 58 10 PM

  • After the installation is successfully completed, you can check http://localhost:3000/ this is the page for Grafana.

image

  • Create the username and password to sign in.

http://localhost:9090/ this is the page for Prometheus.

image

  • After the page is loaded add the following into the applications.properties file :
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
  • After you are able to see this page, click on the globe icon on the left hand side of the execute button you will get a list of the available metrices as shown below.

image

  • You can choose the one that you want to check the result of.

  • Once you are able to see the result of the selected metrices then it means you prometheus is successfully integrated with your Spring Boot Application.

STEP -3 : Adding Prometheus into Grafana

  • After you can logged into the Grafana server you need to head into “Configuration -> Data Source” option as shown in the below figure.

image

  • Now add Prometheus.

image

image

  • Now finish the above setup window And you have successfully completed Grafana and Prometheus into your project.

STEP -4 : Final

  • After step-3 click on the “+” button as shown below and click on the “create new panel”.

image

  • Add the desired panel by giving the metric in the “Metrics browser” field that’s it Hurray ! you have completed the final step.

image

STEP -5 : Additional tips

  • Instead of adding new panel Manually there are already built Dashboard Online search the most relevant one and add that dashboard into your project.

  • For more detailed information on Integration and Alert creation go through the below video.

REFERENCE VIDEO : https://www.youtube.com/watch?v=gJZhdEJvZmc