用于逗号分隔的键值对的Graylog提取器

我想我只是不理解或错过了一个graylog及其提取器的核心概念。 我只是想把我的键值对用逗号分隔,并将它们分解到各自的字段中。

示例日志消息

2016-01-22 18:04:05,639 – host_info_log – INFO – 'cpu_count = 2,user_cpu = 0.0,system_cpu = 0.0,idle_cpu = 100.0,total_memory = 3955.07,avail_memory = 3717.3,percent_memory = 6.0,used_memory = 523.44,free_memory = 3431.63,active_memory = 378.54,inactive_memory = 67.38,swap_memory_used = 0.0,swap_memory_total = 0.0,swap_memory_free = 0.0,swap_memory_percent = 0.0

注意:键并不总是在完全相同的位置,大多数时候cpu_count是第一个,但并不总是。

密钥(ha!)是为Key = Value对的字段添加一个转换器。

同时使用CSV和Key = Value转换器不会做你想要的,但是不知道另一个分隔符。 键=值假定为空白。 因此,一个解决scheme是使用replace正则expression式提取器将逗号放入空格,并在末尾添加Key = Value(记得点击Addbutton)。

为了性能原因添加string条件并避免不正确的提取。

最终结果如下所示:

{ "extractors": [ { "condition_type": "string", "condition_value": "host_info_log", "converters": [ { "type": "numeric", "config": {} }, { "type": "tokenizer", "config": {} } ], "cursor_strategy": "copy", "extractor_config": { "regex": ",", "replacement": " ", "replace_all": true }, "extractor_type": "regex_replace", "order": 0, "source_field": "message", "target_field": "host_info_log", "title": "serverfault http://serverfault.com/q/751126/241174" } ], "version": "1.3.3 (0fda9dc)" }