Skip to content

Commit

Permalink
first prometheus integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Gorzala committed Nov 21, 2022
1 parent c35d8fd commit 4a9001a
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!target
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

FROM openjdk:17-slim

ADD ./target/dancer.jar /dancer.jar
ADD target/dancer.jar /dancer.jar
CMD ["java", "--enable-preview", "-jar", "/dancer.jar"]
EXPOSE 8080
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
version: '3.8'

services:

dancer:
build: ./
ports:
- "8080:8080"
- "8081:8081"
- "5005:5005"
depends_on:
- dancer-db
environment:
# https://ckinan.com/blog/remote-debug-spring-boot-docker-intellij/:
- JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
dancer-db:
image: postgres:14
restart: always
Expand All @@ -23,3 +35,11 @@ services:
PGADMIN_DEFAULT_PASSWORD: secret
volumes:
- ./volumes/pg-admin-data:/var/lib/pgadmin

prometheus:
image: prom/prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml

4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@
<artifactId>logback-jackson</artifactId>
<version>0.1.5</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
6 changes: 6 additions & 0 deletions prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
scrape_configs:
- job_name: 'spring-actuator'
metrics_path: '/actuator/prometheus'
scrape_interval: 5s
static_configs:
- targets: ['dancer:8081']
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ protected void configure(HttpSecurity http) throws Exception {
.authorizeRequests()
.antMatchers("/authentication/**",
"/profile/checkDancerNameAvailability/*",
"/eventlog/**")
"/eventlog/**",
"/actuator/**"
)
.permitAll()
.anyRequest()
.authenticated();
Expand Down
15 changes: 13 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ spring:
hibernate:
ddl-auto: validate
datasource:
url: jdbc:postgresql://localhost:5432/dancer
url: jdbc:postgresql://dancer-db:5432/dancer
username: dancer
password: dancer
liquibase:
Expand Down Expand Up @@ -69,4 +69,15 @@ logging:
core: INFO
web:
filter:
CommonsRequestLoggingFilter: DEBUG
CommonsRequestLoggingFilter: DEBUG

management:
server:
port: 8081
endpoints:
web:
exposure:
include:
- health
- beans
- prometheus

0 comments on commit 4a9001a

Please sign in to comment.