是否可以在 LogQL 中将字符串值转换为数字?
Is it possible to convert string values to numbers in LogQL?
我正在关注 documentation 并感谢 | line_format
和 regexReplaceAll
我能够从一行中获取一些子字符串。
假设现在我有这些列:
line
123
7
123
54
14
有了这个,我想执行一些转换操作,ex sum,或者通过分组和总计进行转换操作。
它不起作用,因为我怀疑这些值不是数字,而只是字符串。
是否可以将其转换为数字?
我尝试使用 unwrap
但没有用:
sum_over_time(
{service="some"}
|="text expression"
| json
| line_format `{{ regexReplaceAll "text expression to remove from (\d+)" .label_id "" | trim }}`
| unwrap label_id [1m]
)
最后是
pipeline error: 'SampleExtractionErr' for series:
当我过滤错误时,没有结果。
我认为您正在寻找“unwrap”表达式。
请参阅关于此的 Loki 文档 here。
我正在关注 documentation 并感谢 | line_format
和 regexReplaceAll
我能够从一行中获取一些子字符串。
假设现在我有这些列:
line
123
7
123
54
14
有了这个,我想执行一些转换操作,ex sum,或者通过分组和总计进行转换操作。 它不起作用,因为我怀疑这些值不是数字,而只是字符串。 是否可以将其转换为数字?
我尝试使用 unwrap
但没有用:
sum_over_time(
{service="some"}
|="text expression"
| json
| line_format `{{ regexReplaceAll "text expression to remove from (\d+)" .label_id "" | trim }}`
| unwrap label_id [1m]
)
最后是
pipeline error: 'SampleExtractionErr' for series:
当我过滤错误时,没有结果。
我认为您正在寻找“unwrap”表达式。
请参阅关于此的 Loki 文档 here。