Skip to content

Commit

Permalink
Allow fields with ip_range datatype (#26444) (#26473)
Browse files Browse the repository at this point in the history
This updates libbeat to support fields with ip_range type.

See https://www.elastic.co/guide/en/elasticsearch/reference/master/range.html

(cherry picked from commit ec52595)

Co-authored-by: Adrian Serrano <adrisr83@gmail.com>
  • Loading branch information
mergify[bot] and adriansr authored Jun 28, 2021
1 parent 904fc3b commit 8f0e280
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions libbeat/kibana/fields_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ var (
"geo_point": "geo_point",
"date": "date",
"ip": "ip",
"ip_range": "ip_range",
"boolean": "boolean",
}
)
2 changes: 2 additions & 0 deletions libbeat/kibana/fields_transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ func TestTransformTypes(t *testing.T) {
{commonField: mapping.Field{Type: "string"}, expected: nil},
{commonField: mapping.Field{Type: "date"}, expected: "date"},
{commonField: mapping.Field{Type: "geo_point"}, expected: "geo_point"},
{commonField: mapping.Field{Type: "ip"}, expected: "ip"},
{commonField: mapping.Field{Type: "ip_range"}, expected: "ip_range"},
{commonField: mapping.Field{Type: "invalid"}, expected: nil},
}
for idx, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion libbeat/mapping/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (f *Field) validateType() error {
allowedFormatters = []string{"geo_point"}
case "date_range":
allowedFormatters = []string{"date_range"}
case "boolean", "binary", "ip", "alias", "array":
case "boolean", "binary", "ip", "alias", "array", "ip_range":
// No formatters, metric types, or units allowed.
case "object":
if f.DynamicTemplate && (len(f.ObjectTypeParams) > 0 || f.ObjectType != "") {
Expand Down
5 changes: 5 additions & 0 deletions libbeat/mapping/field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ func TestFieldValidate(t *testing.T) {
},
err: true,
},
"allow ip_range": {
cfg: common.MapStr{"type": "ip_range"},
err: false,
field: Field{Type: "ip_range"},
},
}

for name, test := range tests {
Expand Down

0 comments on commit 8f0e280

Please sign in to comment.