-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
I recently had a problem with a json transformation using jsonata in Telegraf. The transformation is the following:
$each($merge([metrics.fields]), function($value, $key) {{
"key": $key,
"value": $value
}}) ~> $reduce(function($acc, $entry) {(
$contains($entry.key, "__")
? (
$outerLevelKey := $split($entry.key, "__")[0];
$innerLevelKey := $split($entry.key, "__")[1];
$merge([$acc, {
$outerLevelKey: $merge([
$lookup($acc, $outerLevelKey),
{ $innerLevelKey:$entry.value }
])
}])
)
: $merge([$acc, { $entry.key: $entry.value }])
)}, {})
That works perfectly in the simulator https://try.jsonata.org/5aN2vrMY3, but when used in Telegraf it doesn't work and I found the problematic function is $lookup($acc, $outerLevelKey), since using $acc.PressSPM instead doesn't cause any problem.
I first asked in Telegraf but they say the issue seems to be in the upstream library they are using, i.e. jsonata-go.
Also, if anyone knows an alternative way to do the transformation, I'd really appreciate it.
Thanks a lot
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels