常用指标采集 exporter

1. MySQL

https://github.com/prometheus/mysqld_exporter

可用性

表示MySQL实例是否已停机 mysql_up

表示数据库正常运行的时长,通常使用该指标配置告警,监控运行少于半小时的MySQL实例mysql_global_status_uptime

数据库连接

连接错误是数据库中的主要错误之一,通过该指标可以查看到具体连接错误信息以及错误连接次数。mysql_global_status_connection_errors_total

MySQL实例请求已经连接的线程数。mysql_global_status_threads_connected

MySQL实例请求运行中的线程数。mysql_global_status_threads_running

MySQL实例最大连接记录统计。mysql_global_status_max_used_connections

MySQL实例的最大连接数,若超过该连接数之后有新的请求到来,就会拒绝连接。mysql_global_variables_max_connections

异常中断的连接(尝试连接)。mysql_global_status_aborted_connects

异常中断的连接(超时)。mysql_global_status_aborted_clients

查询

MySQL实例慢查询统计 mysql_global_status_slow_queries

MySQL实例当前查询QPS mysql_global_status_queries

流量

入站流量 mysql_global_status_bytes_received

出站流量 mysql_global_status_bytes_sent

文件

正在打开的文件统计 mysql_global_status_opened_files

MySQL已经打开的文件统计 mysql_global_status_open_files

允许打开的文件统计 mysql_global_variables_open_files_limit

Innodb打开的文件统计 mysql_global_status_innodb_num_open_files

https://blog.youkuaiyun.com/qq_31555951/article/details/109496622
https://help.aliyun.com/zh/prometheus/use-cases/monitor-mysql-databases

2. Redis

https://github.com/oliver006/redis_exporter

Redis实例是否可用 redis_up

连接的客户端数 redis_connected_clients

内存使用率 100 * (redis_memory_used_bytes / redis_memory_max_bytes )

命令执行QPS rate(redis_commands_processed_total[1m])

cache命中QPS irate(redis_keyspace_hits_total[5m])

cache未命中QPS irate(redis_keyspace_misses_total[5m])

网络入流量 rate(redis_net_input_bytes_total[5m])

网络出流量 rate(redis_net_output_bytes_total[5m])

db中的key数量 sum(redis_db_keys) by (db)

db中的过期key数量 sum(redis_db_keys_expiring) by (db)

每一种命令的QPS topk(5, irate(redis_commands_total[1m]))

3. MongoDB

https://github.com/percona/mongodb_exporter
https://github.com/raffis/mongodb-query-exporter

服务器是否在线 mongodb_up

客户端连接数 mongodb_ss_connections{conn_type=“current”}

collection 全部文档的体积,单位 bytes mongodb_collstats_storageStats_size

collection 读操作的数量(每分钟) delta(mongodb_collstats_latencyStats_reads_ops[1m])

collection 读操作的延迟(每分钟),单位为微秒 delta(mongodb_collstats_latencyStats_reads_latency[1m])

collection 的 index 数量 mongodb_collstats_storageStats_nindexes

collection 的 index 占用的磁盘空间 mongodb_collstats_storageStats_totalIndexSize

https://www.cnblogs.com/yangmeichong/p/18156069

4. Kafka

https://github.com/danielqsj/kafka_exporter
https://github.com/prometheus/jmx_exporter
https://cloud.tencent.com/document/product/1416/111833
https://developer.aliyun.com/article/1578308

5. elasticsearch

https://github.com/prometheus-community/elasticsearch_exporter
https://www.cnblogs.com/qianyuliang/p/15410892.html
https://cloud.tencent.com/developer/article/1765046

集群健康和节点可用性

集群状态,green( 所有的主分片和副本分片都正常运行)、yellow(所有的主分片都正常运行,但不是所有的副本分片都正常运行)red(有主分片没能正常运行) elasticsearch_cluster_health_status

集群节点数/数据节点数 elasticsearch_cluster_health_number_of_nodes

活跃的主分片总数 elasticsearch_cluster_health_active_primary_shards

活跃的分片总数(包括复制分片) elasticsearch_cluster_health_active_shards

当前节点正在迁移到其他节点的分片数量,通常为0,集群中有节点新加入或者退出时该值会增加 elasticsearch_cluster_health_relocating_shards

正在初始化的分片 elasticsearch_cluster_health_initializing_shards

未分配的分片数,通常为0,当有节点的副本分片丢失该值会增加 elasticsearch_cluster_health_unassigned_shards

只有主节点能处理集群级元数据的更改(创建索引,更新映射,分配分片等),通过pending-tasks API可以查看队列中等待的任务,绝大部分情况下元数据更改的队列基本上保持为零 elasticsearch_cluster_health_number_of_pending_tasks

主机级别的系统和网络指标

CPU使用率 elasticsearch_process_cpu_percent

磁盘可用空间 elasticsearch_filesystem_data_free_bytes

ES进程打开的文件描述符 elasticsearch_process_open_files_count

ES节点之间网络入流量 elasticsearch_transport_rx_packets_total

ES节点之间网络出流量 elasticsearch_transport_tx_packets_total

JVM内存和垃圾回收

垃圾搜集数 elasticsearch_jvm_gc_collection_seconds_count

垃圾回收时间 elasticsearch_jvm_gc_collection_seconds_sum

最大使用内存限制 elasticsearch_jvm_memory_committed_bytes

内存使用量 elasticsearch_jvm_memory_used_bytes

6. Zookeeper

