Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

以下为PromeQL的执行模板。其中:

  • 范围时间5m是写死的,用于检索指定范围的数据执行指标检索,根据业务场景需要适当调整范围。
  • #LABELS#用于Label过滤,不同的指标过滤的Label条件不同。
  • #GROUPBY#用于操作语句对结果数据进行分组,便于操作符两边的Label能够对应,对应才能够执行操作,也便于上层获取#GROUPBY#指定的Label

主机类

需要依赖node-exporter

节点CPU使用率

NodeCpuUsageRate 

Code Block
100*(
	1 - (avg by (#GROUPBY#) (irate(node_cpu_seconds_total{job="node-exporter", mode="idle" #LABELS#}[5m])))
)

节点CPU使用量

NodeCpuUsage 

Code Block
sum(irate(node_cpu_seconds_total{
	job="node-exporter", mode="idle" #LABELS#}[5m]
)) by (#GROUPBY#)

节点内存使用率

NodeMemoryUsageRate 

Code Block
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 

Code Block
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 

Code Block
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 

Code Block
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 

Code Block
sum(irate(node_network_transmit_bytes_total{
	job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#
}[5m])) by (#GROUPBY#)

节点内网入流量

NodeBytesReceived 

Code Block
sum(irate(node_network_receive_bytes_total{
	job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#
}[5m])) by (#GROUPBY#)

节点内网出带宽

NodeBytesSentBandWidth 

Code Block
sum(irate(node_network_transmit_bytes_total{
	job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#
}[5m])/128) by (#GROUPBY#)

节点内网入带宽

NodeBytesReceivedBandWidth 

Code Block
sum(irate(node_network_receive_bytes_total{
	job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#
}[5m])/128) by (#GROUPBY#)

节点硬盘读IOPS

NodeStorageReadIOPS 

Code Block
sum(rate(node_disk_read_time_seconds_total{
	job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#
}[5m])) by (#GROUPBY#)

节点硬盘写IOPS

NodeStorageWriteIOPS 

Code Block
sum(rate(node_disk_writes_completed_total{
	job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#
}[5m])) by (#GROUPBY#)

节点硬盘读流量

NodeStorageReadFlow 

Code Block
sum(rate(node_disk_read_bytes_total{
	job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#
}[5m])) by (#GROUPBY#)

节点硬盘写流量

NodeStorageWriteFlow 

Code Block

节点TCP连接数

MetricNameNodeNetstatTCP 

sum(rate(node_disk_written_bytes_total{
	job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#
}[5m])) by (#GROUPBY#)

节点TCP连接数

NodeNetstatTCP 

Code Block
node_netstat_Tcp_CurrEstab{job="node-exporter", device!~"lo|nbd.*|sr.*|docker.*" #LABELS#}
Code Block

容器类

需要依赖cadvisorkube-stateexporter

pod

PodCPU使用率

PodCpuUsageRate 

Code Block
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 

Code Block
sum(rate(container_cpu_usage_seconds_total{#LABELS#}[5m])) by (#GROUPBY#)

Pod内存使用率

PodMemoryUsageRate 

Code Block
sum(container_memory_working_set_bytes{#LABELS#}) by (#GROUPBY#)
/ 
sum(container_spec_memory_limit_bytes{#LABELS#}) by (#GROUPBY#) <= 1

Pod内存占用量

PodMemoryUsage 

Code Block
avg(container_memory_working_set_bytes{#LABELS#}) by (#GROUPBY#)

Pod磁盘使用率

PodStorageUsageRate 

Code Block
100*
sum(
	container_fs_usage_bytes{#LABELS#} / (container_fs_limit_bytes{#LABELS#} !=0 )
) by (#GROUPBY#)

Pod磁盘使用量

PodStorageUsage 

Code Block
avg(container_fs_usage_bytes{#LABELS#}) by (#GROUPBY#)

Pod内网出流量

PodBytesSent 

Code Block
sum(rate(container_network_transmit_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)

Pod内网入流量

PodBytesReceived 

Code Block
sum(rate(container_network_receive_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)

Pod内网出带宽

PodBytesSentBandWidth 

Code Block
sum(rate(container_network_transmit_bytes_total{#LABELS#}[5m])/128) by (#GROUPBY#)

Pod内网入带宽

PodBytesReceivedBandWidth 

Code Block
sum(rate(container_network_receive_bytes_total{#LABELS#}[5m])/128) by (#GROUPBY#)

Pod硬盘读IOPS

PodStorageReadIOPS 

Code Block
sum(rate(container_fs_reads_total{#LABELS#}[5m])) by (#GROUPBY#)

Pod硬盘写IOPS

PodStorageWriteIOPS 

Code Block
sum(rate(container_fs_writes_total{#LABELS#}[5m])) by (#GROUPBY#)

Pod硬盘读流量

PodStorageReadFlow 

Code Block
sum(rate(container_network_tcp_usage_total{#LABELS#}[5m])) by (#GROUPBY#)

Pod硬盘写流量

PodStorageWriteFlow 

Code Block
sum(rate(container_fs_reads_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)

PodTCP连接数

PodNetstatTCP 

Code Block
sum(rate(container_fs_writes_total{#LABELS#}[5m])) by (#GROUPBY#)

container

容器CPU使用率

ContainerCpuUsageRate 

Code Block
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 

Code Block
sum(rate(container_cpu_usage_seconds_total{#LABELS#}[5m])) by (#GROUPBY#)

容器内存使用率

ContainerMemoryUsageRate 

Code Block
sum(container_memory_working_set_bytes{#LABELS#}) by (#GROUPBY#)
/ 
sum(container_spec_memory_limit_bytes{#LABELS#}) by (#GROUPBY#) <= 1

容器内存占用量

ContainerMemoryUsage 

Code Block
avg(container_memory_working_set_bytes{#LABELS#}) by (#GROUPBY#)

容器磁盘使用率

ContainerStorageUsageRate 

Code Block
100*
sum(
	container_fs_usage_bytes{#LABELS#} / (container_fs_limit_bytes{#LABELS#} != 0 )
) by (#GROUPBY#)

容器磁盘使用量

ContainerStorageUsage 

Code Block
avg(container_fs_usage_bytes{#LABELS#}) by (#GROUPBY#)

容器内网出流量

ContainerBytesSent 

Code Block
sum(rate(container_network_transmit_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)

容器内网入流量

ContainerBytesReceived 

Code Block
sum(rate(container_network_receive_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)

容器内网出带宽

ContainerBytesSentBandWidth 

Code Block
sum(rate(container_network_transmit_bytes_total{#LABELS#}[5m])/128) by (#GROUPBY#)

容器内网入带宽

ContainerBytesReceivedBandWidth 

Code Block
sum(rate(container_network_receive_bytes_total{#LABELS#}[5m])/128) by (#GROUPBY#)

容器硬盘读IOPS

ContainerStorageReadIOPS 

Code Block
sum(rate(container_fs_reads_total{#LABELS#}[5m])) by (#GROUPBY#)

容器硬盘写IOPS

ContainerStorageWriteIOPS 

Code Block
sum(rate(container_fs_writes_total{#LABELS#}[5m])) by (#GROUPBY#)

容器硬盘读流量

ContainerStorageReadFlow 

Code Block
sum(rate(container_network_tcp_usage_total{#LABELS#}[5m])) by (#GROUPBY#)

容器硬盘写流量

ContainerStorageWriteFlow 

Code Block
sum(rate(container_fs_reads_bytes_total{#LABELS#}[5m])) by (#GROUPBY#)

容器TCP连接数

ContainerNetstatTCP 

Code Block
sum(rate(container_fs_writes_total{#LABELS#}[5m])) by (#GROUPBY#)




Panel
titleContent Menu

Table of Contents
maxLevel5