graylog2-server icon indicating copy to clipboard operation
graylog2-server copied to clipboard

graylog2 extractur cut filed function is not cutting

Open meyju opened this issue 12 years ago • 1 comments

Hi,

I try to parse an "key:value" part from a (syslog) message as a new field with the expected value.

I choosed "cut" but "key:value" still stays in the message filed.

{
  "extractors": [
    {
      "condition_type": "regex",
      "condition_value": "^mykeyword:(.+?)\\s",
      "converters": [],
      "cursor_strategy": "cut",
      "extractor_config": {
        "index": 1,
        "split_by": " "
      },
      "extractor_type": "split_and_index",
      "order": 0,
      "source_field": "message",
      "target_field": "mykeyword",
      "title": "mykeyword"
    }
  ],
  "version": "0.90.0"
}

Example Origin Message:

Oct  8 13:20:01 ip-10-5-62-86 APPNAME[17512]: mykeyword:hello some other text

With the above extractor I get

Getting message field:

Oct  8 13:20:01 ip-10-5-62-86 APPNAME[17512]: mykeyword:hello some other text

Getting mykeyword field:

hello

But I expecte to get the following: Expected message field:

Oct  8 13:20:01 ip-10-5-62-86 APPNAME[17512]:  some other text

Expected mykeyword field:

hello

meyju avatar Oct 08 '14 12:10 meyju

I think you should use a regex extractor here instead of a split & index. Cutting data from the standard message field is not allowed, so using the copy curstor strategy here is fine.

Example:

{
  "extractors": [
    {
      "condition_type": "string",
      "condition_value": "mykeyword:",
      "converters": [],
      "cursor_strategy": "copy",
      "extractor_config": {
        "regex_value": "mykeyword:(.+?)\\s"
      },
      "extractor_type": "regex",
      "order": 0,
      "source_field": "message",
      "target_field": "mykeyword",
      "title": "issue-735"
    }
  ],
  "version": "1.1.0-beta.3-SNAPSHOT (b7914c3)"
}

This results in the following:

v9 cy8ytx6waaaaasuvork5cyii

I hope that helps. Please re-open if you still have that issue. Thanks!

bernd avatar May 23 '15 10:05 bernd