gpt4 book ai didi

influxdb - 电报 : How collect Hexadecimal data and apply function before insert in influxdb?

转载 作者:行者123 更新时间:2023-12-02 15:46:58 24 4
gpt4 key购买 nike

我需要帮助读取十六进制数据并应用公式来转换数据。我的文件用尾部解析:

2022-09-15 00:04:39 AAA99 BBB99 24 43 B2 50
2022-09-15 00:04:40 BBB99 BBB99 2C 42 F1 4B

还有我的配置:

[global_tags]
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
debug = true
quiet = false
logtarget = "file"
logfile = "/var/log/telegraf.log"
hostname = ""
omit_hostname = true
[[outputs.influxdb]]
urls = ["http://127.0.0.1:8086"]
database = "data_hexa"
skip_database_creation = false
timeout = "5s"
username = "telegraf"
password = "***********"
user_agent = "telegraf"
[[outputs.file]]
files = ["stdout", "/tmp/metrics.out"]
[[inputs.tail]]
files = ["/mnt/cle/hexa*.log"]
name_override = "hexa_log"
from_beginning = true
max_undelivered_lines = 10000
character_encoding = "utf-8"
grok_patterns = ["%{CUSTOM_LOG}"]
grok_custom_patterns = '''
CUSTOM_LOG %{TIMESTAMP_ISO8601:timestamp:ts-"2006-01-02 15:04:05"} %{WORD:AAAinfo:tag} %{WORD:BBBinfo:tag} %{BASE16NUM:01hexa} %{BASE16NUM:02hexa} %{BASE16NUM:03hexa} %{BASE16NUM:04hexa}
'''
data_format = "grok"
grok_timezone = "Local"

使用此配置,数据类型为“字符串”,我想将十六进制值转换为整数 (IN_01hexa) 并应用类似 01hexa_convert = ((IN_01hexa)*0.8125-4.25) 的更改。然后,在我的数据库中, 01hexa_convert 的类型必须是 float。

最佳答案

您可以尝试通过 Telegraf's converter plugin 将十六进制字符串转换为整数.

示例代码如下:

[[processors.converter]]
[processors.converter.fields]
integer = ["*hexa"]

至于匹配处理部分,好像我们必须在Telegraf doesn't have such plugin yet的查询阶段做。 .

关于influxdb - 电报 : How collect Hexadecimal data and apply function before insert in influxdb?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73844473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com