Kibana:搜索特定短语,返回没有结果,而另一个搜索返回短语

时间:2015-11-28 22:09:11

标签: logstash kibana kibana-4

看起来像一个简单的用例但由于某些原因我无法弄清楚如何做到这一点,或谷歌一个明确的例子。

假设我在logstash中存储了一条消息 消息:

  

“info:2015-11-28 22:02:19,232:common:INFO:ENV:Production   用户:无:用户名:无:日志:发布到总线“

我想在kibana(第4版)中搜索“发布到公交车”这句话 我会得到一组结果 但如果我要搜索:“无:日志:发布到公交车” 然后我得到“没有找到结果”。

虽然显然这个短语确实存在并且由之前的搜索返回。

所以我的问题基本上是 - 发生了什么?搜索可能的长短语的正确方法是什么?为什么第二个示例失败。

修改 存储的JSON。

{
  "_index": "logz-ngdxrkmolklnvngumaitximbohqwbocg-151206_v1",
  "_type": "django_logger",
  "_id": "AVF2DPxZZst_8_8_m-se",
  "_score": null,
  "_source": {
    "log": " publishing to bus {'user_id': 8866, 'event_id': 'aibRBPcLxcAzsEVRtFZVU5', 'timestamp': 1449384441, 'quotes': {}, 'rates': {u'EURUSD': Decimal('1.061025'), u'GBPUSD': Decimal('1.494125'), u'EURGBP': Decimal('0.710150')}, 'event': 'AccountInstrumentsUpdated', 'minute': 1449384420}",
    "logger": "common",
    "log_level": "INFO",
    "message": "2015-12-06 06:47:21,298:common:INFO:ENV: Production User:None:Username:None:LOG: publishing to bus {'user_id': 8866, 'event_id': 'aibRBPcLxcAzsEVRtFZVU5', 'timestamp': 1449384441, 'quotes': {}, 'rates': {u'EURUSD': Decimal('1.061025'), u'GBPUSD': Decimal('1.494125'), u'EURGBP': Decimal('0.710150')}, 'event': 'AccountInstrumentsUpdated', 'minute': 1449384420}",
    "type": "django_logger",
    "tags": [
      "celery"
    ],
    "path": "//path/to/logs/out.log",
    "environment": "Staging",
    "@timestamp": "2015-12-06T06:47:21.298+00:00",
    "user_id": "None",
    "host": "path.to.host",
    "timestamp": "2015-12-06 06:47:21,298",
    "username": "None"
  },
  "fields": {
    "@timestamp": [
      1449384441298
    ]
  },
  "highlight": {
    "message": [
      "2015-12-06 06:47:21,298:common:INFO:ENV: Staging User:None:Username:None:LOG: @kibana-highlighted-field@publishing@/kibana-highlighted-field@ @kibana-highlighted-field@to@/kibana-highlighted-field@ @kibana-highlighted-field@bus@/kibana-highlighted-field@ {'user_id': **, 'event_id': 'aibRBPcLxcAzsEVRtFZVU5', 'timestamp': 1449384441, 'quotes': {}, 'rates': {u'EURUSD': Decimal('1.061025'), u'GBPUSD': Decimal('1.494125'), u'EURGBP': Decimal('0.710150')}, 'event': 'AccountInstrumentsUpdated', 'minute': 1449384420}"
    ]
  },
  "sort": [
    1449384441298
  ]
}

2 个答案:

答案 0 :(得分:1)

根据Elasticsearch,它使用标准分析器作为默认值。标准分析器将消息字段标记为如下:

  

" 2015-12-06 06:47:21,298:common:INFO:ENV:Production   用户:无:用户名:无:日志:发布到公共汽车{' user_id':8866,   ' event_id':' aibRBPcLxcAzsEVRtFZVU5',' timestamp':1449384441,   '报价':{},'率':{u' EURUSD':十进制(' 1.061025'),u' GBPUSD&# 39 ;:   十进制(' 1.494125'),u' EURGBP':十进制(' 0.710150')},'事件':   ' AccountInstrumentsUpdated','分钟':1449384420}"

