Skip to content

Instantly share code, notes, and snippets.

@Marthym
Last active June 11, 2023 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marthym/320fb102c473c17ee31367a067988800 to your computer and use it in GitHub Desktop.
Save Marthym/320fb102c473c17ee31367a067988800 to your computer and use it in GitHub Desktop.
Grafana Stack 📈 2. Collecte des métriques avec OpenTelemetry
---
version: "3.9"
services:
myapp:
image: marthym/myapp:latest
restart: unless-stopped
read_only: true
environment:
- SPRING_MAIN_BANNER-MODE
- SPRING_PROFILES_ACTIVE
networks:
myappnet: {}
prometheus:
image: prom/prometheus:v2.44.0
restart: unless-stopped
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --web.console.libraries=/usr/share/prometheus/console_libraries
- --web.console.templates=/usr/share/prometheus/consoles
volumes:
- /opt/bw/prometheus/:/etc/prometheus/
- prometheus_data:/prometheus
networks:
metrics: {}
opentelemetry:
image: otel/opentelemetry-collector-contrib:0.77.0
user: 0:0
command:
- --config=/etc/otel/receivers.yaml
- --config=/etc/otel/processors.yaml
- --config=/etc/otel/exporters.yaml
- --config=/etc/otel/service.yaml
logging:
driver: local
options:
max-size: 10m
volumes:
- /opt/opentelemetry:/etc/otel:ro
networks:
myappnet: {}
metrics: {}
volumes:
prometheus_data: {}
networks:
metrics: {}
myappnet: {}
exporters:
prometheus:
endpoint: '0.0.0.0:9091'
send_timestamps: true
enable_open_metrics: true
logging:
verbosity: detailed
processors:
batch:
send_batch_size: 10000
send_batch_max_size: 11000
timeout: 10s
---
receivers:
prometheus/myapp:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 15s
metrics_path: '/actuator/prometheus'
# Si vous avez sécurisé la route comme précognisé dans l’article précédent
# basic_auth:
# username: "otel_collector"
# password: "otel_password"
static_configs:
- targets: [myappservice:8081]
labels:
platform: 'prod'
service:
pipelines:
metrics:
receivers: [prometheus/myapp]
processors: [batch]
exporters: [prometheus]
---
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
# scrape_timeout is set to the global default (10s).
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# Le job pour se collecter lui même (optionel)
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
# Le job de collecte OpenTelemetry
- job_name: 'otel-exporter'
scrape_interval: 15s
file_sd_configs:
- files:
- 'targets/otel_targets.yml'
---
- targets:
- 'opentelemetry:9091'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment