跳到主要内容

用夜莺监控 Linux

CPU、内存、磁盘、网络、进程到内核参数,Categraf 装上就有数据,模板覆盖 Categraf、node_exporter 和 Telegraf 三种采集口径。

最后校对于

Linux 主机是绝大多数监控的起点。Categraf 自带的 cpu、mem、disk、diskio、net、netstat、kernel、processes 等插件默认开启,装好就上报,不用额外配置;下面列出的是那些有可调项的插件。

模板里的仪表盘和规则分三套:按 Categraf 指标名写的、按 node_exporter 指标名写的、按 Telegraf 指标名写的。用哪种采集器就导哪一套,混用会看到空面板。规则覆盖了磁盘写满预测、IO 繁忙、conntrack 表、时间漂移、失联等运维上真正会半夜被叫醒的场景。

模板里有什么​

  • 5 张仪表盘,共 71 个面板
  • 60 条告警规则,每条附处置步骤
  • 132 条指标说明
  • Categraf 采集配置:input.arp_packet、input.kernel_vmstat、input.logs-agent、input.netstat、input.node_exporter、input.ntp、input.processes、input.sshd、input.supervisor

怎么接入​

  1. 安装 Categraf,按需启用下面的插件。每个配置放到对应的 conf/input.<插件名>/ 目录,改好地址和凭据后重启 Categraf。

    conf/input.arp_packet/arp_packet.toml

    # # collect interval
    # interval = 15

    [[instances]]
    #eth_device="ens192"

    conf/input.kernel_vmstat/kernel_vmstat.toml

    # # collect interval
    # interval = 15

    # file: /proc/vmstat
    [white_list]
    oom_kill = 1
    nr_free_pages = 0
    nr_alloc_batch = 0
    nr_inactive_anon = 0
    nr_active_anon = 0
    nr_inactive_file = 0
    nr_active_file = 0
    nr_unevictable = 0
    nr_mlock = 0
    nr_anon_pages = 0
    nr_mapped = 0
    nr_file_pages = 0
    nr_dirty = 0
    nr_writeback = 0
    nr_slab_reclaimable = 0
    nr_slab_unreclaimable = 0
    nr_page_table_pages = 0
    nr_kernel_stack = 0
    nr_unstable = 0
    nr_bounce = 0
    nr_vmscan_write = 0
    nr_vmscan_immediate_reclaim = 0
    nr_writeback_temp = 0
    nr_isolated_anon = 0
    nr_isolated_file = 0
    nr_shmem = 0
    nr_dirtied = 0
    nr_written = 0
    numa_hit = 0
    numa_miss = 0
    numa_foreign = 0
    numa_interleave = 0
    numa_local = 0
    numa_other = 0
    workingset_refault = 0
    workingset_activate = 0
    workingset_nodereclaim = 0
    nr_anon_transparent_hugepages = 0
    nr_free_cma = 0
    nr_dirty_threshold = 0
    nr_dirty_background_threshold = 0
    pgpgin = 0
    pgpgout = 0
    pswpin = 0
    pswpout = 0
    pgalloc_dma = 0
    pgalloc_dma32 = 0
    pgalloc_normal = 0
    pgalloc_movable = 0
    pgfree = 0
    pgactivate = 0
    pgdeactivate = 0
    pgfault = 0
    pgmajfault = 0
    pglazyfreed = 0
    pgrefill_dma = 0
    pgrefill_dma32 = 0
    pgrefill_normal = 0
    pgrefill_movable = 0
    pgsteal_kswapd_dma = 0
    pgsteal_kswapd_dma32 = 0
    pgsteal_kswapd_normal = 0
    pgsteal_kswapd_movable = 0
    pgsteal_direct_dma = 0
    pgsteal_direct_dma32 = 0
    pgsteal_direct_normal = 0
    pgsteal_direct_movable = 0
    pgscan_kswapd_dma = 0
    pgscan_kswapd_dma32 = 0
    pgscan_kswapd_normal = 0
    pgscan_kswapd_movable = 0
    pgscan_direct_dma = 0
    pgscan_direct_dma32 = 0
    pgscan_direct_normal = 0
    pgscan_direct_movable = 0
    pgscan_direct_throttle = 0
    zone_reclaim_failed = 0
    pginodesteal = 0
    slabs_scanned = 0
    kswapd_inodesteal = 0
    kswapd_low_wmark_hit_quickly = 0
    kswapd_high_wmark_hit_quickly = 0
    pageoutrun = 0
    allocstall = 0
    pgrotated = 0
    drop_pagecache = 0
    drop_slab = 0
    numa_pte_updates = 0
    numa_huge_pte_updates = 0
    numa_hint_faults = 0
    numa_hint_faults_local = 0
    numa_pages_migrated = 0
    pgmigrate_success = 0
    pgmigrate_fail = 0
    compact_migrate_scanned = 0
    compact_free_scanned = 0
    compact_isolated = 0
    compact_stall = 0
    compact_fail = 0
    compact_success = 0
    htlb_buddy_alloc_success = 0
    htlb_buddy_alloc_fail = 0
    unevictable_pgs_culled = 0
    unevictable_pgs_scanned = 0
    unevictable_pgs_rescued = 0
    unevictable_pgs_mlocked = 0
    unevictable_pgs_munlocked = 0
    unevictable_pgs_cleared = 0
    unevictable_pgs_stranded = 0
    thp_fault_alloc = 0
    thp_fault_fallback = 0
    thp_collapse_alloc = 0
    thp_collapse_alloc_failed = 0
    thp_split = 0
    thp_zero_page_alloc = 0
    thp_zero_page_alloc_failed = 0
    balloon_inflate = 0
    balloon_deflate = 0
    balloon_migrate = 0

    conf/input.logs-agent/logs-agent.toml

    [logs]
    ## just a placholder
    api_key = ""
    ## enable log collect or not
    enable = true
    ## the server receive logs, http/tcp/kafka, only kafka brokers can be multiple ip:ports with concatenation character ","
    send_to = "127.0.0.1:17878"
    ## send logs with protocol: http/tcp/kafka
    send_type = "http"
    topic = "flashcatcloud"
    ## send logs with compression or not
    use_compress = false
    ## use ssl or not
    send_with_tls = false
    ## send logs in batchs
    batch_wait = 5
    ## save offset in this path
    run_path = "/opt/categraf/run"
    ## max files can be open
    open_files_limit = 100
    ## scan config file in 10 seconds
    scan_period = 10
    ## read buffer of udp
    frame_size = 9000

    ## channal size, default 100
    ## 读取日志缓冲区,行数
    chan_size = 1000
    ## pipeline num , default 4
    ## 有多少线程处理日志
    pipeline=4
    ## configuration for kafka
    ## 指定kafka版本
    kafka_version="3.3.2"
    # 默认0 表示串行,如果对日志顺序有要求,保持默认配置
    batch_max_concurrence = 0
    # 最大并发批次, 默认100
    batch_max_size=100
    # 每次最大发送的内容上限 默认1000000
    batch_max_content_size=1000000
    # client timeout in seconds
    producer_timeout= 10

    # 是否开启sasl模式
    sasl_enable = false
    sasl_user = "admin"
    sasl_password = "admin"
    # PLAIN
    sasl_mechanism= "PLAIN"
    # v1
    sasl_version=1
    # set true
    sasl_handshake = true
    # optional
    # sasl_auth_identity=""
    #
    ##
    # v0.3.39以上版本新增,是否开启pod日志采集
    enable_collect_container=false

    # 是否采集所有pod的stdout stderr
    collect_container_all = true
    ## glog processing rules
    # [[logs.Processing_rules]]
    ## single log configure
    [[logs.items]]
    ## file/journald/tcp/udp
    type = "file"
    ## type=file, path is required; type=journald/tcp/udp, port is required
    path = "/opt/tomcat/logs/*.txt"
    source = "tomcat"
    service = "my_service"

    conf/input.netstat/netstat.toml

    # # collect interval
    # interval = 15

    disable_summary_stats = false
    ## if machine has many network connections, use this plugin may exhaust your cpu resource, disable connection stat to avoid this
    disable_connection_stats = true

    tcp_ext = false
    ip_ext = false

    conf/input.node_exporter/node_exporter.toml

    #collectors=[
    # "--path.procfs=/hostfs/proc",
    # "--path.sysfs=/hostfs/sys",
    # "--path.rootfs=/hostfs",
    # "--collector.arp",
    # "--collector.bcache",
    # "--collector.bonding",
    # "--collector.btrfs",
    # "--collector.conntrack",
    # "--collector.cpu",
    # "--collector.cpufreq",
    # "--collector.diskstats",
    # "--collector.dmi",
    # "--collector.edac",
    # "--collector.entropy",
    # "--collector.fibrechannel",
    # "--collector.filefd",
    # "--collector.filesystem",
    # "--collector.hwmon",
    # "--collector.infiniband",
    # "--collector.ipvs",
    # "--collector.loadavg",
    # "--collector.mdadm",
    # "--collector.meminfo",
    # "--collector.netclass",
    # "--collector.netdev",
    # "--collector.netstat",
    # "--collector.nfs",
    # "--collector.nfsd",
    # "--collector.nvme",
    # "--collector.os",
    # "--collector.powersupplyclass",
    # "--collector.pressure",
    # "--collector.rapl",
    # "--collector.schedstat",
    # "--collector.selinux",
    # "--collector.sockstat",
    # "--collector.softnet",
    # "--collector.stat",
    # "--collector.tapestats",
    # "--collector.textfile",
    # "--collector.thermal_zone",
    # "--collector.time",
    # "--collector.timex",
    # "--collector.udp_queues",
    # "--collector.uname",
    # "--collector.vmstat",
    # "--collector.xfs",
    # "--collector.zfs",
    # "--collector.processes"
    #]
    #[[relabel_configs]]
    #source_labels = ["agent_hostname"]
    #target_label = "instance"
    #action = "replace"
    collectors=[]

    conf/input.ntp/ntp.toml

    # # collect interval
    # interval = 15

    # # ntp servers
    # ntp_servers = ["ntp.aliyun.com"]

    # # response time out seconds
    # timeout = 5

    conf/input.processes/processes.toml

    # # collect interval
    # interval = 15

    # # force use ps command to gather
    # force_ps = false

    # # force use /proc to gather
    # force_proc = false

    conf/input.sshd/sshd.toml

    # interval = 15

    #[[instances]]
    # # append labels
    # labels = { region="cloud", product="n9e" }

    # # whether to enable username label in metrics
    # # when enabled, metrics will include username labels for detailed tracking
    # # default: false
    # enable_username = false

    # # whether to enable client_ip label in metrics
    # # when enabled, metrics will include client_ip labels for detailed tracking
    # # default: false
    # enable_ip = false

    conf/input.supervisor/supervisor.toml

    # Gathers information about processes that running under supervisor using XML-RPC API
    [[instances]]
    ## Url of supervisor's XML-RPC endpoint if basic auth enabled in supervisor http server,
    ## than you have to add credentials to url (ex. http://login:pass@localhost:9001/RPC2)
    # url = "http://login:pass@localhost:9001/RPC2"
    ## With settings below you can manage gathering additional information about processes
    ## If both of them empty, then all additional information will be collected.
    ## Currently supported supported additional metrics are: pid, rc
    # metrics_include = []
    # metrics_exclude = ["pid", "rc"]
  2. 在夜莺「集成中心」里找到 Linux,把仪表盘和告警规则导入到业务组。

  3. 导入的告警规则默认是停用的。先确认指标已经入库,再按自己环境的阈值逐条启用。

