Skip to content

Commit

Permalink
Configured Prometheus & Grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
mszarlinski committed Sep 14, 2019
1 parent 3fa4433 commit c6b62cd
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 1 deletion.
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3"
services:
app:
image: spring/library:latest
container_name: 'library'
build:
context: ./
dockerfile: Dockerfile
ports:
- '8080:8080'

prometheus:
image: prom/prometheus:v2.4.3
container_name: 'prometheus'
volumes:
- ./monitoring/prometheus:/etc/prometheus/
ports:
- '9090:9090'

grafana:
image: grafana/grafana:5.2.4
container_name: 'grafana'
ports:
- '3000:3000'
volumes:
- ./monitoring/grafana/provisioning/:/etc/grafana/provisioning/
env_file:
- ./monitoring/grafana/config.monitoring
depends_on:
- prometheus
2 changes: 2 additions & 0 deletions monitoring/grafana/config.monitoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GF_SECURITY_ADMIN_PASSWORD=password
GF_USERS_ALLOW_SIGN_UP=false
16 changes: 16 additions & 0 deletions monitoring/grafana/provisioning/datasources/datasource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: 1

deleteDatasources:
- name: Prometheus
orgId: 1

datasources:
- name: Prometheus
type: prometheus
access: proxy
orgId: 1
url: http://prometheus:9090
basicAuth: false
isDefault: true
version: 1
editable: true
11 changes: 11 additions & 0 deletions monitoring/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.

scrape_configs:
- job_name: 'library'
scrape_interval: 10s
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['library:8080']
labels:
application: 'library'
11 changes: 10 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.M1</version>
<version>2.2.0.M6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.pillopl</groupId>
Expand Down Expand Up @@ -64,6 +64,11 @@
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down Expand Up @@ -239,6 +244,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
management:
endpoints:
web:
exposure:
include: info, health, metrics, prometheus

0 comments on commit c6b62cd

Please sign in to comment.