monitor exporter

OpenTelemetry

1
./otelcol --config=customconfig.yaml

doc https://opentelemetry.io/docs/collector/configuration/

1
2
3
4
❯ ./otelcol validate --config=otel-collector-config.yaml
Error: failed to get config: cannot resolve the configuration: retrieved value (type=string) cannot be used as a Conf
2024/08/23 17:57:26 collector server run finished with error: failed to get config: cannot resolve the configuration: retrieved value (type=string) cannot be used as a Conf
❯ ./otelcol validate --config=otel-collector-config.yaml
otel-collector-config.yaml
otel-collector-config.yaml
##接收器
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
  prometheus:
    config:
     scrape_configs:
       - job_name: 'elasticsearch-monitoring'
         scrape_interval: 10s
         static_configs:
           - targets: ['local.org:9114']
       - job_name: 'skywalking-so11y'
         scrape_interval: 8s
         static_configs:
           - targets: ['local.org:11234']
             labels:
               host_name: http://localhost:11234
               service: oap-server
       - job_name: 'nginx-monitoring'
         scrape_interval: 10s
         metrics_path: "/metrics"
         static_configs:
            - targets: ['local.org:9145']
              labels:
                 service: nginx-service
                 service_instance_id: e2e-test-instance
       # - job_name: 'apisix-monitoring'
       #   scrape_interval: 10s
       #   metrics_path: "/apisix/prometheus/metrics"
       #   static_configs:
       #      - targets: ['local.org:9091']
       #        labels:
       #          skywalking_service: showcase-apisix-service
       - job_name: "vm-monitoring" # make sure to use this in the vm.yaml to filter only VM metrics
         scrape_interval: 10s
         static_configs:
            - targets: ["local.org:9100"]
       - job_name: 'mysql-monitoring'
         scrape_interval: 5s
         static_configs:
           - targets: ['local.org:9104']
             labels:
               host_name: local.org:3305
       - job_name: "postgresql-monitoring"
         scrape_interval: 5s
         static_configs: #["postgres-exporter:9187","postgres-exporter_2:9187","postgres-exporter_3:9187"]
            - targets: ["local.org:9187"]
              labels:
                host_name: local.org:5433
       - job_name: 'redis-monitoring'
         scrape_interval: 5s
         static_configs:
           - targets: ['local.org:9121']
             labels:
               host_name: local.org:9121                

processors: batch:
##导出器 exporters: otlp: endpoint: local.org:11800 tls: insecure: true debug:
##扩展组件 extensions: health_check: endpoint: 0.0.0.0:13133 pprof: endpoint: 0.0.0.0:1888 zpages: endpoint: 0.0.0.0:55679
service: extensions: [health_check, pprof, zpages] pipelines: traces: receivers: [otlp] processors: [batch] exporters: [otlp,debug] metrics: receivers: [otlp,prometheus] processors: [batch] exporters: [otlp,debug] logs: receivers: [otlp] processors: [batch] exporters: [otlp]

exporter

exporter/exporter123

exporter.yaml
docker compose -f ./exporter.yaml up -d
---
version: '3.8'
services:
  node_exporter:
    image: prom/node-exporter:v1.8.2
    container_name: node_exporter
    command:
      - '--path.rootfs=/host'
   #   - '--collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/.+)($|/)'
    ports:
      - "9100:9100/tcp"  
    restart: unless-stopped
    volumes:
      - '/:/host:ro,rslave'
  postgres-exporter:
    image: quay.io/prometheuscommunity/postgres-exporter:v0.15.0
    container_name: postgres_exporter
    extra_hosts:
      - "local.org:192.168.122.1" # 添加主机名
    environment:
     - DATA_SOURCE_NAME=postgres://postgres:123456@local.org:5433/postgres?sslmode=disable
    ports:
      - "9187:9187/tcp"
  mysqld-exporter:
    image: prom/mysqld-exporter:v0.15.1
    container_name: mysqld_exporter
    command:
      - '--mysqld.address=local.org:3305'
      - '--config.my-cnf=/opt/my.cnf'
  #    - '--mysqld.username=exporter'
   # environment:
  #    - MYSQLD_EXPORTER_PASSWORD=exporter123
    volumes:
      - './config/mysql.cnf:/opt/my.cnf'
    ports:
      - "9104:9104/tcp"  
    extra_hosts:
      - "local.org:192.168.122.1" # 添加主机名
  redis-exporter:
    image: oliver006/redis_exporter:v1.62.0
    container_name: redis_exporter
    extra_hosts:
      - "local.org:192.168.122.1" # 添加主机名
    command:
       - '--redis.addr=redis://local.org:9736'
       - '--redis.user=exporter'
       - '--redis.password-file=/opt/redis-pwd.json'
       - '--web.listen-address=0.0.0.0:9121'
       - '--web.telemetry-path=/metrics'
    volumes:
      - './config/redis-pwd.json:/opt/redis-pwd.json'
    ports:
      - "9121:9121/tcp"  
  elasticsearch_exporter:
    image: quay.io/prometheuscommunity/elasticsearch-exporter:v1.7.0
    container_name: es-exporter
    command:
     - '--es.uri=https://elastic:cs123456@es.local.org:9123'
     - '--es.ca=/opt/ca.crt'
     - '--es.client-private-key=/opt/es.key'
     - '--es.client-cert=/opt/es.crt'
     # - '--es.ssl-skip-verify'  #跳过证书验证
     - '--collector.clustersettings'
     - '--collector.snapshots'
     - '--web.telemetry-path=/metrics'
     - '--web.listen-address=:9114'
     - '--es.timeout=15s'
     - '--es.clusterinfo.interval=3m'
    volumes:
      - '/opt/monitor/elasticsearch_exporter-1.7.0/ssl:/opt:ro'
    extra_hosts:
      - "es.local.org:192.168.122.1" # 添加主机名
    ports:
    - "9114:9114"
  otel-collector:
    image: otel/opentelemetry-collector-contrib:0.107.0
    container_name: otel
    volumes:
      - '/opt/monitor/opentelemetry/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml:ro'
    ports:
      - 1888:1888 # pprof extension
      - 8888:8888 # Prometheus metrics exposed by the Collector
      - 8889:8889 # Prometheus exporter metrics
      - 13133:13133 # health_check extension   http://localhost:13133/health
      - 4317:4317 # OTLP gRPC receiver
      - 4318:4318 # OTLP http receiver
      - 56789:55679 # zpages extension   55679/debug/servicez
    depends_on:
      - node_exporter
      - elasticsearch_exporter
    extra_hosts:
      - "local.org:192.168.122.1" # 添加主机名  

#mysql

CREATE USER ‘exporter‘@’localhost’ IDENTIFIED BY ‘exporter123’ WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON . TO ‘exporter‘@’localhost’;

#redis

ACL SETUSER exporter +client +ping +info +config|get +cluster|info +slowlog +latency +memory +select +get +scan +xinfo +type +pfcount +strlen +llen +scard +zcard +hlen +xlen +eval allkeys on >exporter123

点击打赏
文章目录
  1. 1. OpenTelemetry
  2. 2. exporter
载入天数...载入时分秒... ,