【问题标题】:Logstash elastic search output custom template not workingLogstash 弹性搜索输出自定义模板不起作用
【发布时间】:2016-08-04 16:30:13
【问题描述】:

我的 logstash 配置类似于以下内容

if "user" in [tags] {
        elasticsearch {
            hosts => ["localhost:9200"]
            action => "index"
            index => "user-%{+YYYY.MM.dd}"
            template => '/path/to/elastic-template.json'
            flush_size => 50
        }
}    

而 json 模板包含行

 "fields" : {
                 "{name}" : {"type": "string", "index" : "analyzed", "omit_norms" : true, "index_options" : "docs"},
                 "{name}.raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
               }

所以我假设在搜索或生成可视化时可以使用 .raw

但是,我删除了现有的索引并再次重建,我可以看到数据,但我仍然找不到 Kibana 的设置、发现或可视化的 .raw 字段

如何使用.raw字段?

【问题讨论】:

  • 为什么不使用 Logstash 默认模板?那个确实添加了raw 字段。分享完整的模板。

标签: elasticsearch logstash kibana kibana-4 logstash-configuration


【解决方案1】:

您发布的模板甚至不是有效的 JSON。如果您想像not_analyzed 一样应用raw 字段,您必须这样做:

"action" : {
  "type" : "string",
    "fields" : {
      "raw" : {
        "index" : "not_analyzed",
        "type" : "string"
    }
  }
}

这将创建一个action.raw 字段。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。 我用了ES5.5.1logstash 5.5.1,下面是我的模板文件

    {
      "template": "access_log",
      "settings": {
        "index.refresh_interval" : "5s"
      },
      "mappings": {
        "log": {
          "properties":{
            "geoip":{
              "properties":{
                 "location" : {
                   "type" : "geo_point",
                   "index": "false"
                 }
              }
            }
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多