You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below I am attempting to set application name by taking the body of a /var/log/messages log and indexing into the 5th value (assuming 0-base indexes)
set(resource.attributes["application_name"], Slice(body, " ")[4])
Expected Result
Since slice returns an array, I should be able to use an int to grab the nth value.
2024-02-28T13:18:57.248Z warn ottl@v0.94.0/parser.go:273 failed to execute statement {"kind": "processor", "name": "transform", "pipeline": "logs", "error": "type, []string, does not support int indexing", "statement": "set(resource.attributes[\"application_name\"], Split(body, \"\")[4])"}
Additional context
No response
The text was updated successfully, but these errors were encountered:
@fredyfredburger you are correct. OTTL currently has a limitation that it only knows how to index pcommon.Slice and []any. Since []any != []string, which is what Split returns, the indexing doesn't work.
See #29441 for more details. Closing this issue as a duplicate
Component(s)
pkg/ottl
What happened?
Description
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/LANGUAGE.md
Per this documentation it should be possible to do int referencing from the result of Slice(), but it is not because type []String does not support int indexing.
Steps to Reproduce
Below I am attempting to set application name by taking the body of a /var/log/messages log and indexing into the 5th value (assuming 0-base indexes)
set(resource.attributes["application_name"], Slice(body, " ")[4])
Expected Result
Since slice returns an array, I should be able to use an int to grab the nth value.
Actual Result
"type, []string, does not support int indexing"
Collector version
7ac560f
Environment information
Environment
OS: (Amazon Linux 2)
Compiler(if manually compiled): go 1.21.5
OpenTelemetry Collector configuration
Log output
Additional context
No response
The text was updated successfully, but these errors were encountered: