PromQL
空闲的cpu指标
node_cpu_seconds_total{instance="192.168.153.21:9100",mode="idle"}
除空闲之外的其他指标
node_cpu_seconds_total{instance="192.168.153.21:9100",mode!="idle"}
192.168.153.21 的cpu使用率
100-(avg(irate(node_cpu_seconds_total{instance="192.168.153.21:9100",mode="idle"}[5m]))*100)
标签管理
自定义标签
- job_name: 'Linux Server'
static_configs:
- targets: ['192.168.153.21:9100']
labels:
project: k8s
type: monitor
重命名标签
- job_name: 'BJLinux Server'
static_configs:
- targets: ['192.168.153.22:9100']
labels:
add: bj
metric_relabel_configs:
- action: replace
source_labels: ['instance']
regex: (.*):([0-9]+)
replacement: $1
target_label: "ip"
过滤Target
- job_name: 'Linux Server'
static_configs:
- targets: ['192.168.153.21:9100','192.168.153.22:9100']
labels:
project: k8s
type: monitor
relabel_configs:
- action: drop
regex: "192.168.153.22:9100"
source_labels: ["__address__"]
-------------------------------------------------------------------
#查询验证,192.168.153.22:9100信息将不再显示
node_cpu_seconds_total{project="k8s"}
删除标签
- job_name: 'SHLinux Server'
static_configs:
- targets: ['192.168.153.21:9100']
labels:
add: sh
relabel_configs:
- action: labeldrop
regex: "job"
-------------------------------------------------------------------
#查询验证,job信息信息将不再显示
node_cpu_seconds_total{add="sh"}
Grafana
仪表盘
导航栏(job)
label_values(up,job)
Preview of values:
BJLinux Server
kubernetes-service-endpoints
kubernetes-nodes-cadvisor
Linux Server
prometheus
导航栏(节点)
(up{job="$job"},instance)
#每个job有不同节点
cpu核数
count(node_cpu_seconds_total{instance="$node",job="$job",mode="idle"})
组件:stat
内存总量
node_memory_MemTotal_bytes{instance="$node",job="$job"}
组件:stat
内存使用率
100 - (avg(irate(node_cpu_seconds_total{instance="$node",mode="idle"}[5m])) by (instance) * 100)
内存使用率
100 - (node_memory_MemFree_bytes+node_memory_Cached_bytes+node_memory_Buffers_bytes) / node_memory_MemTotal_bytes * 100
100 - (node_memory_MemFree_bytes{instance="$node",job="$job"}+node_memory_Cached_bytes{instance="$node",job="$job"}+node_memory_Buffers_bytes{instance="$node",job="$job"}) / node_memory_MemTotal_bytes{instance="$node",job="$job"} * 100
根分区使用率
100 - (node_filesystem_free_bytes{fstype=~"ext4|xfs",mountpoint="/"} / node_filesystem_size_bytes{fstype=~"ext4|xfs",mountpoint="/"} * 100)
100 - (node_filesystem_free_bytes{fstype=~"ext4|xfs",mountpoint="/",instance="$node",job="$job"} / node_filesystem_size_bytes{fstype=~"ext4|xfs",mountpoint="/",instance="$node",job="$job"} * 100)