内置仪表盘​

仪表盘面板数
机器常用指标(如果只想看当前业务组内的机器修改大盘变量 ident 的变量类型为机器标识即可)22
机器台账表格视图(使用 Categraf 作为采集器)3
机器进程数量统计(使用 Categraf 作为采集器)4
Host Table NG1
机器常用指标(使用 NodeExporter 作为采集器)41

内置告警规则​

共 60 条。每条给出触发条件(PromQL)和告警后的处置步骤,导入后可以直接改阈值。

规则按采集方式分组,用哪种采集器就导哪一组。

Categraf 采集(35)​

Conntrack表的使用率超过80%​

S2 警告 · 持续 1 分钟 · 触发条件:

conntrack_ip_conntrack_count / conntrack_ip_conntrack_max > 0.8

处置步骤:

  1. 用 sysctl net.netfilter.nf_conntrack_count 与 nf_conntrack_max 确认当前水位;
  2. 用 conntrack -L | awk '{print $4}' | sort | uniq -c | sort -rn 看连接集中在哪类协议或来源;
  3. 应急调大:sysctl -w net.netfilter.nf_conntrack_max=<更大值>,并同步调大 nf_conntrack_buckets;
  4. 同时缩短 nf_conntrack_tcp_timeout_time_wait 等超时,或对不需要跟踪的流量用 iptables raw 表 NOTRACK。

CPU利用率较高​

S3 提醒 · 持续 1 分钟 · 触发条件:

cpu_usage_active>75

cpu_usage_active>85

cpu_usage_active>95

处置步骤:

  1. 用 top -H 或 pidstat 1 找出占用最高的进程与线程;
  2. 用 perf top 或对应语言的 profiler(Java 用 arthas/async-profiler,Go 用 pprof)定位热点函数;
  3. 区分是业务量自然增长还是代码异常(死循环、正则回溯、频繁 GC);
  4. 业务量增长则扩容或限流,代码问题则修复后发布。

HTTP地址探测失败​

S2 警告 · 持续 1 分钟 · 触发条件:

http_response_result_code != 0

处置步骤:

  1. 在采集机上手工 curl -sv <目标URL> 复现,看是连接失败、超时还是状态码不符;
  2. 连接失败则先确认目标端口通、进程活;
  3. 状态码不符则看目标服务日志定位;
  4. 确认探测配置里的超时、期望状态码、证书校验设置是否与实际相符,避免配置导致的误报。

IO比较繁忙​

S2 警告 · 持续 1 分钟 · 触发条件:

rate(diskio_io_time[1m])/10 > 99

处置步骤:

  1. 用 iostat -x 1 确认是哪块盘、await 与 %util 的具体数值;
  2. 用 iotop -oP 或 pidstat -d 1 找出占用 IO 最高的进程;
  3. 常见元凶是数据库大查询、备份任务、日志刷盘——把可延后的任务错峰执行;
  4. 若是持续高负载而非突发,考虑换 SSD 或把热数据分散到多块盘。

NTP时间偏移太大​

S2 警告 · 持续 1 分钟 · 触发条件:

ntp_offset_ms > 1000 or ntp_offset_ms < -1000

处置步骤:

  1. 用 chronyc tracking(或 ntpq -p)确认当前偏移量与上游源状态;
  2. 上游不可达则检查网络与防火墙是否放行 123/UDP;
  3. 用 chronyc sources -v 确认是否所有源都被标记为不可用,必要时更换 NTP 服务器;
  4. 偏移过大时 chrony 会拒绝平滑校正,需用 chronyc makestep 强制对时(注意对时间敏感的业务先做好准备)。

PING地址探测失败​

S2 警告 · 持续 1 分钟 · 触发条件:

ping_result_code != 0

处置步骤:

  1. 在采集机上手工 ping -c 5 <目标> 复现,再用 mtr -n <目标> 定位丢包出现在哪一跳;
  2. 目标机若存活,确认它是否禁 ICMP(很多安全策略会禁),是则该探测本身不适用,应改用端口探测;
  3. 中间跳丢包的联系网络侧排查;
  4. 确认目标机自身是否宕机或网卡故障。

TME_WAIT状态的连接超过2万,可能需要关注​

S2 警告 · 持续 1 分钟 · 触发条件:

netstat_tcp_time_wait > 20000

处置步骤:

  1. 用 ss -s 确认各状态连接数分布;
  2. 用 ss -tan state time-wait | awk '{print $4}' | cut -d: -f1 | sort | uniq -c | sort -rn 看集中在哪个目标;
  3. 根因通常是短连接过多——在应用侧改用长连接或连接池,这是最有效的手段;
  4. 应急可开启 net.ipv4.tcp_tw_reuse=1 并调大 net.ipv4.ip_local_port_range(不要开 tcp_tw_recycle,NAT 环境下会丢包)。

内存利用率比较高​

S3 提醒 · 持续 1 分钟 · 触发条件:

mem_available_percent < 25

mem_available_percent < 15

mem_available_percent < 5

处置步骤:

  1. 用 free -h 确认 available 与 swap 使用情况;
  2. 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
  3. 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
  4. 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。

文件句柄使用率超过90%​

S2 警告 · 持续 1 分钟 · 触发条件:

linux_sysctl_fs_file_nr/linux_sysctl_fs_file_max>0.9

