Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fields validation for histogram subfields #17759

Merged
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-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
- New mage target for Functionbeat: generate pkg folder to make manager easier. {pull}15580[15880]
- Add support for MODULE environment variable in `mage goIntegTest` in metricbeat to run integration tests for a single module. {pull}17147[17147]
- Add support for a `TEST_TAGS` environment variable to add tags for tests selection following go build tags semantics, this environment variable is used by mage test targets to add build tags. Python tests can also be tagged with a decorator (`@beat.tag('sometag')`). {pull}16937[16937] {pull}17075[17075]
- Add fields validation for histogram subfields. {pull}17759[17759]
4 changes: 4 additions & 0 deletions libbeat/mapping/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ func (f Fields) getKeys(namespace string) []string {
} else {
keys = append(keys, field.Fields.getKeys(fieldName)...)
}
if field.ObjectType == "histogram" {
keys = append(keys, fieldName+".values")
keys = append(keys, fieldName+".counts")
}
}

return keys
Expand Down
4 changes: 4 additions & 0 deletions libbeat/tests/system/beat/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,10 @@ def extract_fields(doc_list, name):
if field.get("type") in ["object", "geo_point"]:
dictfields.append(newName)

if field.get("type") == "object" and field.get("object_type") == "histogram":
fields.append(newName + ".values")
fields.append(newName + ".counts")

if field.get("type") == "alias":
aliases.append(newName)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
type: http
url: "/metrics"
suffix: plain
omit_documented_fields_check:
# these are not mapped by this module but the oss one
- prometheus.labels.*
# histogram values & counts are not mapped (it's part of the type data)
- '*.histogram.values'
- '*.histogram.counts'
remove_fields_from_comparison: ["prometheus.labels.instance"]
module:
use_types: true
rate_counters: true
rate_counters: true
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing"

_ "github.com/elastic/beats/v7/x-pack/metricbeat/module/prometheus"

// Import common fields for validation
_ "github.com/elastic/beats/v7/metricbeat/module/prometheus"
)

func TestData(t *testing.T) {
Expand Down