8

I am following documentation and thanks to | line_format and regexReplaceAll I was able to fetch some substring from a line.

Let's say now I have those columns:

line
123
7
123
54
14

Having that I want to perform some transform operation, ex sum, or transform operation with grouping by and taking total. It is not working as I am suspecting those values are not being numbers, but only strings. Is it possible to convert it to numbers?

I was trying using unwrap but it didn't worked:

sum_over_time(
    {service="some"} 
    |="text expression"
    | json
    | line_format `{{ regexReplaceAll "text expression to remove from (\\d+)" .label_id "${1}" | trim }}`
    | unwrap label_id [1m]
)

it ends up with

pipeline error: 'SampleExtractionErr' for series:

when I am filtering out errors, there is no results.

Rumid
  • 1,627
  • 2
  • 21
  • 39
  • Did you find a way to convert the String to an Integer or did you modify the data source? @Rumid – Illidan Feb 22 '23 at 17:45

1 Answers1

0

You can use int or float64 methods documented on the official docs to convert String to Int/Float

Clément Duveau
  • 399
  • 3
  • 14