Skip to content

Commit 9779a43

Browse files
committed
Add system test for global filtering in Metricbeat
1 parent d7deab6 commit 9779a43

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import re
2+
import sys
3+
import metricbeat
4+
import unittest
5+
6+
@unittest.skipUnless(re.match("(?i)win|linux|darwin|openbsd", sys.platform), "os")
7+
class GlobalFiltering(metricbeat.BaseTest):
8+
9+
def test_drop_fields(self):
10+
11+
self.render_config_template(
12+
modules=[{
13+
"name": "system",
14+
"metricsets": ["cpu"],
15+
"period": "5s"
16+
}],
17+
drop_fields={
18+
"condition": "range.system.cpu.system_p.lt: 0.1",
19+
"fields": ["system.cpu.load"],
20+
},
21+
)
22+
proc = self.start_beat()
23+
self.wait_until(lambda: self.output_lines() > 0)
24+
proc.check_kill_and_wait()
25+
26+
output = self.read_output_json()
27+
self.assertEqual(len(output), 1)
28+
evt = output[0]
29+
self.assert_fields_are_documented(evt)
30+
31+
print(evt)
32+
print(evt.keys())
33+
self.assertItemsEqual([
34+
'beat', '@timestamp', 'system', 'module',
35+
'rtt', 'type', 'metricset'
36+
], evt.keys())
37+
cpu = evt["system"]["cpu"]
38+
print(cpu.keys())
39+
self.assertItemsEqual([
40+
"system_p", "user_p", "softirq", "iowait", "system",
41+
"idle", "user", "irq", "steal", "nice"
42+
], cpu.keys())

0 commit comments

Comments
 (0)