Skip to content

Commit 881e994

Browse files
committed
Merge branch 'master' into syslog-docs
2 parents 76af7c9 + 1c4f8b1 commit 881e994

19 files changed

Lines changed: 54 additions & 337 deletions

File tree

CHANGELOG-developer.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
5353
- Remove global ACK handler support via `SetACKHandler` from publisher pipeline. {pull}19632[19632]
5454
- Make implementing `Close` required for `reader.Reader` interfaces. {pull}20455[20455]
5555
- Remove `NumCPU` as clients should update the CPU count on the fly in case of config changes in a VM. {pull}23154[23154]
56+
- Remove Metricbeat EventFetcher and EventsFetcher interface. Use the reporter interface instead. {pull}25093[25093]
5657

5758
==== Bugfixes
5859

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
161161

162162
*Affecting all Beats*
163163

164+
- Fix events being dropped if they contain a floating point value of NaN or Inf. {pull}25051[25051]
164165
- Fix templates being overwritten if there was an error when check for the template existance. {pull}24332[24332]
165166
- Fix Kubernetes autodiscovery provider to correctly handle pod states and avoid missing event data {pull}17223[17223]
166167
- Fix `add_cloud_metadata` to better support modifying sub-fields with other processors. {pull}13808[13808]

NOTICE.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7454,11 +7454,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-seccomp-bpf@
74547454

74557455
--------------------------------------------------------------------------------
74567456
Dependency : github.com/elastic/go-structform
7457-
Version: v0.0.7
7457+
Version: v0.0.8
74587458
Licence type (autodetected): Apache-2.0
74597459
--------------------------------------------------------------------------------
74607460

7461-
Contents of probable licence file $GOMODCACHE/github.com/elastic/go-structform@v0.0.7/LICENSE:
7461+
Contents of probable licence file $GOMODCACHE/github.com/elastic/go-structform@v0.0.8/LICENSE:
74627462

74637463
Apache License
74647464
Version 2.0, January 2004
@@ -14556,11 +14556,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1455614556

1455714557
--------------------------------------------------------------------------------
1455814558
Dependency : github.com/stretchr/testify
14559-
Version: v1.6.1
14559+
Version: v1.7.0
1456014560
Licence type (autodetected): MIT
1456114561
--------------------------------------------------------------------------------
1456214562

14563-
Contents of probable licence file $GOMODCACHE/github.com/stretchr/testify@v1.6.1/LICENSE:
14563+
Contents of probable licence file $GOMODCACHE/github.com/stretchr/testify@v1.7.0/LICENSE:
1456414564

