Локальный стенд OpenTelemetry

Source:: https://github.com/maksim77/otel_dev_stand

.
├── compose.yaml
├── grafana
│   └── datasource.yml
├── LICENSE.md
├── otel
│   └── otel-collector-config.yaml
├── prometheus
│   └── prometheus.yml
├── README.md
└── TODO.md

compose.yml

services:
  prometheus:
    image: prom/prometheus
    container_name: prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
    ports:
      - 9090:9090
    volumes:
      - ./prometheus:/etc/prometheus
 
  grafana:
    image: grafana/grafana
    container_name: grafana
    ports:
      - 3000:3000
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=grafana
    volumes:
      - ./grafana:/etc/grafana/provisioning/datasources
 
  otel-collector:
    image: otel/opentelemetry-collector:latest
    container_name: otel-collector
    command: ["--config=/etc/otel-collector-config.yaml"]
    volumes:
      - ./otel/otel-collector-config.yaml:/etc/otel-collector-config.yaml
    ports:
      - "4317:4317"  # OTLP gRPC receiver
      - "8889:8889"  # Prometheus exposed port
    depends_on:
      - jaeger
 
  jaeger:
    image: jaegertracing/all-in-one:latest
    container_name: jaeger
    environment:
      - COLLECTOR_OTLP_ENABLED=true
      - COLLECTOR_OTLP_GRPC_HOST_PORT=:4317
    ports:
      - "16686:16686"

Prometheus

В папке prometheus находится файл prometheus.yml. Просто собирает метрики со следующих таргетов:

global:
  scrape_interval: 15s
  scrape_timeout: 10s
  evaluation_interval: 15s
alerting:
  alertmanagers:
  - static_configs:
    - targets: []
    scheme: http
    timeout: 10s
    api_version: v2
scrape_configs:
- job_name: prometheus
  honor_timestamps: true
  scrape_interval: 15s
  scrape_timeout: 10s
  metrics_path: /metrics
  scheme: http
  static_configs:
  - targets:
    - localhost:9090
- job_name: grafana
  honor_timestamps: true
  scrape_interval: 15s
  scrape_timeout: 10s
  metrics_path: /metrics
  scheme: http
  static_configs:
  - targets:
    - grafana:3000
- job_name: otel-collector
  honor_timestamps: true
  scrape_interval: 15s
  scrape_timeout: 10s
  metrics_path: /metrics
  scheme: http
  static_configs:
  - targets:
    - otel-collector:8889

Grafana

Для автоматического добавления соседнего Prometheus в папке grafana расположен файл datasource.yml:

apiVersion: 1
 
datasources:
- name: Prometheus
  type: prometheus
  url: http://prometheus:9090 
  isDefault: true
  access: proxy
  editable: true
- name: Jaeger
  type: jaeger
  url: http://jaeger:16686
  access: proxy
  editable: true

Jaeger

В рамках стенда поднимается jaeger-all-in-one. Дополнительных настроек или файлов не требует.

OTEL collector

Настройки находятся в файле otel-collector-config.yaml:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
       endpoint: 0.0.0.0:4318
processors:
exporters:
  otlp:
    endpoint: "http://jaeger:4317"
    tls:
      insecure: true
  debug:
    verbosity: detailed
  prometheus:
    endpoint: 0.0.0.0:8889
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: []
      exporters: [otlp, debug]
    metrics:
      receivers: [otlp]
      processors: []
      exporters: [prometheus, debug]