Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Rename `network.direction` values in crowdstrike/falcon to `ingress`/`egress`. {pull}23041[23041]
- Possible values for Netflow's locality fields (source.locality, destination.locality and flow.locality) are now `internal` and `external`, instead of `private` and `public`. {issue}24272[24272] {pull}24295[24295]
- Add User Agent Parser for Azure Sign In Logs Ingest Pipeline {pull}23201[23201]
- Changes filebeat httpjson input's append transform to create a list even with only a single value{pull}25074[25074]

*Heartbeat*

Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/docs/inputs/input-httpjson.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ The access limitations are described in the corresponding configuration sections
[float]
==== `append`

Appends a value to a list. If the field does not exist, the first entry will be a scalar value, and subsequent additions will convert the value to a list.
Appends a value to an array. If the field does not exist, the first entry will create a new array. If the field exists, the value is appended to the existing field and converted to a list.

["source","yaml",subs="attributes"]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func appendToCommonMap(m common.MapStr, key, val string) error {
if val == "" {
return nil
}
var value interface{} = val
var value interface{}
if found, _ := m.HasKey(key); found {
prev, _ := m.GetValue(key)
switch t := prev.(type) {
Expand All @@ -137,6 +137,8 @@ func appendToCommonMap(m common.MapStr, key, val string) error {
value = []interface{}{prev, val}
}

} else {
value = []interface{}{val}
}
if _, err := m.Put(key, value); err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ func TestAppendFunctions(t *testing.T) {
expectedTr: transformable{"body": common.MapStr{"a_key": []interface{}{"a_value", "another_value"}}},
expectedErr: nil,
},
{
name: "appendBodyWithSingleValue",
tfunc: appendBody,
paramCtx: &transformContext{},
paramTr: transformable{"body": common.MapStr{}},
paramKey: "a_key",
paramVal: "a_value",
expectedTr: transformable{"body": common.MapStr{"a_key": []interface{}{"a_value"}}},
expectedErr: nil,
},
{
name: "appendHeader",
tfunc: appendHeader,
Expand Down