乐闻世界logo
搜索文章和话题

Prometheus 常用的 Exporter 有哪些,如何选择和使用?

2月21日 15:39

Prometheus 常见 Exporter 及其使用场景:

系统监控 Exporter

  1. Node Exporter

    • 监控 Linux/Unix 系统指标
    • 指标:CPU、内存、磁盘、网络、文件系统
    • 部署:在每个节点上运行
    • 示例指标:node_cpu_seconds_totalnode_memory_MemAvailable_bytes
  2. Windows Exporter

    • 监控 Windows 系统
    • 支持 WMI 性能计数器
    • 指标:CPU、内存、进程、服务

数据库 Exporter

  1. MySQL Exporter

    • 监控 MySQL/MariaDB
    • 指标:连接数、查询性能、复制状态
    • 配置:DSN 连接字符串
    • 示例:mysql_global_status_threads_connected
  2. PostgreSQL Exporter

    • 监控 PostgreSQL
    • 指标:连接、查询、锁、复制
    • 支持扩展指标
  3. Redis Exporter

    • 监控 Redis
    • 指标:内存使用、连接数、命令统计
    • 支持集群模式

应用 Exporter

  1. Blackbox Exporter

    • HTTP/HTTPS、TCP、ICMP 探测
    • 用于可用性监控
    • 配置模块定义探测参数
  2. JMX Exporter

    • 监控 Java 应用
    • 通过 JMX 获取指标
    • 支持 Kafka、Tomcat 等
  3. StatsD Exporter

    • 兼容 StatsD 协议
    • 适合应用埋点

容器和云平台 Exporter

  1. cAdvisor

    • 容器资源使用
    • 集成在 Kubelet
  2. Kube-State-Metrics

    • Kubernetes 对象状态
    • Pod、Deployment、Service 等

部署示例

yaml
scrape_configs: - job_name: 'node' static_configs: - targets: ['node1:9100', 'node2:9100'] - job_name: 'mysql' static_configs: - targets: ['mysql-exporter:9104']

最佳实践

  • 选择合适的 Exporter 版本
  • 配置认证和安全
  • 监控 Exporter 自身健康
  • 使用标签区分不同实例
标签:Prometheus