elastic / elastic/logstash

mutate convert is flattening array of 1 into single element instead of maintaining array

Open
#3,649 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
19h 14m
Merged PRs (30d)
63

Description

The following creates an array properly (an array of 1 element in some cases):

```
filter {
mutate {
gsub => ["upstream_response_time", "-", null]
split => ["upstream_response_time", ":"]
strip => ["upstream_response_time"]
}
}
```

json output:

```
"upstream_response_time": [
"0.317"
],
```

The following creates flattens that array to just a single value instead of maintaining the array for json output:

```
filter {
mutate {
gsub => ["upstream_response_time", "-", null]
split => ["upstream_response_time", ":"]
strip => ["upstream_response_time"]
+ convert => ["upstream_response_time", "float"]
}
}
```

json output:

```
"upstream_response_time": 0.317,
```

I would like for the array to be maintained and represented in json as such. Is this a bug or feature request? The documents state that all values in the array are casted, not that the array structure is lost.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.