磁盘 IO
磁盘 IO 采集器用于磁盘流量和时间的指标的采集。
配置¶
成功安装 DataKit 并启动后,会默认开启 DiskIO 采集器,无需手动开启。
前置条件¶
对于部分旧版本 Windows 操作系统,如若遇到 DataKit 报错: "The system cannot find the file specified."
请以管理员身份运行 PowerShell,并执行:
在执行成功后需要重启 DataKit 服务。
采集器配置¶
进入 DataKit 安装目录下的 conf.d/samples 目录,复制 diskio.conf.sample 并命名为 diskio.conf。示例如下:
[[inputs.diskio]]
##(optional) collect interval, default is 10 seconds
interval = '10s'
## By default, gather stats for all devices including
## disk partitions.
## Setting interfaces using regular expressions will collect these expected devices.
# devices = ['''^sda\d*''', '''^sdb\d*''', '''vd.*''']
## If the disk serial number is not required, please uncomment the following line.
# skip_serial_number = true
## On systems which support it, device metadata can be added in the form of
## tags.
## Currently only Linux is supported via udev properties. You can view
## available properties for a device by running:
## 'udevadm info -q property -n /dev/sda'
## Note: Most, but not all, udev properties can be accessed this way. Properties
## that are currently inaccessible include DEVTYPE, DEVNAME, and DEVPATH.
# device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"]
## Using the same metadata source as device_tags,
## you can also customize the name of the device through a template.
## The "name_templates" parameter is a list of templates to try to apply equipment.
## The template can contain variables of the form "$PROPERTY" or "${PROPERTY}".
## The first template that does not contain any variables that do not exist
## for the device is used as the device name label.
## A typical use case for LVM volumes is to obtain VG/LV names,
## not DM-0 names which are almost meaningless.
## In addition, "device" is reserved specifically to indicate the device name.
# name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME", "$device:$ID_FS_TYPE"]
[inputs.diskio.tags]
# some_tag = "some_value"
# more_tag = "some_other_value"
配置好后,重启 DataKit 即可。
可通过 ConfigMap 方式注入采集器配置 或 配置 ENV_DATAKIT_INPUTS 开启采集器。
也支持以环境变量的方式修改配置参数(需要在 ENV_DEFAULT_ENABLED_INPUTS 中加为默认采集器):
-
ENV_INPUT_DISKIO_INTERVAL
采集器重复间隔时长
字段类型: Duration
采集器配置字段:
interval默认值: 10s
-
ENV_INPUT_DISKIO_DEVICES
使用正则表达式设置接口将收集这些预期的设备
字段类型: List
采集器配置字段:
devices示例:
^sda\d,^sdb\d,vd.* -
ENV_INPUT_DISKIO_DEVICE_TAGS
设备附加标签
字段类型: List
采集器配置字段:
device_tags示例: ID_FS_TYPE,ID_FS_USAGE
-
ENV_INPUT_DISKIO_NAME_TEMPLATES
使用与 device_ tags 相同的元数据源
字段类型: List
采集器配置字段:
name_templates示例: $ID_FS_LABEL,$DM_VG_NAME/$DM_LV_NAME
-
ENV_INPUT_DISKIO_SKIP_SERIAL_NUMBER
不需要磁盘序列号
字段类型: Boolean
采集器配置字段:
skip_serial_number默认值: false
-
ENV_INPUT_DISKIO_TAGS
自定义标签。如果配置文件有同名标签,将会覆盖它
字段类型: Map
采集器配置字段:
tags示例:
tag1=value1,tag2=value2
指标¶
以下所有数据采集,默认会追加名为 host 的全局 tag(tag 值为 DataKit 所在主机名),也可以在配置中通过 [[inputs.diskio.tags]] 另择 host 来命名。
diskio¶
| Tags & Fields | Description |
|---|---|
| host ( tag) |
System hostname. |
| name ( tag) |
Device name. |
| await | Average time for I/O requests to be served (ms). Linux only Type: float | (gauge) Unit: time,ms |
| io_time | Time spent doing I/Os. Linux only Type: int | (gauge) Unit: time,ms |
| iops_in_progress | I/Os currently in progress. Linux only Type: int | (gauge) Unit: count |
| merged_reads | The number of merged read requests. Linux only Type: int | (gauge) Unit: count |
| merged_writes | The number of merged write requests. Linux only Type: int | (gauge) Unit: count |
| read_bytes | The number of bytes read from the device. Type: int | (gauge) Unit: digital,B |
| read_bytes/sec | The number of bytes read on the device per second. Type: int | (gauge) Unit: traffic,B/S |
| read_time | Time spent reading. Type: int | (gauge) Unit: time,ms |
| reads | The number of read requests. Type: int | (gauge) Unit: count |
| weighted_io_time | Weighted time spent doing I/Os. Linux only Type: int | (gauge) Unit: time,ms |
| write_bytes | The number of bytes written to the device. Type: int | (gauge) Unit: digital,B |
| write_bytes/sec | The number of bytes written to the device per second. Type: int | (gauge) Unit: traffic,B/S |
| write_time | Time spent writing. Type: int | (gauge) Unit: time,ms |
| writes | The number of write requests. Type: int | (gauge) Unit: count |
FAQ¶
diskio 指标在 Linux 主机上的数据来源是什么¶
在 Linux 主机上,指标从 /proc/diskstats 文件获取并通过解析和计算得出;其中每一列的解释可参考文档;
部分数据来源列和指标的对应关系为:
diskstats 字段 |
diskio 指标 |
|---|---|
| col04: reads completed successfully | reads |
| col05: reads merged | merged_reads |
| col06: sectors read | read_bytes = col06 * sector_size; read_bytes/sec = (read_bytes - last(read_bytes))/(time - last(time)) |
| col07: time spent reading (ms) | read_time |
| col08: writes completed | writes |
| col09: writes merged | merged_writes |
| col10: sectors written | write_bytes = col10 * sector_size; write_bytes/sec = (write_bytes - last(write_bytes))/(time - last(time)) |
| col11: time spent writing (ms) | write_time |
| col12: I/Os currently in progress | iops_in_progress |
| col13: time spent doing I/Os (ms) | io_time |
| col14: weighted time spent doing I/Os (ms) | weighted_io_time |
注意:
- 扇区大小(
sector_size)为 512 字节; - 除
read_bytes/sec和write_bytes/sec外均为递增值。