{
  "tokens": [
    {
      "token": "2015",
      "start_offset": 0,
      "end_offset": 4,
      "type": "<NUM>",
      "position": 0
    },
    {
      "token": "12",
      "start_offset": 5,
      "end_offset": 7,
      "type": "<NUM>",
      "position": 1
    },
    {
      "token": "06",
      "start_offset": 8,
      "end_offset": 10,
      "type": "<NUM>",
      "position": 2
    },
    {
      "token": "06",
      "start_offset": 11,
      "end_offset": 13,
      "type": "<NUM>",
      "position": 3
    },
    {
      "token": "47",
      "start_offset": 14,
      "end_offset": 16,
      "type": "<NUM>",
      "position": 4
    },
    {
      "token": "21,298",
      "start_offset": 17,
      "end_offset": 23,
      "type": "<NUM>",
      "position": 5
    },
    {
      "token": "common:info:env",
      "start_offset": 24,
      "end_offset": 39,
      "type": "<ALPHANUM>",
      "position": 6
    },
    {
      "token": "production",
      "start_offset": 41,
      "end_offset": 51,
      "type": "<ALPHANUM>",
      "position": 7
    },
    {
      "token": "user:none:username:none:log",
      "start_offset": 52,
      "end_offset": 79,
      "type": "<ALPHANUM>",
      "position": 8
    },
    {
      "token": "publishing",
      "start_offset": 81,
      "end_offset": 91,
      "type": "<ALPHANUM>",
      "position": 9
    },
    {
      "token": "to",
      "start_offset": 92,
      "end_offset": 94,
      "type": "<ALPHANUM>",
      "position": 10
    },
    {
      "token": "bus",
      "start_offset": 95,
      "end_offset": 98,
      "type": "<ALPHANUM>",
      "position": 11
    },
    {
      "token": "user_id",
      "start_offset": 100,
      "end_offset": 107,
      "type": "<ALPHANUM>",
      "position": 12
    },
    {
      "token": "8866",
      "start_offset": 109,
      "end_offset": 113,
      "type": "<NUM>",
      "position": 13
    },
    {
      "token": "event_id",
      "start_offset": 115,
      "end_offset": 123,
      "type": "<ALPHANUM>",
      "position": 14
    },
    {
      "token": "aibrbpclxcazsevrtfzvu5",
      "start_offset": 125,
      "end_offset": 147,
      "type": "<ALPHANUM>",
      "position": 15
    },
    {
      "token": "timestamp",
      "start_offset": 149,
      "end_offset": 158,
      "type": "<ALPHANUM>",
      "position": 16
    },
    {
      "token": "1449384441",
      "start_offset": 160,
      "end_offset": 170,
      "type": "<NUM>",
      "position": 17
    },
    {
      "token": "quotes",
      "start_offset": 172,
      "end_offset": 178,
      "type": "<ALPHANUM>",
      "position": 18
    },
    {
      "token": "rates",
      "start_offset": 184,
      "end_offset": 189,
      "type": "<ALPHANUM>",
      "position": 19
    },
    {
      "token": "ueurusd",
      "start_offset": 192,
      "end_offset": 199,
      "type": "<ALPHANUM>",
      "position": 20
    },
    {
      "token": "decimal",
      "start_offset": 201,
      "end_offset": 208,
      "type": "<ALPHANUM>",
      "position": 21
    },
    {
      "token": "1.061025",
      "start_offset": 209,
      "end_offset": 217,
      "type": "<NUM>",
      "position": 22
    },
    {
      "token": "ugbpusd",
      "start_offset": 220,
      "end_offset": 227,
      "type": "<ALPHANUM>",
      "position": 23
    },
    {
      "token": "decimal",
      "start_offset": 229,
      "end_offset": 236,
      "type": "<ALPHANUM>",
      "position": 24
    },
    {
      "token": "1.494125",
      "start_offset": 237,
      "end_offset": 245,
      "type": "<NUM>",
      "position": 25
    },
    {
      "token": "ueurgbp",
      "start_offset": 248,
      "end_offset": 255,
      "type": "<ALPHANUM>",
      "position": 26
    },
    {
      "token": "decimal",
      "start_offset": 257,
      "end_offset": 264,
      "type": "<ALPHANUM>",
      "position": 27
    },
    {
      "token": "0.710150",
      "start_offset": 265,
      "end_offset": 273,
      "type": "<NUM>",
      "position": 28
    },
    {
      "token": "event",
      "start_offset": 277,
      "end_offset": 282,
      "type": "<ALPHANUM>",
      "position": 29
    },
    {
      "token": "accountinstrumentsupdated",
      "start_offset": 284,
      "end_offset": 309,
      "type": "<ALPHANUM>",
      "position": 30
    },
    {
      "token": "minute",
      "start_offset": 311,
      "end_offset": 317,
      "type": "<ALPHANUM>",
      "position": 31
    },
    {
      "token": "1449384420",
      "start_offset": 319,
      "end_offset": 329,
      "type": "<NUM>",
      "position": 32
    }
  ]
}

短语&#34;制作用户:无:用户名:无:日志:发布到公共汽车&#34;

 {
      "token": "production",
      "start_offset": 41,
      "end_offset": 51,
      "type": "<ALPHANUM>",
      "position": 7
    },
    {
      "token": "user:none:username:none:log",
      "start_offset": 52,
      "end_offset": 79,
      "type": "<ALPHANUM>",
      "position": 8
    },
    {
      "token": "publishing",
      "start_offset": 81,
      "end_offset": 91,
      "type": "<ALPHANUM>",
      "position": 9
    },
    {
      "token": "to",
      "start_offset": 92,
      "end_offset": 94,
      "type": "<ALPHANUM>",
      "position": 10
    },
    {
      "token": "bus",
      "start_offset": 95,
      "end_offset": 98,
      "type": "<ALPHANUM>",
      "position": 11
    }

所以如果你搜索&#34;发布到公共汽车&#34; elasticsearch匹配上述三个令牌并返回文档。

如果你搜索&#34;无:日志:发布到公共汽车&#34; &#34;无:LOG:&#34;没有完全匹配,所以它不会返回文档。

您可以尝试&#34;用户:无:用户名:无:日志:发布到总线&#34;得到结果。

答案 1 :(得分:0)

在Kibana中存在一些具有特殊性质的问题:|和 - 。当kibana发现他们在不同部分保存的那种角色,而不是在同一个领域。因为很容易找到发布到总线或无或日志。解决方案是你必须向kibana表明该领域不会被分析。