处置步骤:

  1. 用 cat /proc/sys/fs/file-nr 确认已分配与上限;
  2. 用 lsof | awk '{print $2}' | sort | uniq -c | sort -rn | head 找出占用句柄最多的进程;
  3. 应急调大:sysctl -w fs.file-max=<更大值>,并检查该进程的 ulimit -n 与 systemd LimitNOFILE;
  4. 根因通常是连接或文件未关闭,需在应用侧修复泄漏。

机器监控 - agent失联超过60秒​

触发条件:

处置步骤:

  1. 先用 ping 与 ssh 确认机器本身是否存活,机器宕机要按宕机处理;
  2. 机器存活则用 systemctl status categraf 确认 agent 进程,看日志 journalctl -u categraf -n 100 定位;
  3. 常见原因是 agent 崩溃、配置错误、或到服务端的网络/认证不通——用 curl 手工打一次服务端的写入接口验证;
  4. 恢复后确认数据已连续,注意盲区期间的故障不会有历史告警。

机器监控 - 时间偏移超过3秒,请注意​

持续 1 分钟 · 触发条件:

处置步骤:

  1. 用 date 与 chronyc tracking 确认本机时间与偏移量;
  2. 确认 chronyd/ntpd 服务是否在运行,未运行则启动并设为开机自启;
  3. 检查到 NTP 服务器的网络是否放行 123/UDP,必要时换用内网 NTP 源;
  4. 偏移过大时用 chronyc makestep 强制对时,对时间敏感的业务先做好准备。

每个CPU Core的平均负载任务超过3​

S2 警告 · 持续 1 分钟 · 触发条件:

system_load_norm_1>3

处置步骤:

  1. 用 uptime 看 1/5/15 分钟负载趋势,判断是突发还是持续;
  2. 用 top 看 %wa(IO 等待)——高说明瓶颈在磁盘而非 CPU,按磁盘 IO 处理;
  3. 用 vmstat 1 看 r(运行队列)与 b(阻塞)列区分 CPU 密集与 IO 阻塞;
  4. 定位到具体进程后按 CPU 或 IO 的路径继续排查,必要时扩容。

硬盘监控 - inode使用率超过90%​

S2 警告 · 持续 1 分钟 · 触发条件:

disk_inodes_used/disk_inodes_total >0.9

