@@ -15,7 +15,7 @@ class Rule:
15
15
ignore_case : bool
16
16
17
17
def __init__ (self , rules : Dict [str , Any ]):
18
- self .select_keys = rules .get ("select_keys" , None )
18
+ self .select_keys = rules .get ("select_keys" , [ "app" , "title" ] )
19
19
self .ignore_case = rules .get ("ignore_case" , False )
20
20
21
21
# NOTE: Also checks that the regex isn't an empty string (which would erroneously match everything)
@@ -29,10 +29,15 @@ def __init__(self, rules: Dict[str, Any]):
29
29
)
30
30
31
31
def match (self , e : Event ) -> bool :
32
- if self .select_keys :
33
- values = [e .data .get (key , None ) for key in self .select_keys ]
34
- else :
32
+ # `data` contains keys like 'app', 'title'
33
+ # by default, the rule regex is matched against all values
34
+
35
+ if self .select_keys == 'all'
35
36
values = list (e .data .values ())
37
+ elif self .select_keys :
38
+ values = [e .data .get (key , None ) for key in self .select_keys ]
39
+
40
+ # although there is a `type` field on the rule name, right now the only valid type is regex
36
41
if self .regex :
37
42
for val in values :
38
43
if isinstance (val , str ) and self .regex .search (val ):
@@ -45,6 +50,7 @@ def categorize(events: List[Event], classes: List[Tuple[Category, Rule]]):
45
50
46
51
47
52
def _categorize_one (e : Event , classes : List [Tuple [Category , Rule ]]) -> Event :
53
+ # TODO can we add a color here too? why is color rendered on the frontend?
48
54
e .data ["$category" ] = _pick_category (
49
55
[_cls for _cls , rule in classes if rule .match (e )]
50
56
)
0 commit comments