多文件输入插件
此插件将多个文件的组合数据读取到一个度量中,为每个文件创建一个字段或标签。这通常有助于从 /sys 或 /proc 文件系统中创建自定义指标。
要解析单个文件的指标,您应该改用 file 输入插件。
引入于: Telegraf v1.10.0 标签: system 操作系统支持: all
全局配置选项
插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md。
配置
# Aggregates the contents of multiple files into a single point
[[inputs.multifile]]
## Base directory where telegraf will look for files.
## Omit this option to use absolute paths.
base_dir = "/sys/bus/i2c/devices/1-0076/iio:device0"
## If true discard all data when a single file can't be read.
## Else, Telegraf omits the field generated from this file.
# fail_early = true
## Files to parse each interval.
[[inputs.multifile.file]]
file = "in_pressure_input"
dest = "pressure"
conversion = "float"
[[inputs.multifile.file]]
file = "in_temp_input"
dest = "temperature"
conversion = "float(3)"
[[inputs.multifile.file]]
file = "in_humidityrelative_input"
dest = "humidityrelative"
conversion = "float(3)"Metrics
每个文件表可以包含以下选项
file: 要解析的文件的路径,相对于base_dir。dest: 字段/标签键的名称,默认为$(basename file)。conversion: 用于解析文件内容的的数据格式float(X): 将输入值转换为浮点数,并除以 10 的 X 次幂。实际上就是将小数点向左移动 X 位。例如,值为123且float(2)将得到1.23。float: 将值转换为浮点数,无调整。与float(0)相同。int: 将值转换为整数。string,"": 无转换。bool: 将值转换为布尔值。tag: 文件内容用作标签。
示例输出
此示例显示了一个连接到 Raspberry Pi 的 BME280,使用了示例配置。
multifile pressure=101.343285156,temperature=20.4,humidityrelative=48.9 1547202076000000000要重现此场景,请将 BMP280 连接到板子的 GPIO 引脚并注册 BME280 设备驱动程序。
cd /sys/bus/i2c/devices/i2c-1
echo bme280 0x76 > new_device内核驱动程序在 /sys/bus/i2c/devices/1-0076/iio:device0 中提供了以下文件。
in_humidityrelative_input:48900in_pressure_input:101.343285156in_temp_input:20400
此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。