Closed Marusyk closed 1 year ago
Currently, the result is a list. This code:
Grok grok = new Grok("%{MONTHDAY:month}-%{MONTHDAY:day}-%{MONTHDAY:year} %{TIME:timestamp};%{WORD:id};%{LOGLEVEL:loglevel};%{WORD:func};%{GREEDYDATA:msg}"); string logs = @"06-21-19 21:00:13:589241;15;INFO;main;DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165 06-22-19 22:00:13:589265;156;WARN;main;DECODED: 775233900043 EMPTY DISTANCE: --------"; var grokResult = grok.Parse(logs); foreach (var item in grokResult) { Console.WriteLine($"{item.Key} : {item.Value}"); }
will print :
month : 06 day : 21 year : 19 timestamp : 21:00:13:589241 id : 15 loglevel : INFO func : main msg : DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165 month : 06 day : 22 year : 19 timestamp : 22:00:13:589265 id : 156 loglevel : WARN func : main msg : DECODED: 775233900043 EMPTY DISTANCE: --------
It could be really useful to group the keys, e.g grokResult.AsDictionary(); to get:
grokResult.AsDictionary();
month: 06 06 day: 21 21 year: 19 19 timestamp: 21:00:13:589241 21:00:13:589265 id: 15 156 loglevel: INFO WARN func: main main msg: DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165 DECODED: 775233900043 EMPTY DISTANCE: --------
Can i take this one?
@GioMaz Sure, it's yours 😉 Thanks for the interest
Currently, the result is a list. This code:
will print :
It could be really useful to group the keys, e.g
grokResult.AsDictionary();
to get: