Drollery Medieval drollery of a knight on a horse

🏆 欢迎来到本站: https://xuchangwei.com/希望这里有你感兴趣的内容

flowery border with man falling
flowery border with man falling

Linux: Prometheus-exporter

https://prometheus.io/docs/instrumenting/exporters/

指标导出器一些应用现实

数据库

MySQL server exporter

https://github.com/prometheus/mysqld_exporter

数据库授权

CREATE USER 'mysqld_exporter'@'%' IDENTIFIED BY 'hIhO6h_j(azn=F17' WITH MAX_USER_CONNECTIONS 10;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysqld_exporter'@'%';
flush privileges;

准备配置文件

cat <<\EOF> .my.cnf 
[client]
user=xxx
password=xxxxx
[client.servers]
user=mysqld_exporter
password=hIhO6h_j(azn=F17
EOF

启动

cat <<\EOF> docker-compose.yml 
volumes:
networks:
  vm_net:
    name: vm_net
    driver: bridge
    ipam:
      config:
        - subnet: 172.26.0.0/24
services:
  mysqld_exporter:
    image: prom/mysqld-exporter:v0.15.1
    hostname: mysqld-exporter
    container_name: mysqld_exporter
    ports:
      - 9104:9104
    command:
      - "--config.my-cnf=/opt/my.cnf"
    volumes:
      - .my.cnf:/opt/my.cnf
    #restart: always
    networks:
      - vm_net
EOF

验证:

curl 'http://localhost:9104/probe?auth_module=client.servers&target=pc-txxx.mysql.polardb.singapore.rds.aliyuncs.com:3306' | grep mysql_version_info

pormetheus集成

- job_name: mysql
  metrics_path: /probe
  params:
    auth_module: [client.servers]
  static_configs:
  - targets:
    - xx:3306
    labels:
      project: mysql-test
  - targets:
    - 47.xxx:3306
    labels:
      project: mysql-test2

  relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      # The mysqld_exporter host:port
      replacement: 172.xxx:9104

Redis exporter

https://github.com/oliver006/redis_exporter

准备密码文件

cat <<\EOF> redis-pwd-file 
{
  "redis://redis6:6379": "",
  "rediss://replica.redixxxx.com:6379": "tKZyvtON547IfnhX"
}
EOF

启动redis-exporter

cat <<\EOF> docker-compose.yml 
networks:
  vm_net:
    name: vm_net
    driver: bridge
    ipam:
      config:
        - subnet: 172.26.0.0/24
services:
  redis_exporter:
    image: oliver006/redis_exporter:v1.67.0
    container_name: redis_exporter
    ports:
      - 9121:9121
    command:
      - "--redis.password-file=/opt/sample-pwd-file.json"
      - '--debug'
    volumes:
      - ./redis-pwd-file:/opt/sample-pwd-file.json
    networks:
      - vm_net
EOF

验证:

curl http://127.0.0.1:9121/scrape?target=redis://xxxx:6379

pormetheus集成

- job_name: redis-exporter
  metrics_path: /scrape
  static_configs:
  - targets:
    - redis://replica.redixxxx.com:6379
    labels:
      dbtype: "redis"
      project: test
  - targets:
    - redis://xxx:6379
    labels:
      dbtype: "redis"
      project: test2
  relabel_configs:
  - source_labels: [__address__]
    target_label: __param_target
  - source_labels: [__param_target]
    target_label: instance
  - target_label: __address__
    replacement: 172.xxx:9121

MongoDB exporter

https://github.com/percona/mongodb_exporter

启动redis-exporter

cat <<\EOF> docker-compose.yml 
networks:
  vm_net:
    name: vm_net
    driver: bridge
    ipam:
      config:
        - subnet: 172.26.0.0/24
services:
  mongodb-exporter:
    image: percona/mongodb_exporter:0.43
    container_name: mongodb-exporter
    #environment:
    #  MONGODB_URI: "mongodb://user:pass@host1:27017,host2:27017/admin"
    ports:
      - 9216:9216
    command:
      - --mongodb.uri=mongodb://root:dMrMPfSq0gNko14@dxs.com:3717,dds-t4n9s.com:3717/admin?replicaSet=mgset-310035630,mongodb://root:dMrMPfSq0gNko14@dxxcom:3717,ddsxxx:3717/admin?replicaSet=mgset-310037394
      - '--collect-all'
      - '--split-cluster=true'
    networks:
      - vm_net
EOF

验证:

curl 127.0.0.1:9216/scrape?target=mongodb://ddsxxx:3717|grep mongodb_up

pormetheus集成

- job_name: mongodb-exporter
  metrics_path: /scrape
  static_configs:
  - targets:
    - mongodb://dxxx:3717
    labels:
      dbtype: "mongodb"
      project: "测试1"
  - targets:
    - mongodb://ddxxx:3717
    labels:
      dbtype: "mongodb"
      project: "测试2"
  relabel_configs:
  - source_labels: [__address__]
    target_label: __param_target
  - source_labels: [__param_target]
    target_label: instance
  - target_label: __address__
    replacement: 172.xxx:9216

grafana监控:https://github.com/percona/grafana-dashboards/blob/main/dashboards/MongoDB/MongoDB_Cluster_Summary.json

硬件相关

问题跟踪器和持续集成

消息系统

RocketMQ exporter

https://github.com/apache/rocketmq-exporter

启动redis-exporter

cat <<\EOF> docker-compose.yml 
networks:
  vm_net:
    name: vm_net
    driver: bridge
    ipam:
      config:
        - subnet: 172.26.0.0/24
services:
  rocketmq-exporter:
    image: apache/rocketmq-exporter:0.0.2-SNAPSHOT
    container_name: rocketmq-exporter
    ports:
      - 5557:5557
    entrypoint:
      - java
      - -jar
      - rocketmq-exporter.jar
      - --server.port=5557
      - --rocketmq.config.namesrvAddr=127.0.0.1:9876
      - --rocketmq.config.enableACL=true
      - --rocketmq.config.accessKey=C65GKxxxx
      - --rocketmq.config.secretKey=oqHc0xxxx
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 2048M
        reservations:
          cpus: '0.25'
          memory: 256M
    networks:
      - vm_net
EOF

pormetheus集成

- job_name: rocketmq-exporter
  static_configs:
  - targets: ['172.xxx:5557']

存储

HTTP

APIs

日志

金融运营

其他