#比较老旧不推荐
https://github.com/dabealu/zookeeper-exporter
https://github.com/carlpett/zookeeper_exporter/
#jmx方式
https://github.com/prometheus/jmx_exporter/blob/main/example_configs/zookeeper.yaml
https://bbs.huaweicloud.com/blogs/166278

为了更加方便的集成prometheus,建议使用3.6.0以后的版本,因为这个版本以后zookeeper加入了prometheus集成监控,只需要开启zookeeper的指标配置即可。在这个版本之前的zookeeper,可能需要通过JMX进行监控。
启用以下三个属性值即可

##Metrics Providers
#https://prometheus.io Metrics Exporter
metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
metricsProvider.httpPort=7000
metricsProvider.exportJvmInfo=true

7. Nginx

https://github.com/nginxinc/nginx-prometheus-exporter/
https://cloud.tencent.com/document/product/1416/111838

存活状态1正常 0异常 nginx_up

nginx已接受的连接 nginx_connections_accepted

nginx连接活动数 nginx_connections_active

nginx已处理的连接 nginx_connections_handled

nginx连接_读取 nginx_connections_reading

nginx连接_等待 nginx_connections_waiting

nginx连接_写入 nginx_connections_writing

nginx请求总数 nginx_http_requests_total

8. k8s集群node-exporter

https://github.com/prometheus/node_exporter

cpu、内存相关的指标

过去 1 分钟的系统平均负载 node_load1

系统总内存量(以字节为单位) node_memory_MemTotal_bytes

系统当前可用的内存量(以字节为单位) node_memory_MemAvailable_bytes

系统缓存使用的内存(以字节为单位) node_memory_Cached_bytes

用于缓冲使用的内存(以字节为单位) node_memory_Buffers_bytes

计算可用内存百分比 node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100

计算已用内存百分比 (node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes *100

磁盘相关指标

文件系统大小(以字节为单位) node_filesystem_size_bytes

文件系统可用空间(以字节为单位 ) node_filesystem_avail_bytes

计算可用空间百分比 node_filesystem_avail_bytes / node_filesystem_size_bytes * 100

计算已用空间百分比 (node_filesystem_size_bytes - node_filesystem_avail_bytes ) / node_filesystem_size_bytes * 100

磁盘IO吞吐量相关核心指标

从给定设备读取的总字节数。(以字节为单位)。(使用irate可以得到每秒写入大小) node_disk_read_bytes_total

向给定设备写入的总字节数 node_disk_written_bytes_total

磁盘IOPS相关核心指标

磁盘设备完成的读操作总数。(使用irate可以得到每秒读操作的平均数) node_disk_reads_completed_total

磁盘设备完成的写操作总数。(使用irate可以得到每秒读操作的平均数) node_disk_writes_completed_total

网络核心指标

网络接口接收到的总字节数。(以字节为单位) node_network_receive_bytes_total

网络接口发送出去的总字节数。(以字节为单位) node_network_transmit_bytes_total

连接追踪核心指标

系统正在跟踪的网络连接的数量。这包括所有类型的连接,例如 TCP, UDP、ICMP等node_nf_conntrack_entries

系统conntrack 能够跟踪的网络连接的最大数量node_nf_conntrack_entries_limit

TCP与其他相关指标

当前已断开的TCP连接数node_tcp_connection_states{state=“time_wait”}

当前建立的TCP连接数node_tcp_connection_states{state=“established”}

https://www.volcengine.com/docs/6731/189369
### 配置 Prometheus 监控 Kafka 指标 #### 使用 JMX Exporter 方法 为了通过 Prometheus 收集 Kafka 的相关指标,一种常用的方法是利用 JMX Exporter。这涉及几个关键步骤。 安装并配置 JMX Exporter 是第一步。下载适合操作系统的 jmx_prometheus_javaagent 版本[^2]。接着,在 Kafka 启动脚本中加入如下 JVM 参数来加载此代理: ```bash -Djava.agent=/path/to/jmx_prometheus_javaagent.jar=port:/path/to/config.yaml ``` 其中 `port` 表示监听的端口号,而 `/path/to/config.yaml` 则指向自定义的 YAML 文件路径,该文件用于指定哪些 MBeans 将被暴露给 Prometheus 抓取。 完成上述设置之后,重启 Kafka 实例以便使更改生效。此时应该可以通过访问 http://localhost:<port>/metrics 来验证是否有预期的度量标准输出。 接下来调整 Prometheus Server 的 scrape_configs 设置,增加一个新的 job 定义以定期抓取来自 JMX Exporter 的数据点。例如: ```yaml scrape_configs: - job_name: 'kafka' static_configs: - targets: ['<host>:<port>'] ``` 最后一步是在 Grafana 中创建仪表板展示这些收集到的数据。先添加 Prometheus 数据源连接至已部署的服务实例上;随后导入预先设计好的可视化模板或是手动构建图表展现感兴趣的关键性能指示器(KPIs)。 #### 使用 Docker Compose 方便快捷地启动服务 对于希望简化环境搭建过程的情况来说,采用容器化方案不失为一个好的选择。编写 docker-compose.yml 文件描述所需组件及其依赖关系,像这样: ```yaml version: '3' services: prometheus: image: prom/prometheus:v2.30.3 ports: - "9090:9090" volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml grafana: image: grafana/grafana:latest ports: - "3000:3000" kafka-exporter: image: obsidiandynamics/kafka-exporter:main environment: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 depends_on: - zookeeper zookeeper: image: wurstmeister/zookeeper ports: - "2181:2181" ``` 执行命令 `[root@... kafka-exporter]#docker-compose up -d` 可一键拉起整个集群,并自动处理好各部分之间的网络互通问题[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

BUG弄潮儿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值