Skip to content

Commit

Permalink
Added Grafana and Prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
Serwios committed Jul 6, 2024
1 parent 8180d61 commit 98ebad4
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
version: '1'
services:
prometheus:
image: prom/prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus:/etc/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
depends_on:
- app

grafana:
image: grafana/grafana
ports:
- "3000:3000"
depends_on:
- prometheus

db:
image: 'postgres:13.1-alpine'
container_name: db
Expand Down Expand Up @@ -46,3 +64,4 @@ services:
- SPRING_RABBITMQ_PORT=5672
- SPRING_RABBITMQ_USERNAME=alex
- SPRING_RABBITMQ_PASSWORD=alex
- SPRING_PROFILES_ACTIVE=prometheus
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,33 @@
<artifactId>spring-rabbit-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>0.12.0</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_common</artifactId>
<version>0.12.0</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_spring_boot</artifactId>
<version>0.12.0</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
8 changes: 8 additions & 0 deletions prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
global:
scrape_interval: 3s

scrape_configs:
- job_name: 'app'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['app:8080']
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.archivision.community.metric;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MetricsConfiguration {
@Bean
public MeterRegistry meterRegistry() {
return new SimpleMeterRegistry();
}
}
13 changes: 13 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ community:
likes-queue: like-events
payment-queue: payment-events

management:
endpoints:
web:
exposure:
include: info,health,metrics,prometheus
endpoint:
health:
show-details: always
metrics:
enabled: true
prometheus:
enabled: true

spring:
app:
rabbit:
Expand Down

0 comments on commit 98ebad4

Please sign in to comment.