rsdatakit
rsdatakit 是面向 Linux 主机和 Kubernetes 节点的轻量采集器,使用 Rust 编写,并以 DataKit/Guance Point v2 格式将数据发送至 Dataway。
功能概览¶
| 模块 | 默认状态 | 采集内容 |
|---|---|---|
| 主机 | 开启 | cpu、mem、disk、diskio、net、system 指标及 HOST 对象。 |
| 日志 | 关闭 | 文件日志、systemd journal、断点续采、多行合并和文件轮转。 |
| OpenTelemetry | 关闭 | 通过 OTLP/HTTP 或 OTLP/gRPC 接收 Trace。 |
| Kubernetes | 关闭 | 本节点 Pod/容器指标、对象、容器日志及 Kubernetes 元数据富化。 |
| Prometheus | 关闭 | 节点本地目标发现与 Prometheus/OpenMetrics 抓取。 |
当前支持 Linux amd64 和 arm64。不支持 Windows、macOS、OTLP Metrics、OTLP Logs、
eBPF、拨测、远程配置及 DataKit 插件系统。
DataKit 兼容性
rsdatakit 对已实现数据使用 DataKit 兼容的指标集、对象分类和核心字段名,可复用依赖这些字段的 中心视图。DataKit 独有而本文未列出的字段不会由 rsdatakit 产生,对应图表可能显示为空。
运行要求¶
- Linux 主机需要可访问
/proc和/sys;journald 采集还需要 systemd journal 运行库。 - 使用安装脚本管理
rsdatakit服务需要 systemd 和systemctl。 - Kubernetes 采集需要以 DaemonSet 运行在待采集节点,并允许读取 Pod 元数据、Kubelet Summary 和宿主机容器日志目录。
- 需要可用的 Dataway 地址和 token。配置文件及状态目录应仅允许运行用户访问。
安装¶
安装脚本支持 Linux amd64 与 arm64,需要 root 权限或 sudo,并使用 systemd
管理服务。安装最新版本:
RSDATAKIT_DATAWAY_URL="https://openway.guance.com" \
RSDATAKIT_DATAWAY_TOKEN="<DATAWAY_TOKEN>" \
sh -c "$(curl -fsSL https://static.guance.com/rsdatakit/install.sh)"
安装指定版本时,将 <VERSION> 替换为完整版本号:
RSDATAKIT_DATAWAY_URL="https://openway.guance.com" \
RSDATAKIT_DATAWAY_TOKEN="<DATAWAY_TOKEN>" \
sh -c "$(curl -fsSL https://static.guance.com/rsdatakit/install-<VERSION>.sh)"
安装脚本会自动选择系统架构、校验软件包、安装二进制和 systemd unit,并启动
rsdatakit.service。默认配置文件为 /etc/rsdatakit/rsdatakit.toml。
升级到最新版本时设置 RSDATAKIT_UPGRADE=1:
升级会替换二进制并重启服务,保留 /etc/rsdatakit/rsdatakit.toml 以及
/var/lib/rsdatakit 中的 WAL 和采集状态。如需同时切换 Dataway,可在升级命令中
传入新的 RSDATAKIT_DATAWAY_URL 和 RSDATAKIT_DATAWAY_TOKEN。升级到指定版本时,
使用 install-<VERSION>.sh。
设置 RSDATAKIT_INSTALL_ONLY=1 可只安装或升级而不启动服务。安装或升级完成后检查:
RustDataKit 以 DaemonSet 方式部署,每个 Linux 节点运行一个采集实例。清单引用支持
linux/amd64 和 linux/arm64 的多架构镜像。
先下载最新版本的 rsdatakit.yaml:
如需安装指定版本,请将 <VERSION> 替换为完整版本号:
清单中的 Dataway URL、工作空间 token 和 OTLP token 通过 Kubernetes Secret 提供。 创建命名空间并写入实际配置:
kubectl create namespace rsdatakit-system --dry-run=client -o yaml | kubectl apply -f -
kubectl -n rsdatakit-system create secret generic rsdatakit-secrets \
--from-literal=dataway-url='https://openway.guance.com' \
--from-literal=dataway-token='<DATAWAY_TOKEN>' \
--from-literal=otlp-token='<OTLP_TOKEN>' \
--dry-run=client -o yaml | kubectl apply -f -
如果使用其它 Dataway 节点,将 dataway-url 改为对应的真实地址。未使用 OTLP 接收功能时,
otlp-token 可以设置为空字符串。
安装 YAML:
安装后检查 DaemonSet 和 Pod 状态:
kubectl -n rsdatakit-system rollout status daemonset/rsdatakit
kubectl -n rsdatakit-system get pods -l app.kubernetes.io/name=rsdatakit
查看运行日志:
配置¶
默认配置路径为 /etc/rsdatakit/rsdatakit.toml。也可以通过 --config <path> 或
RSDATAKIT_CONFIG 指定其他配置文件。配置只在进程启动时读取,修改后需要重启服务。
最小可用配置如下:
[agent]
# 本地状态目录,保存 WAL 和文件日志读取位置;必须使用绝对路径。
state_dir = "/var/lib/rsdatakit"
# 可选的独立健康检查监听地址;留空时不单独监听。
health_addr = ""
[dataway]
# 工作区 Dataway 写入地址。
url = "https://openway.example.com"
# 工作区 token。
token = "<DATAWAY_TOKEN>"
# 单次 Dataway 请求超时(秒),范围为 1–60。
timeout_secs = 15
# 追加到所有上报数据的 tag。
global_tags = { env = "prod" }
# 写入索引;留空使用工作区默认索引。
storage_index = ""
[metrics]
# 主机指标采集周期(秒),范围为 5–300。
interval_secs = 15
# 采集容量的挂载点;最多 32 个,且必须使用绝对路径。
mounts = ["/"]
# 是否额外采集 veth、docker0、cni 等虚拟网卡。
enable_virtual_interfaces = false
[hostobject]
# HOST 主机对象上报周期(秒),范围为 60–3600。
interval_secs = 300
[wal]
# 本地写前日志目录;必须使用绝对路径。
dir = "/var/lib/rsdatakit/wal"
# WAL 总容量上限(字节),范围为 4 MiB–256 MiB;写满时淘汰最旧的未发送数据。
max_bytes = 268435456
agent.state_dir、logs.state_dir 和 wal.dir 必须使用绝对路径。默认 WAL 容量为
256 MiB,应按可接受的 Dataway 中断时长和日志/Trace 写入量调整 wal.max_bytes。
进程启动时可通过 RSDATAKIT_DATAWAY_URL 和 RSDATAKIT_DATAWAY_TOKEN 分别覆盖配置文件中的地址和 token;RSDATAKIT_HEALTH_ADDR 可覆盖独立健康检查地址。
主机采集¶
主机指标和 HOST 对象默认启动,无需额外 enabled 开关。
| 数据 | measurement / object | 默认频率 | 说明 |
|---|---|---|---|
| CPU | cpu |
15 秒 | 汇总 CPU 使用率。 |
| 内存 | mem |
15 秒 | 容量、缓存、已用和百分比。 |
| 磁盘容量 | disk |
15 秒 | 仅采集 [metrics].mounts 指定的挂载点,默认 /。 |
| 磁盘 I/O | diskio |
15 秒 | 块设备累计值、读写速率和 await。 |
| 网络 | net |
15 秒 | 默认只采集 UP 状态的非虚拟网卡。 |
| 系统 | system |
15 秒 | 负载、CPU/内存使用率、进程数和 uptime。 |
| 主机对象 | HOST |
300 秒 | 主机身份、操作系统和基础资源信息。 |
主机指标周期范围为 5–300 秒;HOST 对象周期范围为 60–3600 秒。CPU、网络和磁盘 I/O
速率依赖前后两次样本,刚启动时第一轮可能没有速率字段。
指标¶
以下表格只列出 rsdatakit 当前实际上报的字段。字段名与 DataKit 同名指标集保持兼容,但 rsdatakit 没有实现 DataKit 对应采集器的所有扩展字段。
cpu¶
| Tags & Fields | Description |
|---|---|
| host ( tag) |
主机名。 |
| cpu ( tag) |
CPU 标识;当前固定为 cpu-total,表示所有 CPU 的汇总值。 |
| usage_user | 用户态 CPU 时间占比。 Type: float | (gauge) Unit: percent |
| usage_nice | 低优先级用户态 CPU 时间占比。 Type: float | (gauge) Unit: percent |
| usage_system | 内核态 CPU 时间占比。 Type: float | (gauge) Unit: percent |
| usage_idle | CPU 空闲时间占比。 Type: float | (gauge) Unit: percent |
| usage_iowait | 等待 I/O 完成的 CPU 时间占比。 Type: float | (gauge) Unit: percent |
| usage_irq | 处理硬中断的 CPU 时间占比。 Type: float | (gauge) Unit: percent |
| usage_softirq | 处理软中断的 CPU 时间占比。 Type: float | (gauge) Unit: percent |
| usage_steal | 虚拟化环境中被其他系统占用的 CPU 时间占比。 Type: float | (gauge) Unit: percent |
| usage_guest | 运行客户机虚拟 CPU 的时间占比。 Type: float | (gauge) Unit: percent |
| usage_guest_nice | 运行低优先级客户机虚拟 CPU 的时间占比。 Type: float | (gauge) Unit: percent |
| usage_total | 汇总 CPU 使用率。 Type: float | (gauge) Unit: percent |
mem¶
| Tags & Fields | Description |
|---|---|
| host ( tag) |
主机名。 |
| total | 物理内存总字节数。 Type: int | (gauge) Unit: digital,B |
| available | 内核估算的当前可用内存字节数。 Type: int | (gauge) Unit: digital,B |
| used | 已用内存,按 total - free - buffered - cached 计算。Type: int | (gauge) Unit: digital,B |
| free | 未使用内存字节数。 Type: int | (gauge) Unit: digital,B |
| buffered | 内核 buffer 占用字节数。 Type: int | (gauge) Unit: digital,B |
| cached | page cache 与可回收 slab 占用字节数。 Type: int | (gauge) Unit: digital,B |
| used_percent | 已用内存占总内存的百分比。 Type: float | (gauge) Unit: percent |
| available_percent | 可用内存占总内存的百分比。 Type: float | (gauge) Unit: percent |
disk¶
每个 [metrics].mounts 中配置的挂载点产生一个 Point。
| Tags & Fields | Description |
|---|---|
| host ( tag) |
主机名。 |
| device ( tag) |
挂载点对应的设备名;无法识别时为 unknown。 |
| fstype ( tag) |
文件系统类型;无法识别时为 unknown。 |
| mount_point ( tag) |
挂载路径。 |
| total | 文件系统总容量。 Type: int | (gauge) Unit: digital,B |
| free | 文件系统可用容量。 Type: int | (gauge) Unit: digital,B |
| used | 文件系统已用容量。 Type: int | (gauge) Unit: digital,B |
| used_percent | 文件系统已用容量百分比。 Type: float | (gauge) Unit: percent |
| inodes_total | inode 总数;文件系统未提供 inode 信息时不产生。 Type: int | (gauge) Unit: count |
| inodes_free | 空闲 inode 数。 Type: int | (gauge) Unit: count |
| inodes_used | 已用 inode 数。 Type: int | (gauge) Unit: count |
| inodes_total_mb | inodes_total / 1,000,000 的兼容字段。Type: int | (gauge) |
| inodes_free_mb | inodes_free / 1,000,000 的兼容字段。Type: int | (gauge) |
| inodes_used_mb | inodes_used / 1,000,000 的兼容字段。Type: int | (gauge) |
| inodes_used_percent | 已用 inode 百分比。 Type: float | (gauge) Unit: percent |
diskio¶
每个具有 I/O 计数的 Linux 块设备产生一个 Point。
| Tags & Fields | Description |
|---|---|
| host ( tag) |
主机名。 |
| name ( tag) |
块设备路径,例如 /dev/vda。 |
| serial ( tag) |
udev 中的设备序列号;无法识别时为 unknown。 |
| reads | 启动以来完成的读请求数。 Type: int | (count) Unit: count |
| writes | 启动以来完成的写请求数。 Type: int | (count) Unit: count |
| merged_reads | 合并的读请求累计数。 Type: int | (count) Unit: count |
| merged_writes | 合并的写请求累计数。 Type: int | (count) Unit: count |
| read_bytes | 累计读取字节数。 Type: int | (count) Unit: digital,B |
| write_bytes | 累计写入字节数。 Type: int | (count) Unit: digital,B |
| read_time | 累计读耗时。 Type: int | (count) Unit: ms |
| write_time | 累计写耗时。 Type: int | (count) Unit: ms |
| io_time | 设备执行 I/O 的累计时间。 Type: int | (count) Unit: ms |
| weighted_io_time | 加权累计 I/O 时间。 Type: int | (count) Unit: ms |
| iops_in_progress | 当前正在处理的 I/O 请求数。 Type: int | (gauge) Unit: count |
| read_bytes/sec | 采集周期内的平均读取速率;首轮不产生。 Type: int | (gauge) Unit: traffic,B/s |
| write_bytes/sec | 采集周期内的平均写入速率;首轮不产生。 Type: int | (gauge) Unit: traffic,B/s |
| await | 采集周期内每个读写请求的平均等待时间;首轮不产生。 Type: float | (gauge) Unit: ms |
net¶
每个符合过滤规则且具有前一轮样本的网络接口产生一个 Point。
| Tags & Fields | Description |
|---|---|
| host ( tag) |
主机名。 |
| interface ( tag) |
网络接口名。 |
| bytes_sent | 接口累计发送字节数。 Type: int | (count) Unit: digital,B |
| bytes_recv | 接口累计接收字节数。 Type: int | (count) Unit: digital,B |
| packets_sent | 接口累计发送数据包数。 Type: int | (count) Unit: count |
| packets_recv | 接口累计接收数据包数。 Type: int | (count) Unit: count |
| err_in | 接口累计接收错误数。 Type: int | (count) Unit: count |
| err_out | 接口累计发送错误数。 Type: int | (count) Unit: count |
| drop_in | 接口累计接收丢包数。 Type: int | (count) Unit: count |
| drop_out | 接口累计发送丢包数。 Type: int | (count) Unit: count |
| bytes_sent/sec | 采集周期内每秒发送字节数。 Type: int | (gauge) Unit: traffic,B/s |
| bytes_recv/sec | 采集周期内每秒接收字节数。 Type: int | (gauge) Unit: traffic,B/s |
| packets_sent/sec | 采集周期内每秒发送数据包数。 Type: int | (gauge) Unit: count/s |
| packets_recv/sec | 采集周期内每秒接收数据包数。 Type: int | (gauge) Unit: count/s |
system¶
| Tags & Fields | Description |
|---|---|
| host ( tag) |
主机名。 |
| load1 | 最近 1 分钟系统负载。 Type: float | (gauge) |
| load1_per_core | 最近 1 分钟负载除以逻辑 CPU 数。 Type: float | (gauge) |
| load5 | 最近 5 分钟系统负载。 Type: float | (gauge) |
| load5_per_core | 最近 5 分钟负载除以逻辑 CPU 数。 Type: float | (gauge) |
| load15 | 最近 15 分钟系统负载。 Type: float | (gauge) |
| load15_per_core | 最近 15 分钟负载除以逻辑 CPU 数。 Type: float | (gauge) |
| n_cpus | 进程可见的逻辑 CPU 数。 Type: int | (gauge) Unit: count |
| uptime | 主机启动后的运行时长。 Type: int | (gauge) Unit: s |
| cpu_total_usage | 与本轮 cpu.usage_total 相同的主机 CPU 汇总使用率;CPU 样本无效时不产生。Type: float | (gauge) Unit: percent |
| memory_usage | 与本轮 mem.used_percent 相同的内存使用率;内存样本无效时不产生。Type: float | (gauge) Unit: percent |
| process_count | /proc 中当前进程目录数量。Type: int | (gauge) Unit: count |
对象¶
HOST¶
| Tags & Fields | Description |
|---|---|
| host ( tag) |
主机名。 |
| name ( tag) |
对象名称,当前与 host 相同。 |
| os ( tag) |
操作系统,当前为 linux。 |
| arch ( tag) |
CPU 架构,例如 x86_64 或 aarch64。 |
| unicast_ip ( tag) |
主机单播 IP;无法识别时不产生。 |
| message | 包含主机 CPU、内存、网络、磁盘和系统元数据的 JSON。 Type: string |
| rs_datakit_ver | rsdatakit 版本。 Type: string |
| cpu_usage | 对象采集周期内的 CPU 使用率。 Type: float Unit: percent |
| num_cpu | 逻辑 CPU 数。 Type: int Unit: count |
| mem_used_percent | 内存使用率。 Type: float Unit: percent |
| load | 最近 5 分钟系统负载。 Type: float |
| disk_total | 已配置挂载点的总容量。 Type: int Unit: digital,B |
| disk_used_percent | 已配置挂载点的汇总使用率。 Type: float Unit: percent |
| diskio_read_bytes_per_sec | 对象采集周期内的磁盘读取速率。 Type: int Unit: traffic,B/s |
| diskio_write_bytes_per_sec | 对象采集周期内的磁盘写入速率。 Type: int Unit: traffic,B/s |
| net_recv_bytes_per_sec | 对象采集周期内的网络接收速率。 Type: int Unit: traffic,B/s |
| net_send_bytes_per_sec | 对象采集周期内的网络发送速率。 Type: int Unit: traffic,B/s |
| logging_level | 当前 RUST_LOG 值;未设置时为 info。Type: string |
| is_docker | 进程是否运行在容器中,1 表示是,0 表示否。Type: int |
| start_time | 主机启动时间,Unix 毫秒时间戳;无法识别时不产生。 Type: int Unit: ms |
日志采集¶
日志默认关闭。空 paths 不采集任何文件;请仅配置明确需要的路径,不要使用过宽的全局 glob。
[logs]
# 是否启用文件日志采集。
enabled = true
# 要采集的日志文件绝对路径 glob。
paths = ["/var/log/my-service/*.log"]
# 日志数据来源名称。
source = "my-service"
# 追加到日志的 service tag。
service = "my-service"
# 将顶层 JSON 对象的第一层成员作为日志字段上报。
json_as_fields = false
# 同时读取的活跃文件上限。
max_files = 32
# 重新发现匹配文件的周期(秒)。
discovery_secs = 5
# copytruncate 日志轮转识别策略。
copytruncate_mode = "auto"
# 保存文件读取位置的本地目录;必须使用绝对路径。
state_dir = "/var/lib/rsdatakit"
# 仅在使用 journald feature 构建,并且主机具备 libsystemd 运行库时生效。
journald_enabled = false
# 仅采集指定 systemd unit;留空采集所有可访问的 journal。
journald_unit = "my-service.service"
[logs.multiline]
# 续行模式;留空则每一行独立上报。
continuation_regex = "^\\s+"
# 等待续行的最长时间(毫秒)。
flush_timeout_ms = 1000
# 单条合并日志允许的最大字节数。
max_bytes = 262144
日志位置、journald cursor 和 WAL 存储在状态目录。文件日志在重启后从已确认位置继续读取; 数据已经写入 WAL 或已被 Dataway 接收后才推进位置。多行续行匹配时会合并为一条日志。
json_as_fields 默认关闭。开启后,顶层为对象的 JSON 日志会把第一层成员作为字段上报:
字符串、布尔值、int64 和有限 float64 保留类型,对象和数组编码为紧凑 JSON 字符串,
null 及超出支持范围的数值忽略。解析失败、顶层不是对象或没有可用字段时保留原始
message。JSON 字段覆盖同名采集器字段;字段名按 Point 规则规范化并限制为 256 字节,
单个 Point 最多保留 1024 个 field。time、source、date 和 storage_index 分别改名为
json_* 字段,不修改 Point 时间、日志 source 或存储索引。也可通过
RSDATAKIT_LOG_JSON_AS_FIELDS=true 开启;原 json_extract 和
RSDATAKIT_LOG_JSON_EXTRACT 继续作为兼容别名。
journald_enabled = true 表示额外从 systemd journal 读取日志,不影响文件日志是否采集。
发布包会启用 journald;源码手动构建时使用:
日志数据¶
日志 measurement 为 [logs].source。Kubernetes 容器日志的初始 source 通常配置为
kubernetes;元数据匹配成功后,measurement 会改为容器名。
| Tags & Fields | Description |
|---|---|
| host ( tag) |
采集节点的主机名。 |
| service ( tag) |
[logs].service;journald 优先使用 _SYSTEMD_UNIT。 |
| filepath ( tag) |
文件日志的完整路径;journald 固定为 journald。 |
| status ( tag) |
当前固定为 info。日志正文中的级别不会自动解析。 |
| stream ( tag) |
CRI/Docker 容器日志的 stdout 或 stderr;普通文件日志和 journald 不产生。 |
| message | 未开启 json_as_fields,或 JSON 转换失败时,保留单行或多行合并后的原始正文。Type: string |
<json_key> |
开启 json_as_fields 且转换成功时产生的第一层 JSON 字段。Type: string, bool, int, float |
Kubernetes 容器日志在元数据可用时还会增加以下 tag:
| Tags & Fields | Description |
|---|---|
| cluster_name_k8s ( tag) |
Kubernetes 集群名。 |
| node_name ( tag) |
Pod 所在节点。 |
| namespace ( tag) |
Pod 命名空间。 |
| pod_namespace ( tag) |
Pod 命名空间兼容字段。 |
| pod_name ( tag) |
Pod 名称。 |
| pod_uid ( tag) |
Pod UID。 |
| pod_ip ( tag) |
Pod IP;存在时产生。 |
| container_name ( tag) |
容器名称。 |
| container_id ( tag) |
容器运行时 ID,不含运行时前缀;可识别时产生。 |
| image ( tag) |
容器镜像;可识别时产生。 |
| deployment ( tag) |
Deployment 名称;存在时产生。 |
| daemonset ( tag) |
DaemonSet 名称;存在时产生。 |
| statefulset ( tag) |
StatefulSet 名称;存在时产生。 |
| replica_set ( tag) |
ReplicaSet 名称;存在时产生。 |
| job ( tag) |
Job 名称;存在时产生。 |
<label_key>( tag) |
[kubernetes].label_tags 白名单中 Pod label 的规范化 key(. 转为 _,/ 保留)。 |
OpenTelemetry Trace¶
OTLP 默认关闭。开启后接收 OTLP Trace,并转发到 tracing 数据类别:
[otlp]
# 是否启动 OTLP HTTP 和 gRPC 接收器。
enabled = true
# OTLP/HTTP 监听地址。
http_addr = "127.0.0.1:4318"
# OTLP/gRPC 监听地址,必须与 http_addr 不同。
grpc_addr = "127.0.0.1:4317"
# 非本地监听地址所需的 Bearer Token;本地监听可留空。
bearer_token = ""
# 单个 OTLP 请求允许的最大字节数。
max_request_bytes = 4194304
# 最大并发 OTLP 请求数。
max_concurrent_requests = 8
# 已受理 OTLP 请求的总内存预算(字节)。
max_inflight_bytes = 16777216
| 协议 | 地址 / 路径 |
|---|---|
| OTLP/HTTP | http://<host>:4318/otel/v1/traces |
| OTLP/gRPC | <host>:4317,服务为 opentelemetry.proto.collector.trace.v1.TraceService/Export |
| 健康检查 | http://<health-host>:<health-port>/health;OTLP 开启时也可使用 http://<host>:4318/health |
当 HTTP 或 gRPC 地址绑定到非 loopback 地址时,必须设置 bearer_token,客户端使用
Authorization: Bearer <token>。当前仅接收 Trace;OTLP Metrics 和 OTLP Logs 请求不受支持。
/health 可由 agent.health_addr 独立提供;OTLP 关闭时不会绑定 4317/4318。
连接空闲期限为 30 秒;HTTP header/body、gRPC 连接启动及请求体接收/解码分别受
65 秒绝对期限约束。gRPC 完整解码消息和 trailers 后即停止请求体期限;后续映射、入队和等待
Dataway/WAL receipt 没有总 handler 超时,活跃请求也不会被连接空闲期限中断。gRPC
请求体超过接收期限时返回 DeadlineExceeded 并释放全局准入预算。
Trace 数据¶
OTLP Span 输出到 tracing 类别,measurement 固定为 opentelemetry。时间字段 start 和
duration 使用微秒;Point 自身时间戳使用 Span 的纳秒开始时间。
| Tags & Fields | Description |
|---|---|
| service ( tag) |
服务名。优先取 Span 的数据库、RPC 或消息系统名,否则取 Resource 的 service.name。 |
| source ( tag) |
固定为 opentelemetry。 |
| span_type ( tag) |
Span 在当前请求内 Trace 树中的结构类型:entry、local 或 exit。 |
| span_kind ( tag) |
internal、server、client、producer、consumer 或 unspecified。 |
| source_type ( tag) |
db、message_queue、web 或 custom。 |
| status ( tag) |
ok、error 或 info。 |
| dk_fingerprint ( tag) |
用于 DataKit/观测云 Trace 聚合兼容的指纹。 |
| host ( tag) |
接收该 Trace 的 rsdatakit 主机名。Kubernetes 节点身份另存为 node_name。 |
| base_service ( tag) |
当数据库/RPC/消息系统覆盖 service 时记录原始服务名。 |
| collector_source_ip ( tag) |
OTLP 客户端源 IP;仅在可获得时产生。 |
| trace_id | 32 位十六进制 Trace ID。 Type: string |
| span_id | 16 位十六进制 Span ID。 Type: string |
| parent_id | 父 Span ID;根 Span 为字符串 0。Type: string |
| resource | Span 名称。 Type: string |
| start | Span 开始时间,Unix 微秒时间戳。 Type: int Unit: us |
| duration | Span 持续时间。 Type: int Unit: us |
| runtime_id | Runtime ID;存在时产生。 Type: string |
| message | 去掉核心 ID/时间字段后的 Span JSON,包含未映射为顶层字段的属性与事件。 Type: string |
| error_type | 从 exception.type 提取的异常类型;仅 exception event 存在时产生。Type: string |
| error_message | 从 exception.message 提取的异常消息;仅 exception event 存在时产生。Type: string |
| error_stack | 从 exception.stacktrace 提取的异常堆栈;仅 exception event 存在时产生。Type: string |
常用 OTel Resource/Span 属性会转换为扁平字段,例如 db.system → db_system、
db.operation.name → db_operation、http.request.method → http_method、
http.response.status_code → http_status_code、rpc.system → rpc_system、
messaging.system → messaging_system。字符串、布尔、整数和浮点值保留原类型;数组和对象编码为 JSON。
单个属性来源最多处理 256 个属性。不在当前语义映射白名单内的属性不会成为顶层字段,但会保留在
message JSON 中。
语义属性字段¶
下面列出当前白名单内的 OTel 属性映射。除 http_status_code 外,字段类型保持输入属性的
string、bool、int 或 float 类型;数组和 key/value 对象会编码成 JSON 字符串。
| Tags & Fields | Description |
|---|---|
| db_system | 输入 db.system 或 db.system.name。Type: string | bool | int | float |
| db_operation | 输入 db.operation 或 db.operation.name。Type: string | bool | int | float |
| db_operation_batch_size | 输入 db.operation.batch.size。Type: string | bool | int | float |
| db_name | 输入 db.name 或 db.namespace。Type: string | bool | int | float |
| db_statement | 输入 db.statement 或 db.query.text。Type: string | bool | int | float |
| db_collection | 输入 db.collection.name。Type: string | bool | int | float |
| db_host ( tag) |
当 Span 表示数据库调用时,优先取 server.address,其次 net.peer.name。 |
| server_address | 输入 server.address。Type: string | bool | int | float |
| server_port | 输入 server.port。Type: string | bool | int | float |
| net_host_name | 输入 net.host.name。Type: string | bool | int | float |
| net_host_port | 输入 net.host.port。Type: string | bool | int | float |
| network_peer_address | 输入 network.peer.address。Type: string | bool | int | float |
| network_peer_port | 输入 network.peer.port。Type: string | bool | int | float |
| network_transport | 输入 network.transport。Type: string | bool | int | float |
| net_protocol_name | 输入 network.protocol.name。Type: string | bool | int | float |
| net_protocol_version | 输入 network.protocol.version。Type: string | bool | int | float |
| network_type | 输入 network.type。Type: string | bool | int | float |
| network_local_address | 输入 network.local.address。Type: string | bool | int | float |
| network_local_port | 输入 network.local.port。Type: string | bool | int | float |
| http_method | 输入 http.request.method 或兼容的 http.method。Type: string | bool | int | float |
| http_status_code ( tag) |
输入 http.response.status_code 或兼容的 http.status_code;统一转为字符串 tag。 |
| http_route | 输入 http.route。Type: string | bool | int | float |
| http_target | 输入 http.target。Type: string | bool | int | float |
| http_scheme | 输入 http.scheme。Type: string | bool | int | float |
| http_url | 输入 http.url。Type: string | bool | int | float |
| url_full | 输入 url.full。Type: string | bool | int | float |
| url_scheme | 输入 url.scheme。Type: string | bool | int | float |
| url_path | 输入 url.path。Type: string | bool | int | float |
| url_query | 输入 url.query。Type: string | bool | int | float |
| client_address | 输入 client.address。Type: string | bool | int | float |
| client_port | 输入 client.port。Type: string | bool | int | float |
| user_agent_original | 输入 user_agent.original。Type: string | bool | int | float |
| error_type | 输入 error.type;exception event 也可能提供此字段。Type: string | bool | int | float |
| messaging_system | 输入 messaging.system。Type: string | bool | int | float |
| messaging_operation | 输入 messaging.operation 或 messaging.operation.name。Type: string | bool | int | float |
| messaging_operation_type | 输入 messaging.operation.type。Type: string | bool | int | float |
| messaging_destination_name | 输入 messaging.destination.name。Type: string | bool | int | float |
| messaging_message_id | 输入 messaging.message.id。Type: string | bool | int | float |
| rpc_service | 输入 rpc.service。Type: string | bool | int | float |
| rpc_system | 输入 rpc.system 或 rpc.system.name。Type: string | bool | int | float |
| rpc_method | 输入 rpc.method。Type: string | bool | int | float |
| rpc_grpc_status_code | 输入 rpc.grpc.status_code。Type: string | bool | int | float |
| exception | 输入 exception。Type: string | bool | int | float |
| exception_type | 输入 exception.type。Type: string | bool | int | float |
| exception_message | 输入 exception.message。Type: string | bool | int | float |
| exception_stacktrace | 输入 exception.stacktrace。Type: string | bool | int | float |
| container_name | 输入 container.name。在 Kubernetes 模式下也会被规范化为同名 tag。Type: string | bool | int | float |
| container_id | 输入 container.id。在 Kubernetes 模式下也会被规范化为同名 tag。Type: string | bool | int | float |
| image | 输入 container.image.name。在 Kubernetes 模式下也会被规范化为同名 tag。Type: string | bool | int | float |
| k8s_cluster_name | 输入 k8s.cluster.name。Type: string | bool | int | float |
| k8s_namespace_name | 输入 k8s.namespace.name。Type: string | bool | int | float |
| k8s_node_name | 输入 k8s.node.name。Type: string | bool | int | float |
| k8s_pod_name | 输入 k8s.pod.name。Type: string | bool | int | float |
| k8s_pod_uid | 输入 k8s.pod.uid。Type: string | bool | int | float |
| k8s_container_name | 输入 k8s.container.name。Type: string | bool | int | float |
| k8s_deployment_name | 输入 k8s.deployment.name。Type: string | bool | int | float |
| k8s_replicaset_name | 输入 k8s.replicaset.name。Type: string | bool | int | float |
| k8s_statefulset_name | 输入 k8s.statefulset.name。Type: string | bool | int | float |
| k8s_daemonset_name | 输入 k8s.daemonset.name。Type: string | bool | int | float |
| k8s_job_name | 输入 k8s.job.name。Type: string | bool | int | float |
| k8s_cronjob_name | 输入 k8s.cronjob.name。Type: string | bool | int | float |
| process_pid | 输入 process.pid。Type: string | bool | int | float |
| project | 输入 project。Type: string | bool | int | float |
| version | 输入 version。Type: string | bool | int | float |
| env | 输入 env。Type: string | bool | int | float |
| pod_name | 输入兼容属性 pod_name;Kubernetes 模式下也会被规范化为同名 tag。Type: string | bool | int | float |
| pod_namespace | 输入兼容属性 pod_namespace;Kubernetes 模式下也会被规范化为同名 tag。Type: string | bool | int | float |
| sdk_language | 输入 telemetry.sdk.language。Type: string | bool | int | float |
| sdk_name | 输入 telemetry.sdk.name。Type: string | bool | int | float |
| sdk_version | 输入 telemetry.sdk.version。Type: string | bool | int | float |
在 Kubernetes 模式下,Trace 还可增加与容器日志相同的集群、Node、Pod、Container、workload 和白名单 label tag。OTel Resource 中已经提供的身份信息优先,缺失项才从本节点 Pod 缓存补全。
Kubernetes 采集¶
Kubernetes 模式由 [kubernetes].enabled = true 开启。DaemonSet 通过本节点的 Pod 元数据、
Kubelet /stats/summary 和宿主机 /var/log/pods 采集数据:
| 数据 | 输出 |
|---|---|
| Pod 指标 | kube_pod |
| 容器指标 | docker_containers |
| Pod 对象 | kubelet_pod |
| 容器对象 | docker_containers |
| 容器日志 | logging;自动附加 Pod、容器、镜像、namespace、workload 等上下文。 |
[kubernetes]
# 是否启用 Kubernetes 采集。
enabled = true
# 是否上报 Pod 和容器指标。
metrics_enabled = true
# 是否上报 Pod 和容器对象。
objects_enabled = true
# Kubernetes 集群名称。
cluster_name = "default"
# 本节点 Pod 元数据刷新周期(秒)。
refresh_secs = 60
# Pod 和容器对象上报周期(秒)。
object_interval_secs = 300
# 允许附加到数据的 Pod label 白名单。
label_tags = ["app.kubernetes.io/name"]
metrics_enabled 和 objects_enabled 可独立控制。指标默认每 60 秒采集,对象启动时立即上报、
之后默认每 5 分钟上报。label_tags 是允许附加的 Pod label 白名单,用于控制标签基数。
rsdatakit 访问 Kubelet 时使用 HTTPS 和自动挂载的 ServiceAccount bearer token,并由
nodes/stats RBAC 权限完成授权;为兼容节点本地自签名证书和缺少 Node IP SAN 的集群,
Kubelet 连接不校验服务端证书。Kubernetes API 使用独立客户端,仍通过 ServiceAccount CA
严格校验证书。
项目 DaemonSet 示例还会挂载 /var/log/pods、/var/lib/docker/containers 和
/var/lib/rsdatakit。容器日志来自节点本地文件,不会为每条日志调用 Kubernetes API;Pod 元数据
通过共享的本节点缓存补全。
指标¶
Kubelet Summary 中没有提供的可选字段不会产生。CPU、内存、文件系统和网络累计值均来自本节点
Kubelet /stats/summary;request、limit、ready、restart 和 workload tag 来自 Pod API 元数据。
kube_pod¶
每个本节点 Pod 产生一个 Point。
| Tags & Fields | Description |
|---|---|
| cluster_name_k8s ( tag) |
Kubernetes 集群名。 |
| node_name ( tag) |
Pod 所在节点。 |
| namespace ( tag) |
Pod 命名空间。 |
| pod_namespace ( tag) |
Pod 命名空间的 DataKit 兼容字段;Pod API 元数据可用时产生。 |
| pod ( tag) |
Kubelet Summary 中的 Pod 名称。 |
| pod_name ( tag) |
Pod 名称。 |
| uid ( tag) |
Kubelet Summary 中的 Pod UID。 |
| pod_uid ( tag) |
Pod UID。 |
| pod_ip ( tag) |
Pod IP;元数据可用时产生。 |
| deployment ( tag) |
Deployment 名称;Pod 由 ReplicaSet 管理且可从 pod-template-hash 推导时产生。 |
| daemonset ( tag) |
管理该 Pod 的 DaemonSet 名称;存在时产生。 |
| statefulset ( tag) |
管理该 Pod 的 StatefulSet 名称;存在时产生。 |
| replica_set ( tag) |
管理该 Pod 的 ReplicaSet 名称;存在时产生。 |
| job ( tag) |
管理该 Pod 的 Job 名称;存在时产生。 |
<label_key>( tag) |
[kubernetes].label_tags 白名单中 Pod label 的规范化 key(. 转为 _,/ 保留)。 |
| cpu_usage_millicores | 当前 CPU 使用量。 Type: float | (gauge) Unit: mCPU |
| cpu_usage | 当前 CPU 使用量;单核为 100%,多核并行时可超过 100%。 Type: float | (gauge) Unit: percent |
| cpu_usage_base100 | 当前 CPU 使用量除以 Node CPU 容量;Node 容量可获得时产生。 Type: float | (gauge) Unit: percent |
| cpu_usage_core_nano_seconds | 累计 CPU 使用时间。 Type: int | (count) Unit: ns |
| cpu_limit_millicores | Pod 内普通容器的 CPU limit 之和;未配置时不产生。 Type: float | (gauge) Unit: mCPU |
| cpu_request_millicores | Pod 内普通容器的 CPU request 之和;未配置时不产生。 Type: float | (gauge) Unit: mCPU |
| cpu_usage_base_limit | CPU 使用量占 CPU limit 的百分比;配置了 limit 且有使用量时产生。 Type: float | (gauge) Unit: percent |
| cpu_usage_base_request | CPU 使用量占 CPU request 的百分比;配置了 request 且有使用量时产生。 Type: float | (gauge) Unit: percent |
| mem_available | 当前可用内存。 Type: int | (gauge) Unit: digital,B |
| mem_usage | 当前 working set 内存。 Type: int | (gauge) Unit: digital,B |
| mem_working_set | 当前 working set 内存,值与 mem_usage 相同。Type: int | (gauge) Unit: digital,B |
| memory_usage_bytes | 当前 working set 内存的兼容字段,值与 mem_usage 相同。Type: int | (gauge) Unit: digital,B |
| mem_rss | 常驻内存。 Type: int | (gauge) Unit: digital,B |
| mem_capacity | Node 内存容量;Node 容量可获得时产生。 Type: int | (gauge) Unit: digital,B |
| memory_capacity | Node 内存容量兼容字段,值与 mem_capacity 相同。Type: int | (gauge) Unit: digital,B |
| mem_used_percent | working set 占 Node 内存容量的百分比。 Type: float | (gauge) Unit: percent |
| memory_used_percent | mem_used_percent 的兼容字段。Type: float | (gauge) Unit: percent |
| mem_limit | Pod 内普通容器内存 limit 之和;未配置时不产生。 Type: float | (gauge) Unit: digital,B |
| mem_request | Pod 内普通容器内存 request 之和;未配置时不产生。 Type: float | (gauge) Unit: digital,B |
| mem_used_percent_base_limit | 内存使用量占内存 limit 的百分比;配置了 limit 且有使用量时产生。 Type: float | (gauge) Unit: percent |
| mem_used_percent_base_request | 内存使用量占内存 request 的百分比;配置了 request 且有使用量时产生。 Type: float | (gauge) Unit: percent |
| network_bytes_rcvd | Pod 累计接收字节数。 Type: int | (count) Unit: digital,B |
| network_bytes_sent | Pod 累计发送字节数。 Type: int | (count) Unit: digital,B |
| network_errors_rcvd | Pod 累计接收网络错误数。 Type: int | (count) Unit: count |
| network_errors_sent | Pod 累计发送网络错误数。 Type: int | (count) Unit: count |
| ephemeral_storage_available_bytes | Pod 临时存储可用容量。 Type: int | (gauge) Unit: digital,B |
| ephemeral_storage_capacity_bytes | Pod 临时存储总容量。 Type: int | (gauge) Unit: digital,B |
| ephemeral_storage_used_bytes | Pod 临时存储已用容量。 Type: int | (gauge) Unit: digital,B |
| ephemeral_storage_inodes | Pod 临时存储 inode 总数。 Type: int | (gauge) Unit: count |
| ephemeral_storage_inodes_free | Pod 临时存储空闲 inode 数。 Type: int | (gauge) Unit: count |
| ephemeral_storage_inodes_used | Pod 临时存储已用 inode 数。 Type: int | (gauge) Unit: count |
| ready | 当前处于 running 状态的普通容器数。 Type: float | (gauge) Unit: count |
| restarts | 普通容器中的最大重启次数。 Type: float | (gauge) Unit: count |
docker_containers(Kubernetes 指标)¶
每个本节点容器产生一个 Point。容器网络由 Pod 级别的 kube_pod 上报,因此这里没有网络字段。
| Tags & Fields | Description |
|---|---|
| cluster_name_k8s ( tag) |
Kubernetes 集群名。 |
| host ( tag) |
容器所在节点,值与 node_name 相同。 |
| node_name ( tag) |
容器所在节点。 |
| namespace ( tag) |
Pod 命名空间。 |
| pod_namespace ( tag) |
Pod 命名空间的兼容字段;元数据可用时产生。 |
| pod_name ( tag) |
Pod 名称。 |
| pod_uid ( tag) |
Pod UID。 |
| pod_ip ( tag) |
Pod IP;元数据可用时产生。 |
| container_name ( tag) |
容器名称。 |
| container_id ( tag) |
不含 runtime 前缀的容器 ID;元数据可用时产生。 |
| container_runtime ( tag) |
容器运行时,例如 containerd。 |
| container_type ( tag) |
固定为 kubernetes。 |
| image ( tag) |
容器镜像。 |
| state ( tag) |
Kubelet Summary 中出现的容器当前固定为 running。 |
| deployment ( tag) |
Deployment 名称;存在时产生。 |
| daemonset ( tag) |
DaemonSet 名称;存在时产生。 |
| statefulset ( tag) |
StatefulSet 名称;存在时产生。 |
| replica_set ( tag) |
ReplicaSet 名称;存在时产生。 |
| job ( tag) |
Job 名称;存在时产生。 |
<label_key>( tag) |
[kubernetes].label_tags 白名单中 Pod label 的规范化 key。 |
| cpu_usage_millicores | 当前容器 CPU 使用量。 Type: float | (gauge) Unit: mCPU |
| cpu_usage | 当前容器 CPU 使用量;单核为 100%。 Type: float | (gauge) Unit: percent |
| cpu_usage_base100 | 当前容器 CPU 使用量除以 Node CPU 容量;容量可获得时产生。 Type: float | (gauge) Unit: percent |
| cpu_usage_core_nano_seconds | 容器累计 CPU 使用时间。 Type: int | (count) Unit: ns |
| cpu_limit_millicores | 容器 CPU limit;未配置时不产生。 Type: float | (gauge) Unit: mCPU |
| cpu_request_millicores | 容器 CPU request;未配置时不产生。 Type: float | (gauge) Unit: mCPU |
| cpu_usage_base_limit | 容器 CPU 使用量占 CPU limit 的百分比。 Type: float | (gauge) Unit: percent |
| cpu_usage_base_request | 容器 CPU 使用量占 CPU request 的百分比。 Type: float | (gauge) Unit: percent |
| mem_available | 容器当前可用内存。 Type: int | (gauge) Unit: digital,B |
| mem_usage | 容器 working set 内存。 Type: int | (gauge) Unit: digital,B |
| mem_working_set | 容器 working set 内存,值与 mem_usage 相同。Type: int | (gauge) Unit: digital,B |
| memory_usage_bytes | mem_usage 的兼容字段。Type: int | (gauge) Unit: digital,B |
| mem_rss | 容器常驻内存。 Type: int | (gauge) Unit: digital,B |
| mem_capacity | Node 内存容量;容量可获得时产生。 Type: int | (gauge) Unit: digital,B |
| memory_capacity | mem_capacity 的兼容字段。Type: int | (gauge) Unit: digital,B |
| mem_used_percent | 容器 working set 占 Node 内存容量的百分比。 Type: float | (gauge) Unit: percent |
| memory_used_percent | mem_used_percent 的兼容字段。Type: float | (gauge) Unit: percent |
| mem_limit | 容器内存 limit;未配置时不产生。 Type: float | (gauge) Unit: digital,B |
| mem_request | 容器内存 request;未配置时不产生。 Type: float | (gauge) Unit: digital,B |
| mem_used_percent_base_limit | 容器内存使用量占内存 limit 的百分比。 Type: float | (gauge) Unit: percent |
| mem_used_percent_base_request | 容器内存使用量占内存 request 的百分比。 Type: float | (gauge) Unit: percent |
| ephemeral_storage_available_bytes | 容器 rootfs 可用容量。 Type: int | (gauge) Unit: digital,B |
| ephemeral_storage_capacity_bytes | 容器 rootfs 总容量。 Type: int | (gauge) Unit: digital,B |
| ephemeral_storage_used_bytes | 容器 rootfs 已用容量。 Type: int | (gauge) Unit: digital,B |
| ephemeral_storage_inodes | 容器 rootfs inode 总数。 Type: int | (gauge) Unit: count |
| ephemeral_storage_inodes_free | 容器 rootfs 空闲 inode 数。 Type: int | (gauge) Unit: count |
| ephemeral_storage_inodes_used | 容器 rootfs 已用 inode 数。 Type: int | (gauge) Unit: count |
| log_available_bytes | 容器日志文件系统可用容量。 Type: int | (gauge) Unit: digital,B |
| log_capacity_bytes | 容器日志文件系统总容量。 Type: int | (gauge) Unit: digital,B |
| log_used_bytes | 容器日志文件系统已用容量。 Type: int | (gauge) Unit: digital,B |
| log_inodes | 容器日志文件系统 inode 总数。 Type: int | (gauge) Unit: count |
| log_inodes_free | 容器日志文件系统空闲 inode 数。 Type: int | (gauge) Unit: count |
| log_inodes_used | 容器日志文件系统已用 inode 数。 Type: int | (gauge) Unit: count |
对象¶
对象使用与 DataKit 页面兼容的对象分类。对象 message 是当前对象字段的 JSON 快照。
如果 Kubelet Summary 当轮可用,对象还会带上同一 Pod/容器的资源字段;这些字段在下表中逐一列出。
kubelet_pod 对象¶
| Tags & Fields | Description |
|---|---|
| name ( tag) |
对象名称,固定为 Pod UID。 |
| uid ( tag) |
Pod UID。 |
| pod_name ( tag) |
Pod 名称。 |
| namespace ( tag) |
Pod 命名空间。 |
| pod_namespace ( tag) |
Pod 命名空间兼容字段。 |
| cluster_name_k8s ( tag) |
Kubernetes 集群名。 |
| node_name ( tag) |
Pod 所在节点;Pod 尚未调度时不产生。 |
| host ( tag) |
Pod 所在节点;值与 node_name 相同。 |
| pod ( tag) |
Kubelet Summary 中的 Pod 名称;Summary 可用时产生。 |
| phase ( tag) |
Pod phase,例如 Running、Pending。 |
| status ( tag) |
当前 Pod 状态;优先使用容器 waiting reason,否则为 Pod phase。 |
| pod_ip ( tag) |
Pod IP;存在时产生。 |
| qos_class ( tag) |
Pod QoS class;存在时产生。 |
| workload_name ( tag) |
规范化工作负载名;优先 Deployment,否则第一个已识别 owner。 |
| deployment ( tag) |
Deployment 名称;存在时产生。 |
| daemonset ( tag) |
DaemonSet 名称;存在时产生。 |
| statefulset ( tag) |
StatefulSet 名称;存在时产生。 |
| replica_set ( tag) |
ReplicaSet 名称;存在时产生。 |
| job ( tag) |
Job 名称;存在时产生。 |
<label_key>( tag) |
[kubernetes].label_tags 白名单中 Pod label 的规范化 key。 |
| available | Pod 内普通容器总数。 Type: int Unit: count |
| ready | 当前处于 running 状态的普通容器数。 Type: int Unit: count |
| restarts | 普通容器中的最大重启次数。 Type: int Unit: count |
| age | Pod 自创建以来的秒数。 Type: int Unit: s |
| cpu_usage_millicores | Pod 当前 CPU 使用量;Kubelet Summary 可用时产生。 Type: float Unit: mCPU |
| cpu_usage | Pod 当前 CPU 使用量;单核为 100%。 Type: float Unit: percent |
| cpu_usage_base100 | Pod CPU 使用量除以 Node CPU 容量。 Type: float Unit: percent |
| cpu_usage_core_nano_seconds | Pod 累计 CPU 使用时间。 Type: int Unit: ns |
| cpu_limit_millicores | Pod 内普通容器 CPU limit 之和。 Type: float Unit: mCPU |
| cpu_request_millicores | Pod 内普通容器 CPU request 之和。 Type: float Unit: mCPU |
| cpu_usage_base_limit | Pod CPU 使用量占 CPU limit 的百分比。 Type: float Unit: percent |
| cpu_usage_base_request | Pod CPU 使用量占 CPU request 的百分比。 Type: float Unit: percent |
| mem_available | Pod 当前可用内存。 Type: int Unit: digital,B |
| mem_usage | Pod working set 内存。 Type: int Unit: digital,B |
| mem_working_set | Pod working set 内存,值与 mem_usage 相同。Type: int Unit: digital,B |
| memory_usage_bytes | mem_usage 的兼容字段。Type: int Unit: digital,B |
| mem_rss | Pod 常驻内存。 Type: int Unit: digital,B |
| mem_capacity | Node 内存容量。 Type: int Unit: digital,B |
| memory_capacity | mem_capacity 的兼容字段。Type: int Unit: digital,B |
| mem_used_percent | Pod working set 占 Node 内存容量的百分比。 Type: float Unit: percent |
| memory_used_percent | mem_used_percent 的兼容字段。Type: float Unit: percent |
| mem_limit | Pod 内普通容器内存 limit 之和。 Type: float Unit: digital,B |
| mem_request | Pod 内普通容器内存 request 之和。 Type: float Unit: digital,B |
| mem_used_percent_base_limit | Pod 内存使用量占内存 limit 的百分比。 Type: float Unit: percent |
| mem_used_percent_base_request | Pod 内存使用量占内存 request 的百分比。 Type: float Unit: percent |
| network_bytes_rcvd | Pod 累计接收字节数。 Type: int Unit: digital,B |
| network_bytes_sent | Pod 累计发送字节数。 Type: int Unit: digital,B |
| network_errors_rcvd | Pod 累计接收网络错误数。 Type: int Unit: count |
| network_errors_sent | Pod 累计发送网络错误数。 Type: int Unit: count |
| ephemeral_storage_available_bytes | Pod 临时存储可用容量。 Type: int Unit: digital,B |
| ephemeral_storage_capacity_bytes | Pod 临时存储总容量。 Type: int Unit: digital,B |
| ephemeral_storage_used_bytes | Pod 临时存储已用容量。 Type: int Unit: digital,B |
| ephemeral_storage_inodes | Pod 临时存储 inode 总数。 Type: int Unit: count |
| ephemeral_storage_inodes_free | Pod 临时存储空闲 inode 数。 Type: int Unit: count |
| ephemeral_storage_inodes_used | Pod 临时存储已用 inode 数。 Type: int Unit: count |
| message | 对象 JSON 快照。 Type: string |
docker_containers 对象¶
| Tags & Fields | Description |
|---|---|
| name ( tag) |
对象名称,固定为容器 ID。 |
| container_id ( tag) |
不含 runtime 前缀的容器 ID。 |
| container_name ( tag) |
容器名称。 |
| container_runtime ( tag) |
容器运行时,例如 containerd;可获得时产生。 |
| image ( tag) |
容器镜像;可获得时产生。 |
| container_type ( tag) |
固定为 kubernetes。 |
| state ( tag) |
当前固定为 running。 |
| cluster_name_k8s ( tag) |
Kubernetes 集群名。 |
| host ( tag) |
容器所在节点。 |
| node_name ( tag) |
容器所在节点。 |
| namespace ( tag) |
Pod 命名空间。 |
| pod_namespace ( tag) |
Pod 命名空间兼容字段;源指标带有该 tag 时保留。 |
| pod_name ( tag) |
Pod 名称。 |
| pod_uid ( tag) |
Pod UID。 |
| pod_ip ( tag) |
Pod IP;源指标带有该 tag 时保留。 |
| workload_name ( tag) |
规范化工作负载名;存在时产生。 |
| deployment ( tag) |
Deployment 名称;存在时产生。 |
| daemonset ( tag) |
DaemonSet 名称;存在时产生。 |
| statefulset ( tag) |
StatefulSet 名称;存在时产生。 |
| replica_set ( tag) |
ReplicaSet 名称;存在时产生。 |
| job ( tag) |
Job 名称;存在时产生。 |
<label_key>( tag) |
[kubernetes].label_tags 白名单中 Pod label 的规范化 key。 |
| age | 容器启动以来的秒数;启动时间可获得时产生。 Type: int Unit: s |
| cpu_usage_millicores | 当前容器 CPU 使用量。 Type: float Unit: mCPU |
| cpu_usage | 当前容器 CPU 使用量。 Type: float Unit: percent |
| cpu_usage_base100 | 容器 CPU 使用量除以 Node CPU 容量。 Type: float Unit: percent |
| cpu_usage_core_nano_seconds | 容器累计 CPU 使用时间。 Type: int Unit: ns |
| cpu_limit_millicores | 容器 CPU limit。 Type: float Unit: mCPU |
| cpu_request_millicores | 容器 CPU request。 Type: float Unit: mCPU |
| cpu_usage_base_limit | 容器 CPU 使用量占 CPU limit 的百分比。 Type: float Unit: percent |
| cpu_usage_base_request | 容器 CPU 使用量占 CPU request 的百分比。 Type: float Unit: percent |
| mem_available | 容器当前可用内存。 Type: int Unit: digital,B |
| mem_usage | 容器 working set 内存。 Type: int Unit: digital,B |
| mem_working_set | 容器 working set 内存,值与 mem_usage 相同。Type: int Unit: digital,B |
| memory_usage_bytes | mem_usage 的兼容字段。Type: int Unit: digital,B |
| mem_rss | 容器常驻内存。 Type: int Unit: digital,B |
| mem_capacity | Node 内存容量。 Type: int Unit: digital,B |
| memory_capacity | mem_capacity 的兼容字段。Type: int Unit: digital,B |
| mem_used_percent | 容器 working set 占 Node 内存容量的百分比。 Type: float Unit: percent |
| memory_used_percent | mem_used_percent 的兼容字段。Type: float Unit: percent |
| mem_limit | 容器内存 limit。 Type: float Unit: digital,B |
| mem_request | 容器内存 request。 Type: float Unit: digital,B |
| mem_used_percent_base_limit | 容器内存使用量占内存 limit 的百分比。 Type: float Unit: percent |
| mem_used_percent_base_request | 容器内存使用量占内存 request 的百分比。 Type: float Unit: percent |
| ephemeral_storage_available_bytes | 容器 rootfs 可用容量。 Type: int Unit: digital,B |
| ephemeral_storage_capacity_bytes | 容器 rootfs 总容量。 Type: int Unit: digital,B |
| ephemeral_storage_used_bytes | 容器 rootfs 已用容量。 Type: int Unit: digital,B |
| ephemeral_storage_inodes | 容器 rootfs inode 总数。 Type: int Unit: count |
| ephemeral_storage_inodes_free | 容器 rootfs 空闲 inode 数。 Type: int Unit: count |
| ephemeral_storage_inodes_used | 容器 rootfs 已用 inode 数。 Type: int Unit: count |
| log_available_bytes | 容器日志文件系统可用容量。 Type: int Unit: digital,B |
| log_capacity_bytes | 容器日志文件系统总容量。 Type: int Unit: digital,B |
| log_used_bytes | 容器日志文件系统已用容量。 Type: int Unit: digital,B |
| log_inodes | 容器日志文件系统 inode 总数。 Type: int Unit: count |
| log_inodes_free | 容器日志文件系统空闲 inode 数。 Type: int Unit: count |
| log_inodes_used | 容器日志文件系统已用 inode 数。 Type: int Unit: count |
| message | 对象 JSON 快照。 Type: string |
Prometheus 采集¶
Prometheus 抓取是 Kubernetes 模式的一部分。独立二进制默认关闭,项目 DaemonSet 示例默认开启:
[kubernetes.prometheus]
# 是否启用本节点 Prometheus 目标发现和抓取。
enabled = true
# 每个目标的抓取周期(秒)。
scrape_interval_secs = 30
# 单次抓取超时(秒)。
scrape_timeout_secs = 10
# 是否保留 exporter 的完整指标名作为 field 名。
keep_exist_metric_name = true
# 是否发现带 prometheus.io/scrape 注解的 Pod。
discover_pod_annotations = true
# 是否发现带 prometheus.io/scrape 注解的 Service。
discover_service_annotations = true
# 是否发现 Prometheus Operator 的 PodMonitor。
discover_pod_monitors = true
# 是否发现 Prometheus Operator 的 ServiceMonitor。
discover_service_monitors = true
除自动发现外,也可以配置可信的显式目标:
[[kubernetes.prometheus.instances]]
# 目标来源类型。
role = "pod" # node | pod | service | endpoints
# 目标所在命名空间。
namespaces = ["default"]
# Kubernetes label selector。
selector = "app=nginx"
# 抓取协议。
scheme = "http"
# 端口号或命名端口。
port = "metrics"
# 指标 HTTP 路径。
path = "/metrics"
# measurement 名称;留空时自动推导。
measurement = ""
# 追加到此目标所有指标的 tag。
tags = { team = "platform" }
支持以下目标来源:
- Pod/Service 的
prometheus.io/scrape、port、scheme、path等 annotations; - Prometheus Operator 的 PodMonitor 和 ServiceMonitor;
- 可信静态配置中的
node、pod、service、endpoints实例。
只抓取可确认属于当前节点的目标,避免 DaemonSet 的每个副本重复抓取整个集群。采集的
measurement 由 exporter 指标名或静态 measurement 配置决定;collector.up 用于表示每个目标的抓取结果。
如不需要相应发现能力,请关闭对应 discover_* 开关。关闭 Service annotation、ServiceMonitor 且未配置
service/endpoints 显式实例时,不会订阅全局 Service 和 EndpointSlice 资源。
指标转换规则¶
Prometheus exporter 的 measurement 和 field 由指标名动态生成,无法像固定主机指标一样穷举:
| 配置 / 输入 | 输出规则 |
|---|---|
未配置 measurement,指标名含 _ |
第一个 _ 之前作为 measurement。例如 http_requests_total → measurement http。 |
keep_exist_metric_name = true |
field 保留完整指标名,例如 requests_total 或 http_requests_total,具体取决于 measurement 是否显式配置。 |
keep_exist_metric_name = false |
未显式配置 measurement 时去掉第一个 _ 前缀,例如 http_requests_total → measurement http、field requests_total。 |
显式配置 measurement |
所有样本写入该 measurement;field 使用完整指标名或按上面的保留规则处理。 |
| Prometheus label | 转为 tag;采集目标的 Kubernetes 身份 tag 优先于 exporter 提供的同名身份 label。 |
| Counter | 作为累计和类型上报;名称缺少 _total 时自动补充。 |
| Histogram / Summary | 展开为 _sum、_count、_bucket,以及 le/quantile tag。 |
| Info / StateSet | Info 转为值为 1 的 gauge;StateSet 为每个状态产生 0 或 1。 |
每次抓取还会产生采集器状态指标:
collector¶
| Tags & Fields | Description |
|---|---|
| host ( tag) |
目标的非 loopback IP;无法确定时为空字符串。 |
| job ( tag) |
发现或显式配置的 Prometheus job。 |
| 目标 tags ( tag) |
目标自带的 Pod、Service、Node、namespace、instance 等 tag。 |
| up | 本次目标抓取且解析成功为 1,失败为 0。Type: float | (gauge) |
运行与验证¶
前台运行:
systemd 安装完成后可使用:
启动日志出现 rsdatakit started 后,可在中心检查以下数据:
| 功能 | 验证内容 |
|---|---|
| 主机 | cpu、mem、disk、diskio、net、system 指标及 HOST 对象。 |
| 日志 | [logs].source 对应的数据源、采集器 tag,以及原始 message 或 json_as_fields 产生的 JSON 字段。 |
| Trace | opentelemetry 数据源中的服务、Span 层级和 Trace ID。 |
| Kubernetes | kube_pod、docker_containers 指标以及 Pod/容器对象。 |
| Prometheus | exporter 指标以及 collector.up。 |
配置独立健康地址或开启 OTLP HTTP 后可查看健康状态,例如:
返回 degraded 表示 Dataway、WAL 或某个采集模块存在当前故障;返回 HTTP 503 表示队列、
WAL 或后台任务已进入不健康状态。
注意事项¶
- 日志和 Trace 在网络错误、HTTP 5xx 或 429 时写入 WAL 并重试;其他 4xx 不重试。 指标和对象是周期快照,不写入 WAL。
- 根据日志和 Trace 写入量以及允许的 Dataway 中断时间调整
wal.max_bytes。 - Dataway token 和 OTLP bearer token 应通过 Secret 或受限配置文件注入,不要提交到仓库。
- 仅将必要的 Pod label 加入
kubernetes.label_tags,避免产生高基数 tag。 RUST_LOG=rsdatakit=debug会产生大量运行日志,只应在短时间排障时使用。