- Created by 郭强, last modified on Oct 12, 2023
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 5 Next »
以下为PromeQL
的执行模板。其中:
- 范围时间
5m
是写死的,用于检索指定范围的数据执行指标检索,根据业务场景需要适当调整范围。 #LABELS#
用于Label
过滤,不同的指标过滤的Label
条件不同。#GROUPBY#
用于操作语句对结果数据进行分组,便于操作符两边的Label
能够对应,对应才能够执行操作,也便于上层获取#GROUPBY#
指定的Label
。
主机类
需要依赖node-exporter
。
节点CPU使用率
NodeCpuUsageRate
100*( 1 - (avg by (#GROUPBY#) (irate(node_cpu_seconds_total{job="node-exporter", mode="idle" #LABELS#}[5m]))) )
节点CPU使用量
NodeCpuUsage
sum(irate(node_cpu_seconds_total{ job="node-exporter", mode="idle" #LABELS#}[5m] )) by (#GROUPBY#)
节点内存使用率
NodeMemoryUsageRate
100*( 1 - ( avg( ( avg_over_time(node_memory_MemFree_bytes{job="node-exporter"#LABELS#}[5m]) + avg_over_time(node_memory_Cached_bytes{job="node-exporter"#LABELS#}[5m]) + avg_over_time(node_memory_Buffers_bytes{job="node-exporter"#LABELS#}[5m]) ) / avg_over_time(node_memory_MemTotal_bytes{job="node-exporter"#LABELS#}[5m]) ) by (#GROUPBY#) ) )
节点内存占用量
NodeMemoryUsage
avg( node_memory_MemTotal_bytes{job="node-exporter"#LABELS#} - node_memory_MemFree_bytes{job="node-exporter"#LABELS#} - ( node_memory_Cached_bytes{job="node-exporter"#LABELS#} + node_memory_Buffers_bytes{job="node-exporter"#LABELS#} ) ) by (#GROUPBY#)
节点磁盘使用率
NodeStorageUsageRate
100*sum( 1 - ( node_filesystem_avail_bytes{job="node-exporter", mountpoint="/", fstype!="rootfs"#LABELS#} / node_filesystem_size_bytes{job="node-exporter", mountpoint="/", fstype!="rootfs"#LABELS#} ) ) by (#GROUPBY#)
节点磁盘使用量
NodeStorageUsage
sum( node_filesystem_size_bytes{job="node-exporter", mountpoint="/",fstype!="rootfs" #LABELS#} - node_filesystem_avail_bytes{job="node-exporter", mountpoint="/",fstype!="rootfs" #LABELS#} ) by (#GROUPBY#)
节点内网出流量
NodeBytesSent
sum(irate(node_network_transmit_bytes_total{ job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS# }[5m])) by (#GROUPBY#)
节点内网入流量
NodeBytesReceived
sum(irate(node_network_receive_bytes_total{ job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS# }[5m])) by (#GROUPBY#)
节点内网出带宽
NodeBytesSentBandWidth
sum(irate(node_network_transmit_bytes_total{ job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS# }[5m])/128) by (#GROUPBY#)
节点内网入带宽
NodeBytesReceivedBandWidth
sum(irate(node_network_receive_bytes_total{ job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS# }[5m])/128) by (#GROUPBY#)
节点硬盘读IOPS
NodeStorageReadIOPS
sum(rate(node_disk_read_time_seconds_total{ job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS# }[5m])) by (#GROUPBY#)
节点硬盘写IOPS
NodeStorageWriteIOPS
sum(rate(node_disk_writes_completed_total{ job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS# }[5m])) by (#GROUPBY#)
节点硬盘读流量
NodeStorageReadFlow
sum(rate(node_disk_read_bytes_total{ job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS# }[5m])) by (#GROUPBY#)
节点硬盘写流量
NodeStorageWriteFlow
sum(rate(node_disk_written_bytes_total{ job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS# }[5m])) by (#GROUPBY#)
节点TCP连接数
NodeNetstatTCP
node_netstat_Tcp_CurrEstab{job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#}
容器类
需要依赖cadvisor
、kube-state
的exporter
。
pod
PodCPU使用率
PodCpuUsageRate
100* sum(irate(container_cpu_usage_seconds_total{#LABELS#}[5m])) by (#GROUPBY#) / sum(container_spec_cpu_quota{#LABELS#}/container_spec_cpu_period{#LABELS#}) by (#GROUPBY#)
PodCPU使用量
PodCpuUsage
sum(rate(container_cpu_usage_seconds_total{#LABELS#}[5m])) by (#GROUPBY#)
Pod内存使用率
PodMemoryUsageRate
sum(container_memory_working_set_bytes{#LABELS#}) by (#GROUPBY#) / sum(container_spec_memory_limit_bytes{#LABELS#}) by (#GROUPBY#) <= 1
Pod内存占用量
PodMemoryUsage
avg(container_memory_working_set_bytes{#LABELS#}) by (#GROUPBY#)
Pod磁盘使用率
PodStorageUsageRate
100* sum( container_fs_usage_bytes{#LABELS#} / (container_fs_limit_bytes{#LABELS#} !=0 ) ) by (#GROUPBY#)
Pod磁盘使用量
PodStorageUsage
avg(container_fs_usage_bytes{#LABELS#}) by (#GROUPBY#)
Pod内网出流量
PodBytesSent
sum(rate(container_network_transmit_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)
Pod内网入流量
PodBytesReceived
sum(rate(container_network_receive_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)
Pod内网出带宽
PodBytesSentBandWidth
sum(rate(container_network_transmit_bytes_total{#LABELS#}[5m])/128) by (#GROUPBY#)
Pod内网入带宽
PodBytesReceivedBandWidth
sum(rate(container_network_receive_bytes_total{#LABELS#}[5m])/128) by (#GROUPBY#)
Pod硬盘读IOPS
PodStorageReadIOPS
sum(rate(container_fs_reads_total{#LABELS#}[5m])) by (#GROUPBY#)
Pod硬盘写IOPS
PodStorageWriteIOPS
sum(rate(container_fs_writes_total{#LABELS#}[5m])) by (#GROUPBY#)
Pod硬盘读流量
PodStorageReadFlow
sum(rate(container_network_tcp_usage_total{#LABELS#}[5m])) by (#GROUPBY#)
Pod硬盘写流量
PodStorageWriteFlow
sum(rate(container_fs_reads_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)
PodTCP连接数
PodNetstatTCP
sum(rate(container_fs_writes_total{#LABELS#}[5m])) by (#GROUPBY#)
container
容器CPU使用率
ContainerCpuUsageRate
100* sum(irate(container_cpu_usage_seconds_total{#LABELS#}[5m])) by (#GROUPBY#) / sum(container_spec_cpu_quota{#LABELS#}/container_spec_cpu_period{#LABELS#}) by (#GROUPBY#)
容器CPU使用量
ContainerCpuUsage
sum(rate(container_cpu_usage_seconds_total{#LABELS#}[5m])) by (#GROUPBY#)
容器内存使用率
ContainerMemoryUsageRate
sum(container_memory_working_set_bytes{#LABELS#}) by (#GROUPBY#) / sum(container_spec_memory_limit_bytes{#LABELS#}) by (#GROUPBY#) <= 1
容器内存占用量
ContainerMemoryUsage
avg(container_memory_working_set_bytes{#LABELS#}) by (#GROUPBY#)
容器磁盘使用率
ContainerStorageUsageRate
100* sum( container_fs_usage_bytes{#LABELS#} / (container_fs_limit_bytes{#LABELS#} != 0 ) ) by (#GROUPBY#)
容器磁盘使用量
ContainerStorageUsage
avg(container_fs_usage_bytes{#LABELS#}) by (#GROUPBY#)
容器内网出流量
ContainerBytesSent
sum(rate(container_network_transmit_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)
容器内网入流量
ContainerBytesReceived
sum(rate(container_network_receive_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)
容器内网出带宽
ContainerBytesSentBandWidth
sum(rate(container_network_transmit_bytes_total{#LABELS#}[5m])/128) by (#GROUPBY#)
容器内网入带宽
ContainerBytesReceivedBandWidth
sum(rate(container_network_receive_bytes_total{#LABELS#}[5m])/128) by (#GROUPBY#)
容器硬盘读IOPS
ContainerStorageReadIOPS
sum(rate(container_fs_reads_total{#LABELS#}[5m])) by (#GROUPBY#)
容器硬盘写IOPS
ContainerStorageWriteIOPS
sum(rate(container_fs_writes_total{#LABELS#}[5m])) by (#GROUPBY#)
容器硬盘读流量
ContainerStorageReadFlow
sum(rate(container_network_tcp_usage_total{#LABELS#}[5m])) by (#GROUPBY#)
容器硬盘写流量
ContainerStorageWriteFlow
sum(rate(container_fs_reads_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)
容器TCP连接数
ContainerNetstatTCP
sum(rate(container_fs_writes_total{#LABELS#}[5m])) by (#GROUPBY#)
- No labels