1456514565
MIT License
1456614566

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ require (
6868
github.com/elastic/go-lumber v0.1.0
6969
github.com/elastic/go-perf v0.0.0-20191212140718-9c656876f595
7070
github.com/elastic/go-seccomp-bpf v1.1.0
71-
github.com/elastic/go-structform v0.0.7
71+
github.com/elastic/go-structform v0.0.8
7272
github.com/elastic/go-sysinfo v1.6.0
7373
github.com/elastic/go-txfile v0.0.7
7474
github.com/elastic/go-ucfg v0.8.3
@@ -147,7 +147,7 @@ require (
147147
github.com/spf13/cobra v0.0.5
148148
github.com/spf13/pflag v1.0.5
149149
github.com/stretchr/objx v0.2.0 // indirect
150-
github.com/stretchr/testify v1.6.1
150+
github.com/stretchr/testify v1.7.0
151151
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b
152152
github.com/tsg/gopacket v0.0.0-20200626092518-2ab8e397a786
153153
github.com/ugorji/go/codec v1.1.8

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ github.com/elastic/go-plugins-helpers v0.0.0-20200207104224-bdf17607b79f h1:Fvsq
296296
github.com/elastic/go-plugins-helpers v0.0.0-20200207104224-bdf17607b79f/go.mod h1:OPGqFNdTS34kMReS5hPFtBhD9J8itmSDurs1ix2wx7c=
297297
github.com/elastic/go-seccomp-bpf v1.1.0 h1:jUzzDc6LyCtdolZdvL/26dad6rZ9vsc7xZ2eadKECAU=
298298
github.com/elastic/go-seccomp-bpf v1.1.0/go.mod h1:l+89Vy5BzjVcaX8USZRMOwmwwDScE+vxCFzzvQwN7T8=
299-
github.com/elastic/go-structform v0.0.7 h1:ihszOJQryNuIIHE2ZgsbiDq+agKO6V4yK0JYAI3tjzc=
300-
github.com/elastic/go-structform v0.0.7/go.mod h1:QrMyP3oM9Sjk92EVGLgRaL2lKt0Qx7ZNDRWDxB6khVs=
299+
github.com/elastic/go-structform v0.0.8 h1:U0qnb9Zqig7w+FhF+sLI3VZPPi/+2aJ0bIEW6R1z6Tk=
300+
github.com/elastic/go-structform v0.0.8/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4=
301301
github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0=
302302
github.com/elastic/go-sysinfo v1.6.0 h1:u0QbU8eWSwKRPcFQancnSY4Zi0COksCJXkUgPHxE5Tw=
303303
github.com/elastic/go-sysinfo v1.6.0/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0=
@@ -768,6 +768,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
768768
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
769769
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
770770
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8 h1:zLV6q4e8Jv9EHjNg/iHfzwDkCve6Ua5jCygptrtXHvI=
771+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
772+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
771773
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
772774
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b h1:X/8hkb4rQq3+QuOxpJK7gWmAXmZucF0EI1s1BfBLq6U=
773775
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b/go.mod h1:jAqhj/JBVC1PwcLTWd6rjQyGyItxxrhpiBl8LSuAGmw=

libbeat/outputs/codec/json/json.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func New(version string, config Config) *Encoder {
7373
func (e *Encoder) reset() {
7474
visitor := json.NewVisitor(&e.buf)
7575
visitor.SetEscapeHTML(e.config.EscapeHTML)
76+
visitor.SetIgnoreInvalidFloat(true)
7677

7778
var err error
7879

libbeat/outputs/codec/json/json_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package json
1919

2020
import (
21+
"math"
2122
"testing"
2223
"time"
2324

@@ -52,27 +53,31 @@ func TestJsonCodec(t *testing.T) {
5253
"msg": "message"
5354
}`,
5455
},
55-
"html escaping enabled": testCase{
56+
"html escaping enabled": {
5657
config: Config{EscapeHTML: true},
5758
in: common.MapStr{"msg": "<hello>world</hello>"},
5859
expected: `{"@timestamp":"0001-01-01T00:00:00.000Z","@metadata":{"beat":"test","type":"_doc","version":"1.2.3"},"msg":"\u003chello\u003eworld\u003c/hello\u003e"}`,
5960
},
60-
"html escaping disabled": testCase{
61+
"html escaping disabled": {
6162
config: Config{EscapeHTML: false},
6263
in: common.MapStr{"msg": "<hello>world</hello>"},
6364
expected: `{"@timestamp":"0001-01-01T00:00:00.000Z","@metadata":{"beat":"test","type":"_doc","version":"1.2.3"},"msg":"<hello>world</hello>"}`,
6465
},
65-
"UTC timezone offset": testCase{
66+
"UTC timezone offset": {
6667
config: Config{LocalTime: true},
6768
in: common.MapStr{"msg": "message"},
6869
expected: `{"@timestamp":"0001-01-01T00:00:00.000+00:00","@metadata":{"beat":"test","type":"_doc","version":"1.2.3"},"msg":"message"}`,
6970
},
70-
"PST timezone offset": testCase{
71+
"PST timezone offset": {
7172
config: Config{LocalTime: true},
7273
ts: time.Time{}.In(time.FixedZone("PST", -8*60*60)),
7374
in: common.MapStr{"msg": "message"},
7475
expected: `{"@timestamp":"0000-12-31T16:00:00.000-08:00","@metadata":{"beat":"test","type":"_doc","version":"1.2.3"},"msg":"message"}`,
7576
},
77+
"float undefined values": {
78+
in: common.MapStr{"nan": math.NaN()},
79+
expected: `{"@timestamp":"0001-01-01T00:00:00.000Z","@metadata":{"beat":"test","type":"_doc","version":"1.2.3"},"nan":null}`,
80+
},
7681
}
7782

7883
for name, test := range cases {

metricbeat/helper/prometheus/ptest/ptest.go

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030

3131
"github.com/stretchr/testify/assert"
3232

33-
"github.com/elastic/beats/v7/libbeat/common"
3433
"github.com/elastic/beats/v7/metricbeat/mb"
3534
mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing"
3635
"github.com/elastic/beats/v7/metricbeat/mb/testing/flags"
@@ -45,87 +44,6 @@ type TestCases []struct {
4544
ExpectedFile string
4645
}
4746

48-
// TestMetricSetEventsFetcher goes over the given TestCases and ensures that source Prometheus metrics gets converted
49-
// into the expected events when passed by the given metricset.
50-
// If -data flag is passed, the expected JSON file will be updated with the result
51-
func TestMetricSetEventsFetcher(t *testing.T, module, metricset string, cases TestCases) {
52-
for _, test := range cases {
53-
t.Logf("Testing %s file\n", test.MetricsFile)
54-
55-
file, err := os.Open(test.MetricsFile)
56-
assert.NoError(t, err, "cannot open test file "+test.MetricsFile)
57-
58-
body, err := ioutil.ReadAll(file)
59-
assert.NoError(t, err, "cannot read test file "+test.MetricsFile)
60-
61-
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
62-
w.WriteHeader(200)
63-
w.Header().Set("Content-Type", "text/plain; charset=ISO-8859-1")
64-
w.Write([]byte(body))
65-
}))
66-
67-
server.Start()
68-
defer server.Close()
69-
70-
config := map[string]interface{}{
71-
"module": module,
72-
"metricsets": []string{metricset},
73-
"hosts": []string{server.URL},
74-
}
75-
76-
f := mbtest.NewEventsFetcher(t, config)
77-
events, err := f.Fetch()
78-
assert.Nil(t, err, "Errors while fetching metrics")
79-
80-
if *flags.DataFlag {
81-
sort.SliceStable(events, func(i, j int) bool {
82-
h1, _ := hashstructure.Hash(events[i], nil)
83-
h2, _ := hashstructure.Hash(events[j], nil)
84-
return h1 < h2
85-
})
86-
eventsJSON, _ := json.MarshalIndent(events, "", "\t")
87-
err = ioutil.WriteFile(test.ExpectedFile, eventsJSON, 0644)
88-
assert.NoError(t, err)
89-
}
90-
91-
// Read expected events from reference file
92-
expected, err := ioutil.ReadFile(test.ExpectedFile)
93-
if err != nil {
94-
t.Fatal(err)
95-
}
96-
97-
var expectedEvents []common.MapStr
98-
err = json.Unmarshal(expected, &expectedEvents)
99-
if err != nil {
100-
t.Fatal(err)
101-
}
102-
103-
for _, event := range events {
104-
// ensure the event is in expected list
105-
found := -1
106-
for i, expectedEvent := range expectedEvents {
107-
if event.String() == expectedEvent.String() {
108-
found = i
109-
break
110-
}
111-
}
112-
if found > -1 {
113-
expectedEvents = append(expectedEvents[:found], expectedEvents[found+1:]...)
114-
} else {
115-
t.Errorf("Event was not expected: %+v", event)
116-
}
117-
}
118-
119-
if len(expectedEvents) > 0 {
120-
t.Error("Some events were missing:")
121-
for _, e := range expectedEvents {
122-
t.Error(e)
123-
}
124-
t.Fatal()
125-
}
126-
}
127-
}
128-
12947
// TestMetricSet goes over the given TestCases and ensures that source Prometheus metrics gets converted into the expected
13048
// events when passed by the given metricset.
13149
// If -data flag is passed, the expected JSON file will be updated with the result

metricbeat/mb/builders.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,6 @@ func mustHaveModule(ms MetricSet, base BaseMetricSet) error {
217217
// of them.
218218
func mustImplementFetcher(ms MetricSet) error {
219219
var ifcs []string
220-
if _, ok := ms.(EventFetcher); ok {
221-
ifcs = append(ifcs, "EventFetcher")
222-
}
223-
224-
if _, ok := ms.(EventsFetcher); ok {
225-
ifcs = append(ifcs, "EventsFetcher")
226-
}
227-
228220
if _, ok := ms.(ReportingMetricSet); ok {
229221
ifcs = append(ifcs, "ReportingMetricSet")
230222
}
@@ -256,7 +248,7 @@ func mustImplementFetcher(ms MetricSet) error {
256248
switch len(ifcs) {
257249
case 0:
258250
return fmt.Errorf("MetricSet '%s/%s' does not implement an event "+
259-
"producing interface (EventFetcher, EventsFetcher, "+
251+
"producing interface ("+
260252
"ReportingMetricSet, ReportingMetricSetV2, ReportingMetricSetV2Error, ReportingMetricSetV2WithContext"+
261253
"PushMetricSet, PushMetricSetV2, or PushMetricSetV2WithContext)",
262254
ms.Module().Name(), ms.Name())

metricbeat/mb/mb.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ func (m *BaseModule) WithConfig(config common.Config) (*BaseModule, error) {
133133
// MetricSet interfaces
134134

135135
// MetricSet is the common interface for all MetricSet implementations. In
136-
// addition to this interface, all MetricSets must implement either
137-
// EventFetcher or EventsFetcher (but not both).
136+
// addition to this interface, all MetricSets must implement a fetcher interface.
138137
type MetricSet interface {
139138
ID() string // Unique ID identifying a running MetricSet.
140139
Name() string // Name returns the name of the MetricSet.
@@ -154,20 +153,6 @@ type Closer interface {
154153
Close() error
155154
}
156155

157-
// EventFetcher is a MetricSet that returns a single event when collecting data.
158-
// Use ReportingMetricSet for new MetricSet implementations.
159-
type EventFetcher interface {
160-
MetricSet
161-
Fetch() (common.MapStr, error)
162-
}
163-
164-
// EventsFetcher is a MetricSet that returns a multiple events when collecting
165-
// data. Use ReportingMetricSet for new MetricSet implementations.
166-
type EventsFetcher interface {
167-
MetricSet
168-
Fetch() ([]common.MapStr, error)
169-
}
170-
171156
// Reporter is used by a MetricSet to report events, errors, or errors with
172157
// metadata. The methods return false if and only if publishing failed because
173158
// the MetricSet is being closed.

0 commit comments

Comments
 (0)