处置步骤:

  1. 用 df -i 确认是哪个挂载点的 inode 吃紧;
  2. 用 for d in /path/*; do echo "$(find $d | wc -l) $d"; done | sort -rn | head 逐层找出小文件最多的目录;
  3. 常见来源是 session 文件、邮件队列、缓存碎片、未清理的容器层——按业务确认后批量删除;
  4. 长期可在格式化时调大 inode 密度,或把小文件业务迁到独立分区。

硬盘监控 - 大于200G的盘,空间不足了​

S3 提醒 · 持续 1 分钟 · 触发条件:

disk_free/1024/1024/1024 < 20 and disk_total/1024/1024/1024 >= 200

disk_free/1024/1024/1024 < 10 and disk_total/1024/1024/1024 >= 200

disk_free/1024/1024/1024 < 2 and disk_total/1024/1024/1024 >= 200

处置步骤:

  1. 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
  2. 清理日志与过期数据,注意用 lsof +L1 检查已删除但未释放的文件;
  3. 评估是否该把数据目录迁到独立磁盘或加盘扩容;
  4. 若是数据库或对象存储的数据盘,按业务侧的归档策略下沉冷数据。

硬盘监控 - 小于200G的盘,空间不足了​

S3 提醒 · 持续 1 分钟 · 触发条件:

disk_used_percent > 90 and disk_total/1024/1024/1024 < 200

disk_used_percent > 95 and disk_total/1024/1024/1024 < 200

disk_used_percent > 99 and disk_total/1024/1024/1024 < 200

处置步骤:

  1. 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
  2. 系统盘常见是 /var/log 与容器镜像层(docker system df 看占用,docker system prune 清理);
  3. 用 lsof +L1 检查已删除但句柄未释放的文件;
  4. 长期需扩容或把大数据目录迁到独立磁盘。

硬盘监控 - 设备有报错​

S2 警告 · 持续 1 分钟 · 触发条件:

disk_device_error>0

处置步骤:

  1. 用 dmesg -T | grep -iE 'i/o error|ata|scsi' 看内核报的具体错误与设备名;
  2. 用 smartctl -a /dev/sdX 看 SMART 属性,重点关注 Reallocated_Sector_Ct 与 Current_Pending_Sector;
  3. 确认该盘上的数据是否有副本或备份,优先保证数据安全再处理硬件;
  4. 确认为硬件故障的,安排停机换盘,RAID 环境下先确认阵列降级状态再操作。

硬盘监控 - 预测硬盘会在未来4小时内写满​

S1 紧急 · 持续 1 分钟 · 触发条件:

predict_linear(disk_free[1h], 4*3600) < 0

处置步骤:

  1. 用 df -h 确认是哪个挂载点,再用 du -x --max-depth=1 <挂载点> | sort -h 逐层找出增长最快的目录;
  2. 优先清理日志(journalctl --vacuum-size=500M、清 *.log.N)与临时文件,这是最快见效的;
  3. 用 lsof +L1 找出已删除但句柄未释放的文件,重启对应进程才能真正释放空间;
  4. 确认是否有异常写入(应用死循环打日志、备份任务堆积),不解决根因清理只是拖延。

系统有OOM产生​

S2 警告 · 触发条件:

increase(kernel_vmstat_oom_kill[2m]) > 0

处置步骤:

  1. 用 dmesg -T | grep -i 'killed process' 确认被杀的是哪个进程、当时占用多少内存;
  2. 用 free -h 与该进程的内存曲线判断是内存泄漏还是配置的上限过高;
  3. 给关键进程调整 oom_score_adj 降低被杀优先级,同时给次要进程设 cgroup 内存上限;
  4. 根因是泄漏的要在应用侧抓堆定位,只扩内存会反复复发。

网卡监控 - 入方向有丢包​

S3 提醒 · 持续 1 分钟 · 触发条件:

increase(net_drop_in[1m]) > 0

处置步骤:

  1. 用 ip -s link show <网卡> 确认 RX dropped/errors 的增长;
  2. 用 ethtool -S <网卡> 看具体丢包原因(rx_no_buffer、rx_missed_errors 等);
  3. 环形缓冲区不足可用 ethtool -G <网卡> rx <更大值> 调大,并检查 net.core.netdev_max_backlog;
  4. 若伴随 CPU 软中断偏高(top 里 %si),开启 RPS/RSS 把中断分散到多核。

网卡监控 - 入方向有错包​

S3 提醒 · 持续 1 分钟 · 触发条件:

increase(net_err_in[1m]) > 0

处置步骤:

  1. 用 ethtool -S <网卡> 看 rx_crc_errors、rx_frame_errors 等具体计数;
  2. 用 ethtool <网卡> 确认协商的速率与双工模式是否与对端一致(半双工是经典错包源);
  3. 检查网线/光模块,必要时换线或换口做交叉验证;
  4. 联系网络侧确认交换机对应端口的错包计数。

网卡监控 - 出方向有丢包​

S3 提醒 · 持续 1 分钟 · 触发条件:

increase(net_drop_out[1m]) > 0

处置步骤:

  1. 用 ip -s link show <网卡> 确认 TX dropped/errors 的增长;
  2. 用 ethtool -S <网卡> 看具体计数,并用 tc -s qdisc show dev <网卡> 看队列是否溢出;
  3. 发送队列不足可调大 txqueuelen 与 ethtool -G <网卡> tx;
  4. 确认是否已跑满带宽——是则限流或扩带宽,不是则排查网卡驱动与对端设备。

网卡监控 - 出方向有错包​

S3 提醒 · 持续 1 分钟 · 触发条件:

increase(net_err_out[1m]) > 0

处置步骤:

  1. 用 ethtool -S <网卡> 看 tx_errors、tx_carrier_errors 等具体计数;
  2. 用 ethtool <网卡> 确认速率与双工模式与对端一致;
  3. 检查网线/光模块并做交叉验证;
  4. 确认网卡驱动与固件版本,必要时升级。

网络地址探活失败​

S2 警告 · 持续 1 分钟 · 触发条件:

net_response_result_code != 0

处置步骤:

  1. 在采集机上手工 telnet <目标> <端口> 或 nc -vz <目标> <端口> 复现;
  2. 到目标机用 ss -lntp | grep <端口> 确认进程是否在监听;
  3. 进程在监听则排查防火墙、安全组、以及是否只绑定了 127.0.0.1;
  4. 进程不在则按该服务自身的恢复流程拉起。

进程监控-有进程数为0,某进程可能挂了​

S1 紧急 · 持续 1 分钟 · 触发条件:

procstat_lookup_count == 0

处置步骤:

  1. 用 ps -ef | grep <进程关键字> 确认确实不在,排除采集侧的匹配规则写错;
  2. 查该进程的日志与 dmesg -T | grep -i 'killed process',区分自身崩溃、被 OOM 杀死还是人工停止;
  3. 按服务自身流程拉起,并确认 systemd 的 Restart 策略是否生效;
  4. 若反复退出,先定位根因再拉起,避免陷入重启循环。

进程监控-进程句柄限制过小​

S3 提醒 · 持续 1 分钟 · 触发条件:

procstat_rlimit_num_fds_soft < 2048

处置步骤:

  1. 用 cat /proc/<pid>/limits 确认 Max open files 的软硬上限;
  2. systemd 管理的服务在 unit 文件里加 LimitNOFILE=65535 后 systemctl daemon-reload 并重启;
  3. 非 systemd 的在启动脚本里加 ulimit -n 65535,或改 /etc/security/limits.conf;
  4. 注意软上限修改后必须重启进程才生效。

进程监控-进程总量超过600​

S2 警告 · 持续 1 分钟 · 触发条件:

processes_total > 600

处置步骤:

  1. 用 ps -eo ppid | sort | uniq -c | sort -rn | head 找出 fork 子进程最多的父进程;
  2. 确认是正常的多进程模型(如 php-fpm、nginx worker)还是失控 fork;
  3. 失控的先停掉该父进程止血,再修复代码里的 fork 逻辑;
  4. 正常业务增长则调整 worker 数配置并评估是否需要扩容。

Hard disk - expected to be written full in 4 hours - categraf​

S1 紧急 · 持续 1 分钟 · 触发条件:

predict_linear(disk_free[1h], 4*3600) < 0

处置步骤:

  1. 用 df -h 确认是哪个挂载点,再用 du -x --max-depth=1 <挂载点> | sort -h 逐层找出增长最快的目录;
  2. 优先清理日志(journalctl --vacuum-size=500M、清 *.log.N)与临时文件,这是最快见效的;
  3. 用 lsof +L1 找出已删除但句柄未释放的文件,重启对应进程才能真正释放空间;
  4. 确认是否有异常写入(应用死循环打日志、备份任务堆积),不解决根因清理只是拖延。

Hard disk - IO is a bit busy - categraf​

S2 警告 · 持续 1 分钟 · 触发条件:

rate(diskio_io_time[1m])/10 > 99

处置步骤:

  1. 用 iostat -x 1 确认是哪块盘、await 与 %util 的具体数值;
  2. 用 iotop -oP 或 pidstat -d 1 找出占用 IO 最高的进程;
  3. 常见元凶是数据库大查询、备份任务、日志刷盘——把可延后的任务错峰执行;
  4. 若是持续高负载而非突发,考虑换 SSD 或把热数据分散到多块盘。

Lost connection with monitoring target - categraf​

触发条件:

处置步骤:

  1. 先用 ping 与 ssh 确认机器本身是否存活,机器宕机要按宕机处理;
  2. 机器存活则用 systemctl status categraf 确认 agent 进程,看日志 journalctl -u categraf -n 100 定位;
  3. 常见原因是 agent 崩溃、配置错误、或到服务端的网络/认证不通——用 curl 手工打一次服务端的写入接口验证;
  4. 恢复后确认数据已连续,注意盲区期间的故障不会有历史告警。

Machine load - high memory, please pay attention - categraf​

S3 提醒 · 持续 1 分钟 · 触发条件:

mem_available_percent < 25

mem_available_percent < 15

mem_available_percent < 5

处置步骤:

  1. 用 free -h 确认 available 与 swap 使用情况;
  2. 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
  3. 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
  4. 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。

number of TME_WAIT exceeds 20,000 - categraf​

S2 警告 · 持续 1 分钟 · 触发条件:

netstat_tcp_time_wait > 20000

处置步骤:

  1. 用 ss -s 确认各状态连接数分布;
  2. 用 ss -tan state time-wait | awk '{print $4}' | cut -d: -f1 | sort | uniq -c | sort -rn 看集中在哪个目标;
  3. 根因通常是短连接过多——在应用侧改用长连接或连接池,这是最有效的手段;
  4. 应急可开启 net.ipv4.tcp_tw_reuse=1 并调大 net.ipv4.ip_local_port_range(不要开 tcp_tw_recycle,NAT 环境下会丢包)。

packet loss in the inbound direction - categraf​

S3 提醒 · 持续 1 分钟 · 触发条件:

increase(net_drop_in[1m]) > 0

处置步骤:

  1. 用 ip -s link show <网卡> 确认 RX dropped/errors 的增长;
  2. 用 ethtool -S <网卡> 看具体丢包原因(rx_no_buffer、rx_missed_errors 等);
  3. 环形缓冲区不足可用 ethtool -G <网卡> rx <更大值> 调大,并检查 net.core.netdev_max_backlog;
  4. 若伴随 CPU 软中断偏高(top 里 %si),开启 RPS/RSS 把中断分散到多核。

packet loss in the outbound direction - categraf​

S3 提醒 · 持续 1 分钟 · 触发条件:

increase(net_drop_out[1m]) > 0

处置步骤:

  1. 用 ip -s link show <网卡> 确认 TX dropped/errors 的增长;
  2. 用 ethtool -S <网卡> 看具体计数,并用 tc -s qdisc show dev <网卡> 看队列是否溢出;
  3. 发送队列不足可调大 txqueuelen 与 ethtool -G <网卡> tx;
  4. 确认是否已跑满带宽——是则限流或扩带宽,不是则排查网卡驱动与对端设备。

大于200G的盘,空间不足了​

S3 提醒 · 持续 1 分钟 · 触发条件:

disk_free/1024/1024/1024 < 20 and disk_total/1024/1024/1024 >= 200

disk_free/1024/1024/1024 < 10 and disk_total/1024/1024/1024 >= 200

disk_free/1024/1024/1024 < 2 and disk_total/1024/1024/1024 >= 200

处置步骤:

  1. 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
  2. 清理日志与过期数据,注意用 lsof +L1 检查已删除但未释放的文件;
  3. 评估是否该把数据目录迁到独立磁盘或加盘扩容;
  4. 若是数据库或对象存储的数据盘,按业务侧的归档策略下沉冷数据。

小于200G的盘,空间不足了​

S3 提醒 · 持续 1 分钟 · 触发条件:

disk_used_percent > 90 and disk_total/1024/1024/1024 < 200

disk_used_percent > 95 and disk_total/1024/1024/1024 < 200

disk_used_percent > 99 and disk_total/1024/1024/1024 < 200

处置步骤:

  1. 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
  2. 系统盘常见是 /var/log 与容器镜像层(docker system df 看占用,docker system prune 清理);
  3. 用 lsof +L1 检查已删除但句柄未释放的文件;
  4. 长期需扩容或把大数据目录迁到独立磁盘。

Exporter 采集(12)​

A certain disk is unable to read/write normally​

S1 紧急 · 持续 1 分钟 · 触发条件:

(node_filesystem_device_error{mountpoint!~"/var/lib/.*",mountpoint!~"/run.*"}) > 0

处置步骤:

  1. 用 dmesg -T | grep -iE 'i/o error|ata|scsi' 看内核报的具体错误与设备名;
  2. 用 smartctl -a /dev/sdX 看 SMART 属性,重点关注 Reallocated_Sector_Ct 与 Current_Pending_Sector;
  3. 确认该盘上的数据是否有副本或备份,优先保证数据安全再处理硬件;
  4. 确认为硬件故障的,安排停机换盘,RAID 环境下先确认阵列降级状态再操作。

Disk needs to be cleaned - utilization has reached 92% - node exporter​

S1 紧急 · 持续 1 分钟 · 触发条件:

(100 - ((node_filesystem_avail_bytes * 100) / node_filesystem_size_bytes) ) > 92

处置步骤:

  1. 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
  2. 系统盘常见是 /var/log 与容器镜像层(docker system df 看占用,docker system prune 清理);
  3. 用 lsof +L1 检查已删除但句柄未释放的文件;
  4. 长期需扩容或把大数据目录迁到独立磁盘。

Insufficient computational resources - average load per core of the machine is greater than 10 - node exporter​

S2 警告 · 持续 1 分钟 · 触发条件:

avg (node_load1) by (instance)/count(count(node_cpu_seconds_total) by (cpu,instance)) by (instance) >10

处置步骤:

  1. 用 uptime 看 1/5/15 分钟负载趋势,判断是突发还是持续;
  2. 用 top 看 %wa(IO 等待)——高说明瓶颈在磁盘而非 CPU,按磁盘 IO 处理;
  3. 用 vmstat 1 看 r(运行队列)与 b(阻塞)列区分 CPU 密集与 IO 阻塞;
  4. 定位到具体进程后按 CPU 或 IO 的路径继续排查,必要时扩容。

Insufficient file handles - usage exceeds 90% - node exporter​

You can increase the file handle limit or expand the capacity

S2 警告 · 持续 1 分钟 · 触发条件:

(node_filefd_allocated/node_filefd_maximum*100) > 90

处置步骤:

  1. 用 cat /proc/sys/fs/file-nr 确认已分配与上限;
  2. 用 lsof | awk '{print $2}' | sort | uniq -c | sort -rn | head 找出占用句柄最多的进程;
  3. 应急调大:sysctl -w fs.file-max=<更大值>,并检查该进程的 ulimit -n 与 systemd LimitNOFILE;
  4. 根因通常是连接或文件未关闭,需在应用侧修复泄漏。

Insufficient inode resources - usage exceeds 90% - node exporter​

S2 警告 · 持续 1 分钟 · 触发条件:

(100 - ((node_filesystem_files_free * 100) / node_filesystem_files))>90

处置步骤:

  1. 用 df -i 确认是哪个挂载点的 inode 吃紧;
  2. 用 for d in /path/*; do echo "$(find $d | wc -l) $d"; done | sort -rn | head 逐层找出小文件最多的目录;
  3. 常见来源是 session 文件、邮件队列、缓存碎片、未清理的容器层——按业务确认后批量删除;
  4. 长期可在格式化时调大 inode 密度,或把小文件业务迁到独立分区。

Insufficient memory resources - utilization is greater than 75% - node exporter​

Expansion or upgrading of configuration is required

S2 警告 · 持续 1 分钟 · 触发条件:

(node_memory_MemTotal_bytes - node_memory_MemFree_bytes - (node_memory_Cached_bytes + node_memory_Buffers_bytes))/node_memory_MemTotal_bytes*100 > 75

处置步骤:

  1. 用 free -h 确认 available 与 swap 使用情况;
  2. 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
  3. 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
  4. 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。

Insufficient memory resources - utilization is greater than 95% - node exporter​

S1 紧急 · 持续 1 分钟 · 触发条件:

(node_memory_MemTotal_bytes - node_memory_MemFree_bytes - (node_memory_Cached_bytes + node_memory_Buffers_bytes))/node_memory_MemTotal_bytes*100 > 95

处置步骤:

  1. 用 free -h 确认 available 与 swap 使用情况;
  2. 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
  3. 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
  4. 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。

Packet loss in the inbound direction of the network card - node exporter​

S2 警告 · 持续 1 分钟 · 触发条件:

rate(node_network_receive_drop_total{device=~"e.*"}[1m]) > 3

处置步骤:

  1. 用 ip -s link show <网卡> 确认 RX dropped/errors 的增长;
  2. 用 ethtool -S <网卡> 看具体丢包原因(rx_no_buffer、rx_missed_errors 等);
  3. 环形缓冲区不足可用 ethtool -G <网卡> rx <更大值> 调大,并检查 net.core.netdev_max_backlog;
  4. 若伴随 CPU 软中断偏高(top 里 %si),开启 RPS/RSS 把中断分散到多核。

Packet loss in the outbound direction of the network card - node exporter​

S2 警告 · 持续 1 分钟 · 触发条件:

rate(node_network_transmit_drop_total{device=~"e.*"}[1m]) > 3

处置步骤:

  1. 用 ip -s link show <网卡> 确认 TX dropped/errors 的增长;
  2. 用 ethtool -S <网卡> 看具体计数,并用 tc -s qdisc show dev <网卡> 看队列是否溢出;
  3. 发送队列不足可调大 txqueuelen 与 ethtool -G <网卡> tx;
  4. 确认是否已跑满带宽——是则限流或扩带宽,不是则排查网卡驱动与对端设备。

System conntrack needs to be adjusted - usage exceeds 80% - node exporter​

S2 警告 · 持续 1 分钟 · 触发条件:

node_nf_conntrack_entries / node_nf_conntrack_entries_limit*100 > 80

处置步骤:

  1. 用 sysctl net.netfilter.nf_conntrack_count 与 nf_conntrack_max 确认当前水位;
  2. 用 conntrack -L | awk '{print $4}' | sort | uniq -c | sort -rn 看连接集中在哪类协议或来源;
  3. 应急调大:sysctl -w net.netfilter.nf_conntrack_max=<更大值>,并同步调大 nf_conntrack_buckets;
  4. 同时缩短 nf_conntrack_tcp_timeout_time_wait 等超时,或对不需要跟踪的流量用 iptables raw 表 NOTRACK。

System experiences OOM - node exporter​

S2 警告 · 持续 1 分钟 · 触发条件:

increase(node_vmstat_oom_kill[1m]) > 0

处置步骤:

  1. 用 dmesg -T | grep -i 'killed process' 确认被杀的是哪个进程、当时占用多少内存;
  2. 用 free -h 与该进程的内存曲线判断是内存泄漏还是配置的上限过高;
  3. 给关键进程调整 oom_score_adj 降低被杀优先级,同时给次要进程设 cgroup 内存上限;
  4. 根因是泄漏的要在应用侧抓堆定位,只扩内存会反复复发。

Too many running processes - exceeding 3000 - node exporter​

S2 警告 · 持续 1 分钟 · 触发条件:

node_procs_running > 3000

处置步骤:

  1. 用 ps -eo ppid | sort | uniq -c | sort -rn | head 找出 fork 子进程最多的父进程;
  2. 确认是正常的多进程模型(如 php-fpm、nginx worker)还是失控 fork;
  3. 失控的先停掉该父进程止血,再修复代码里的 fork 逻辑;
  4. 正常业务增长则调整 worker 数配置并评估是否需要扩容。

Telegraf 采集(13)​

Address is unreachable by PING, please pay attention - telegraf​

S1 紧急 · 持续 1 分钟 · 触发条件:

ping_result_code != 0

处置步骤:

  1. 在采集机上手工 ping -c 5 <目标> 复现,再用 mtr -n <目标> 定位丢包出现在哪一跳;
  2. 目标机若存活,确认它是否禁 ICMP(很多安全策略会禁),是则该探测本身不适用,应改用端口探测;
  3. 中间跳丢包的联系网络侧排查;
  4. 确认目标机自身是否宕机或网卡故障。

Hard disk - expected to be written full in 4 hours - telegraf​

S1 紧急 · 持续 1 分钟 · 触发条件:

predict_linear(disk_free[1h], 4*3600) < 0

处置步骤:

  1. 用 df -h 确认是哪个挂载点,再用 du -x --max-depth=1 <挂载点> | sort -h 逐层找出增长最快的目录;
  2. 优先清理日志(journalctl --vacuum-size=500M、清 *.log.N)与临时文件,这是最快见效的;
  3. 用 lsof +L1 找出已删除但句柄未释放的文件,重启对应进程才能真正释放空间;
  4. 确认是否有异常写入(应用死循环打日志、备份任务堆积),不解决根因清理只是拖延。

Hard disk - IO is very busy - telegraf​

S2 警告 · 持续 1 分钟 · 触发条件:

rate(diskio_io_time[1m])/10 > 99

处置步骤:

  1. 用 iostat -x 1 确认是哪块盘、await 与 %util 的具体数值;
  2. 用 iotop -oP 或 pidstat -d 1 找出占用 IO 最高的进程;
  3. 常见元凶是数据库大查询、备份任务、日志刷盘——把可延后的任务错峰执行;
  4. 若是持续高负载而非突发,考虑换 SSD 或把热数据分散到多块盘。

Lost connection with monitoring target - telegraf​

触发条件:

处置步骤:

  1. 先用 ping 与 ssh 确认机器本身是否存活,机器宕机要按宕机处理;
  2. 机器存活则用 systemctl status categraf 确认 agent 进程,看日志 journalctl -u categraf -n 100 定位;
  3. 常见原因是 agent 崩溃、配置错误、或到服务端的网络/认证不通——用 curl 手工打一次服务端的写入接口验证;
  4. 恢复后确认数据已连续,注意盲区期间的故障不会有历史告警。

Machine load - high CPU, please pay attention - telegraf​

S3 提醒 · 持续 1 分钟 · 触发条件:

cpu_usage_idle{cpu="cpu-total"} < 25

处置步骤:

  1. 用 top -H 或 pidstat 1 找出占用最高的进程与线程;
  2. 用 perf top 或对应语言的 profiler(Java 用 arthas/async-profiler,Go 用 pprof)定位热点函数;
  3. 区分是业务量自然增长还是代码异常(死循环、正则回溯、频繁 GC);
  4. 业务量增长则扩容或限流,代码问题则修复后发布。

Machine load - high memory, please pay attention - telegraf​

S2 警告 · 持续 1 分钟 · 触发条件:

mem_available_percent < 25

处置步骤:

  1. 用 free -h 确认 available 与 swap 使用情况;
  2. 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
  3. 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
  4. 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。

Network connection - number of TME_WAIT exceeds 20,000 - telegraf​

S2 警告 · 持续 1 分钟 · 触发条件:

netstat_tcp_time_wait > 20000

处置步骤:

  1. 用 ss -s 确认各状态连接数分布;
  2. 用 ss -tan state time-wait | awk '{print $4}' | cut -d: -f1 | sort | uniq -c | sort -rn 看集中在哪个目标;
  3. 根因通常是短连接过多——在应用侧改用长连接或连接池,这是最有效的手段;
  4. 应急可开启 net.ipv4.tcp_tw_reuse=1 并调大 net.ipv4.ip_local_port_range(不要开 tcp_tw_recycle,NAT 环境下会丢包)。

packet loss in the inbound direction - telegraf​

S3 提醒 · 持续 1 分钟 · 触发条件:

increase(net_drop_in[1m]) > 0

处置步骤:

  1. 用 ip -s link show <网卡> 确认 RX dropped/errors 的增长;
  2. 用 ethtool -S <网卡> 看具体丢包原因(rx_no_buffer、rx_missed_errors 等);
  3. 环形缓冲区不足可用 ethtool -G <网卡> rx <更大值> 调大,并检查 net.core.netdev_max_backlog;
  4. 若伴随 CPU 软中断偏高(top 里 %si),开启 RPS/RSS 把中断分散到多核。

packet loss in the outbound direction - telegraf​

S3 提醒 · 持续 1 分钟 · 触发条件:

increase(net_drop_out[1m]) > 0

处置步骤:

  1. 用 ip -s link show <网卡> 确认 TX dropped/errors 的增长;
  2. 用 ethtool -S <网卡> 看具体计数,并用 tc -s qdisc show dev <网卡> 看队列是否溢出;
  3. 发送队列不足可调大 txqueuelen 与 ethtool -G <网卡> tx;
  4. 确认是否已跑满带宽——是则限流或扩带宽,不是则排查网卡驱动与对端设备。

Port detection failed, please pay attention - telegraf​

S1 紧急 · 持续 1 分钟 · 触发条件:

net_response_result_code != 0

处置步骤:

  1. 在采集机上手工 telnet <目标> <端口> 或 nc -vz <目标> <端口> 复现;
  2. 到目标机用 ss -lntp | grep <端口> 确认进程是否在监听;
  3. 进程在监听则排查防火墙、安全组、以及是否只绑定了 127.0.0.1;
  4. 进程不在则按该服务自身的恢复流程拉起。

process handle limit is too small - telegraf​

S3 提醒 · 持续 1 分钟 · 触发条件:

procstat_rlimit_num_fds_soft < 2048

处置步骤:

  1. 用 cat /proc/<pid>/limits 确认 Max open files 的软硬上限;
  2. systemd 管理的服务在 unit 文件里加 LimitNOFILE=65535 后 systemctl daemon-reload 并重启;
  3. 非 systemd 的在启动脚本里加 ulimit -n 65535,或改 /etc/security/limits.conf;
  4. 注意软上限修改后必须重启进程才生效。

Process monitoring - lookup failure - telegraf​

S1 紧急 · 持续 1 分钟 · 触发条件:

procstat_lookup_result_code != 0

处置步骤:

  1. 在采集机上按配置的匹配方式手工执行 ps/pgrep 复现;
  2. 进程确实不在则按服务恢复流程处理;
  3. 进程在但探测失败,检查 procstat 配置的 pid_file、exe、pattern 是否写错,以及采集账号是否有权限读取 /proc;
  4. 容器环境下确认 categraf 是否挂载了宿主机的 /proc。

there are processes with 0 count, a certain process may have crashed - telegraf​

S1 紧急 · 持续 1 分钟 · 触发条件:

procstat_lookup_running == 0

处置步骤:

  1. 用 ps -ef | grep <进程关键字> 确认确实不在,排除采集侧的匹配规则写错;
  2. 查该进程的日志与 dmesg -T | grep -i 'killed process',区分自身崩溃、被 OOM 杀死还是人工停止;
  3. 按服务自身流程拉起,并确认 systemd 的 Restart 策略是否生效;
  4. 若反复退出,先定位根因再拉起,避免陷入重启循环。

指标说明​

共 132 条,和仪表盘、告警规则里用到的指标一一对应。

指标含义单位
cpu_usage_guestCPU Guest 时间占比 — CPU 为 Guest OS 运行虚拟 CPU 的时间占比。 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值%
cpu_usage_iowaitCPU iowait 时间占比 — 表示 CPU 花费在等待 I/O 操作(输入/输出)完成的时间比例; 标签 cpu="cpu-total",表示整机的 iowait 占用率; 标签 cpu="0",表示 0 号 CPU 的 iowait 占用率%
cpu_usage_stealCPU Steal 时间占比 — 表示虚拟机(Guest OS)CPU 时间被虚拟化管理器(Hypervisor)用于运行其他虚拟机的时间比例。物理机中这个指标值是 0,没有用处;虚拟机中这个指标值长时间大于 10 表示争抢严重。参考资料; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值%
cpu_usage_niceCPU 低优先级进程的时间占比 — 在Linux系统中,每个进程都有一个“nice”值,这个值的范围通常是从-20到19。默认的 nice 值为0。负的 nice 值表示高优先级(更快的 CPU 访问),而正的 nice 值表示低优先级(更慢的 CPU 访问)。该指标统计 nice 值为 1-19 的进程的时间占比。 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值%
cpu_usage_systemCPU 内核态时间占比 — 表示 CPU 内核态的时间占比; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值%
cpu_usage_activeCPU 利用率 — - 标签 cpu="cpu-total",表示整机的 CPU 利用率; 标签 cpu="0",表示 0 号 CPU 的单核利用率%
cpu_usage_userCPU 用户态时间占比 — 表示 CPU 用户态的时间占比; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值%
cpu_usage_irqCPU 硬中断时间占比 — 表示 CPU 处理硬中断的时间占比; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值%
cpu_usage_idleCPU 空闲率 — - 标签 cpu="cpu-total",表示整机的 CPU 空闲率; 标签 cpu="0",表示 0 号 CPU 的单核空闲率%
cpu_usage_softirqCPU 软中断时间占比 — 表示 CPU 处理软中断的时间占比; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值%
netstat_tcp_establishedESTABLISHED 状态的网络链接数
netstat_tcp_fin_wait1FIN_WAIT1 状态的网络链接数
netstat_tcp_fin_wait2FIN_WAIT2 状态的网络链接数
100 * conntrack_ip_conntrack_count / conntrack_ip_conntrack_maxIP conntrack 使用率 — 如果用满了,通常会在系统日志中看到:conntrack table full 这样的报错,可以调整系统最大值解决%
netstat_tcp_last_ackLAST_ACK 状态的网络链接数
netstat_tcp_listenLISTEN 状态的网络链接数
100 * conntrack_nf_conntrack_count / conntrack_nf_conntrack_maxNF conntrack 使用率%
increase(kernel_vmstat_oom_kill[1m])1分钟内 OOM 次数统计 — 取自 /proc/vmstat,需要较高版本的内核,没记错的话应该是 4.13 以上版本
netstat_tcp_syn_recvSYN_RECV 状态的网络链接数
netstat_tcp_syn_sentSYN_SENT 状态的网络链接数
netstat_tcp_time_waitTIME_WAIT 状态的网络链接数 — categraf 配置文件 conf/input.netstat/netstat.toml 中 disable_connection_stats 默认配置为 true,是因为在网络连接比较多的机器上,获取各个状态的连接数会耗费较多 CPU,所以默认 disable 掉了。
netstat_tcp_twTIME_WAIT 状态的网络链接数(推荐) — 读取自 /proc/net/sockstat。
(mem_swap_total - mem_swap_free)/mem_swap_total * 100 and mem_swap_total > 0交换空间使用率 — 交换空间使用率。计算原子取自 /proc/meminfo。%
mem_swap_total - mem_swap_free交换空间使用量 — 交换空间使用量。计算原子取自 /proc/meminfo。bytes
mem_swap_total交换空间总量 — 交换空间总量。取自 /proc/meminfo。bytes
mem_swap_free交换空间空闲量 — 交换空间空闲量。取自 /proc/meminfo。bytes
mem_buffered内存 Buffered 量 — 用作缓冲区的内存量。取自 /proc/meminfo。bytes
mem_cached内存 Cached 量 — 用作文件缓存的内存量。取自 /proc/meminfo。bytes
mem_used_percent内存使用率 — 内存使用率%
100 - mem_available_percent内存使用率(基于MemAvailable) — 内存使用率。基于 MemAvailable 计算更准确,但是老版本的 Linux 不支持。%
mem_used内存使用量 — 内存使用量 = Total - Free - Buffered - Cachedbytes
mem_available_percent内存可用率 — 可以立即分配给进程的可用内存量除以内存总量。分子分母的值均取自 /proc/meminfo。%
mem_available内存可用量 — 可以立即分配给进程的可用内存量。取自 /proc/meminfo。bytes
mem_total内存总量 — 内存总量。取自 /proc/meminfo。bytes
mem_active内存活跃量 — 这个字段表示当前活跃使用的内存总量,即系统最近访问过并且预计很快会再次使用的内存页面。取自 /proc/meminfo。bytes
mem_free内存空闲量 — 未使用的内存量。取自 /proc/meminfo。bytes
mem_inactive内存非活跃量 — 在上一采样周期未以某种方式使用的内存量。取自 /proc/meminfo。bytes
netstat_udp_socket当前 UDP 连接数
disk_inodes_used / disk_inodes_total * 100硬盘 inode 使用率 — 如果存储了很多小文件,需要注意 inode 使用情况。%
disk_inodes_used硬盘 inode 使用量 — 如果存储了很多小文件,需要注意 inode 使用情况。
disk_inodes_free硬盘 inode 剩余量 — 如果存储了很多小文件,需要注意 inode 使用情况。
disk_inodes_total硬盘 inode 总量 — 如果存储了很多小文件,需要注意 inode 使用情况。
irate(diskio_write_time[2m])/irate(diskio_writes[2m])硬盘 IO - 写请求平均耗时ms
diskio_write_time硬盘 IO - 写请求等待处理的时间 — 写入请求在磁盘上等待的时间。同时等待的多个写入请求会增加该数字。例如,如果 8 个请求均平均等待 1000 毫秒,则报告 8000。ms
diskio_weighted_io_time硬盘 IO - 加权 IO 处理时间 — 只要设备在处理 IO,不管同时处理了几个,diskio_io_time 就会递增;同时处理的 IO 数量乘以时间就得到加权的值:diskio_weighted_io_time。ms
irate(diskio_io_time[2m])/1000*100硬盘 IO - 时间维度 Utilization — 在时间维度统计硬盘 IO 时间占比,比如该值是 50%,表示有 50% 的时间是在处理 IO,该值 100%,表示一直在处理 IO,但是注意,现代磁盘设备具备并行处理多个 I/O 请求的能力,所以即便该值是 100%,可能硬盘还是可以接收新的处理请求。 比如某人有两只手,最近 1 分钟一直在用单手劳动,从时间维度来看,利用率是 100%,但即便是 100%,再给他更多的活,他也能干,因为他还有一只手可用。%
irate(diskio_write_bytes[2m])硬盘 IO - 每秒写入字节数量bytes/s
irate(diskio_writes{}[2m])硬盘 IO - 每秒写次数
irate(diskio_merged_writes[2m])硬盘 IO - 每秒合并写请求次数 — 相邻的读取和写入可能会为了效率而被合并。因此,在最终交给磁盘之前,两个4K的读取可能会变成一个8K的读取,因此它将被计数(和排队)为仅有一个I/O。这些字段让你知道这种情况发生的频率。
irate(diskio_merged_reads[2m])硬盘 IO - 每秒合并读请求次数 — 相邻的读取和写入可能会为了效率而被合并。因此,在最终交给磁盘之前,两个4K的读取可能会变成一个8K的读取,因此它将被计数(和排队)为仅有一个I/O。这些字段让你知道这种情况发生的频率。
irate(diskio_read_bytes[2m])硬盘 IO - 每秒读取字节数量bytes/s
irate(diskio_reads{}[2m])硬盘 IO - 每秒读次数
diskio_io_time硬盘 IO - 硬盘在处理 IO 的时间 — 硬盘在处理 IO 的时间,单位是毫秒。假设最近 1 秒内有 500 毫秒是在处理 IO,这个值就要加 500,这是一个单调递增的 Counter 值,从操作系统启动之后就会一直涨。实际使用的时候,一般使用该指标计算硬盘 IO UTIL(时间维度的百分比)。ms
diskio_iops_in_progress硬盘 IO - 设备驱动程序正在处理的 IO 数量 — 当前已经分配给设备驱动程序并且尚未完成的请求数量,Gauge 类型。如果 I/O 请求已经进入队列,但是尚未分配给设备驱动程序,则不统计在内。
irate(diskio_read_time[2m])/irate(diskio_reads[2m])硬盘 IO - 读请求平均耗时ms
diskio_read_time硬盘 IO - 读请求等待处理的时间 — 读取请求在磁盘上等待的时间。同时等待的多个读取请求会增加该数字。例如,如果 5 个请求均平均等待 100 毫秒,则报告 500。ms
irate(diskio_weighted_io_time[1m])/1000硬盘 IO - 队列深度 — 假设过去 1000 毫秒内有 5000 毫秒的加权等待时间,相当于平均有 5 个 IO 请求在等待,即队列深度为 5。
disk_used_percent硬盘使用率 — 硬盘空间使用率。%
disk_used硬盘使用量 — 使用 SI 标准渲染数据,和 df 命令保持一致。bytes
disk_device_error硬盘信息读取是否出错 — 0 表示正常,没有出错;非 0 表示获取硬盘信息出错了。
disk_free硬盘剩余量 — 使用 SI 标准渲染数据,和 df 命令保持一致。bytes
disk_total硬盘总量 — 使用 SI 标准渲染数据,和 df 命令保持一致。bytes
system_n_cpus系统 CPU 核数 — CPU 逻辑核的数量。
system_uptime系统启动时长 — 操作系统启动了多久,单位:秒。s
system_load1系统平均负载 - 最近 1 分钟 — 取自 /proc/loadavg。
system_load15系统平均负载 - 最近 15 分钟 — 取自 /proc/loadavg。
system_load5系统平均负载 - 最近 5 分钟 — 取自 /proc/loadavg。
system_load_norm_1系统平均负载(单核) - 最近 1 分钟 — 相当于 system_load1 / system_n_cpus
system_load_norm_15系统平均负载(单核) - 最近 15 分钟 — 相当于 system_load15 / system_n_cpus
system_load_norm_5系统平均负载(单核) - 最近 5 分钟 — 相当于 system_load5 / system_n_cpus
irate(net_drop_in[2m])网卡入方向(接收)每秒丢弃的数据包个数 — 原始指标 net_drop_in 表示操作系统启动之后各个网卡入方向(接收)丢弃的数据包总数。
irate(net_packets_recv[2m])网卡入方向(接收)每秒数据包数 — 原始指标 net_packets_recv 表示操作系统启动之后各个网卡入方向(接收)数据包总数。
irate(net_err_in[2m])网卡入方向(接收)每秒错包数 — 原始指标 net_err_in 表示操作系统启动之后各个网卡入方向(接收)错包总数。
irate(net_drop_out[2m])网卡出方向(发送)每秒丢弃的数据包个数 — 原始指标 net_drop_out 表示操作系统启动之后各个网卡出方向(发送)丢弃的数据包总数。
irate(net_packets_sent[2m])网卡出方向(发送)每秒数据包数 — 原始指标 net_packets_sent 表示操作系统启动之后各个网卡出方向(发送)数据包总数。
irate(net_err_out[2m])网卡出方向(发送)每秒错包数 — 原始指标 net_err_out 表示操作系统启动之后各个网卡出方向(发送)错包总数。
irate(net_bytes_sent[2m]) * 8网卡每秒发送的 bit 量 — 原始指标 net_bytes_sent 表示操作系统启动之后发送的 byte 总量,因为网卡流量习惯使用 bit 作为单位,所以在表达式中做了换算。bit/s
irate(net_bytes_recv[2m]) * 8网卡每秒接收的 bit 量 — 原始指标 net_bytes_recv 表示操作系统启动之后接收的 byte 总量,因为网卡流量习惯使用 bit 作为单位,所以在表达式中做了换算。bit/s
processes_dead进程数 - “僵死”状态的进程数 — 处于“僵死”状态的进程数,它是由 Linux 上的 X 状态代码表示的。
processes_paging进程数 - “分页”状态的进程数 — 处于“分页”状态的进程数,它是由 Linux 上的 W 状态代码表示的。
processes_stopped进程数 - 停止的进程数 — 停止的进程数,由 T 状态代码表示。
processes_zombies进程数 - 僵尸进程数 — 僵尸进程数,由 Z 状态代码表示。
processes_total进程数 - 总数 — 实例上的总进程数。
processes_unknown进程数 - 未知状态的进程数 — 未知状态的进程数。
processes_sleeping进程数 - 正在睡眠的进程数 — 睡眠的进程数,由 S 状态代码表示。
processes_running进程数 - 正在运行的进程数 — 正在运行的进程数,由 R 状态代码表示。
processes_idle进程数 - 空闲的数量 — 处于空闲状态 (睡眠超过 20 秒) 的进程数。
processes_total_threads进程数 - 线程总数 — 组成进程的总线程数。该指标仅适用于 Linux 实例。
processes_blocked进程数 - 被阻止的进程数 — 被阻止的进程数量。
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="steal"}[2m]) ) * 100CPU Steal 时间占比(整机平均)%
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="system"}[2m]) ) * 100CPU 内核态时间占比(整机平均)%
avg without (mode,cpu) ( 1 - irate(node_cpu_seconds_total{mode="idle"}[2m]) ) * 100CPU 利用率(整机平均)%
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="user"}[2m]) ) * 100CPU 用户态时间占比(整机平均)%
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="irq"}[2m]) ) * 100CPU 硬中断时间占比(整机平均)%
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="idle"}[2m]) ) * 100CPU 空闲率(整机平均)%
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="softirq"}[2m]) ) * 100CPU 软中断时间占比(整机平均)%
(node_memory_SwapTotal_bytes - node_memory_SwapFree_bytes)/node_memory_SwapTotal_bytes * 100 and node_memory_SwapTotal_bytes > 0交换空间使用率 — 交换空间使用率。计算原子取自 /proc/meminfo。%
node_memory_SwapTotal_bytes交换空间总量 — 交换空间总量。取自 /proc/meminfo。bytes
node_memory_SwapFree_bytes交换空间空闲量 — 交换空间空闲量。取自 /proc/meminfo。bytes
node_memory_Buffers_bytes内存 Buffered 量 — 用作缓冲区的内存量。取自 /proc/meminfo。bytes
node_memory_Cached_bytes内存 Cached 量 — 用作文件缓存的内存量。取自 /proc/meminfo。bytes
(1 - (node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{})) * 100内存使用率(基于MemAvailable) — 内存使用率。基于 MemAvailable 计算更准确,但是老版本的 Linux 不支持。%
node_memory_MemAvailable_bytes内存可用量 — 可以立即分配给进程的可用内存量。取自 /proc/meminfo。bytes
node_memory_MemTotal_bytes内存总量 — 内存总量。取自 /proc/meminfo。bytes
node_memory_MemFree_bytes内存空闲量 — 未使用的内存量。取自 /proc/meminfo。bytes
node_filefd_allocated / node_filefd_maximum * 100文件句柄 - 已分配占比%
node_filefd_allocated文件句柄 - 已分配量个
node_filefd_maximum文件句柄 - 总可分配量个
irate(node_disk_io_time_seconds_total[2m]) * 100硬盘 IO - 时间维度 Utilization — 在时间维度统计硬盘 IO 时间占比,比如该值是 50%,表示有 50% 的时间是在处理 IO,该值 100%,表示一直在处理 IO,但是注意,现代磁盘设备具备并行处理多个 I/O 请求的能力,所以即便该值是 100%,可能硬盘还是可以接收新的处理请求。 比如某人有两只手,最近 1 分钟一直在用单手劳动,从时间维度来看,利用率是 100%,但即便是 100%,再给他更多的活,他也能干,因为他还有一只手可用。%
irate(node_disk_written_bytes_total[2m])硬盘 IO - 每秒写入字节数量bytes/s
irate(node_disk_writes_completed_total{}[2m])硬盘 IO - 每秒写次数 — 每秒写次数
irate(node_disk_read_bytes_total[2m])硬盘 IO - 每秒读取字节数量bytes/s
irate(node_disk_reads_completed_total{}[2m])硬盘 IO - 每秒读次数 — 每秒读次数
100 - ((node_filesystem_avail_bytes{} * 100) / node_filesystem_size_bytes{})硬盘使用率 — 硬盘空间使用率。%
node_filesystem_free_bytes硬盘剩余量 — 使用 SI 标准渲染数据,和 df 命令保持一致。bytes
node_filesystem_avail_bytes硬盘可用量 — 使用 SI 标准渲染数据,和 df 命令保持一致。bytes
node_filesystem_size_bytes硬盘总量 — 使用 SI 标准渲染数据,和 df 命令保持一致。bytes
count(node_cpu_seconds_total{mode="idle"}) without (cpu, mode)系统 CPU 核数 — CPU 逻辑核的数量。
node_load1系统平均负载 - 最近 1 分钟 — 取自 /proc/loadavg。
node_load15系统平均负载 - 最近 15 分钟 — 取自 /proc/loadavg。
node_load5系统平均负载 - 最近 5 分钟 — 取自 /proc/loadavg。
node_load1 / count(node_cpu_seconds_total{mode="idle"}) without (cpu, mode)系统平均负载(单核) - 最近 1 分钟
node_load15 / count(node_cpu_seconds_total{mode="idle"}) without (cpu, mode)系统平均负载(单核) - 最近 15 分钟
node_load5 / count(node_cpu_seconds_total{mode="idle"}) without (cpu, mode)系统平均负载(单核) - 最近 5 分钟
irate(node_network_receive_drop_total[2m])网卡入方向(接收)每秒丢弃的数据包个数 — 原始指标 node_network_receive_drop_total 表示操作系统启动之后各个网卡入方向(接收)丢弃的数据包总数。
irate(node_network_receive_packets_total[2m])网卡入方向(接收)每秒数据包数 — 原始指标 node_network_receive_packets_total 表示操作系统启动之后各个网卡入方向(接收)数据包总数。
irate(node_network_receive_errs_total[2m])网卡入方向(接收)每秒错包数 — 原始指标 node_network_receive_errs_total 表示操作系统启动之后各个网卡入方向(接收)错包总数。
irate(node_network_transmit_drop_total[2m])网卡出方向(发送)每秒丢弃的数据包个数 — 原始指标 node_network_transmit_drop_total 表示操作系统启动之后各个网卡出方向(发送)丢弃的数据包总数。
irate(node_network_transmit_packets_total[2m])网卡出方向(发送)每秒数据包数 — 原始指标 node_network_transmit_packets_total 表示操作系统启动之后各个网卡出方向(发送)数据包总数。
irate(node_network_transmit_errs_total[2m])网卡出方向(发送)每秒错包数 — 原始指标 node_network_transmit_errs_total 表示操作系统启动之后各个网卡出方向(发送)错包总数。
irate(node_network_transmit_bytes_total[2m]) * 8网卡每秒发送的 bit 量 — 原始指标 node_network_transmit_bytes_total 表示操作系统启动之后发送的 byte 总量,因为网卡流量习惯使用 bit 作为单位,所以在表达式中做了换算。bit/s
irate(node_network_receive_bytes_total[2m]) * 8网卡每秒接收的 bit 量 — 原始指标 node_network_receive_bytes_total 表示操作系统启动之后接收的 byte 总量,因为网卡流量习惯使用 bit 作为单位,所以在表达式中做了换算。bit/s

相关链接​