Skip to content

Commit

Permalink
feat: prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomsrs committed Jul 14, 2021
1 parent 24d2a7e commit 3c58d4e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ services:

prometheus:
image: prom/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-volume:/etc/prometheus/
network_mode: bridge
ports:
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ services:

prometheus:
image: prom/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-volume:/etc/prometheus/
network_mode: bridge
ports:
Expand Down
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
26 changes: 26 additions & 0 deletions prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['127.0.0.1:9090']

- job_name: 'spring-actuator'
metrics_path: '/actuator/prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:8080']
6 changes: 5 additions & 1 deletion src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ cartao.host=http://contas/api/cartoes
conta.host=http://contas:8888/api/contas

#Meu sistema
sistema.nome=meu-sistema
sistema.nome=@project.name@

#Prometheus
management.endpoints.web.exposure.include=info,health,prometheus
management.endpoints.prometheus.enabled=true

## spring security resource server configuration
spring.security.oauth2.resourceserver.jwt.issuer-uri=${KEYCLOAK_ISSUER_URI:http://keycloak:18080/auth/realms/master}
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect

#Meu sistema
sistema.nome=meu-sistema
sistema.nome=@project.name@

#Prometheus
management.endpoints.web.exposure.include=info,health,prometheus
management.endpoints.prometheus.enabled=true

#Serviços Externos
solicitacao.host=http://localhost:9999/api/solicitacao
Expand Down

0 comments on commit 3c58d4e

Please sign in to comment.