elasticsearch - 创建索引时出现Logstash问题,删除kibana中的.raw字段

标签 elasticsearch logstash kibana

我写了一个logstash conf文件来读取日志。如果使用默认索引,即logstash- *,则可以在kibana中看到.raw字段。但是,如果我在logstash中的conf文件中创建新索引,例如

output{
    elasticsearch {
      hosts => "localhost"
      index => "batchjob-*"} 
}

然后,新索引无法配置.raw字段。有解决问题的解决方法吗?十分感谢。

最佳答案

原始字段由Logstash elasticsearch输出在Elasticsearch中创建的specific index template创建。

您只需将模板复制到名为batchjob.json的文件中,然后将模板名称更改为batchjob-*(请参见下文)

{
  "template" : "batchjob-*",
  "settings" : {
    "index.refresh_interval" : "5s"
  },
  "mappings" : {
    "_default_" : {
      "_all" : {"enabled" : true, "omit_norms" : true},
      "dynamic_templates" : [ {
        "message_field" : {
          "match" : "message",
          "match_mapping_type" : "string",
          "mapping" : {
            "type" : "string", "index" : "analyzed", "omit_norms" : true,
            "fielddata" : { "format" : "disabled" }
          }
        }
      }, {
        "string_fields" : {
          "match" : "*",
          "match_mapping_type" : "string",
          "mapping" : {
            "type" : "string", "index" : "analyzed", "omit_norms" : true,
            "fielddata" : { "format" : "disabled" },
            "fields" : {
              "raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
            }
          }
        }
      } ],
      "properties" : {
        "@timestamp": { "type": "date" },
        "@version": { "type": "string", "index": "not_analyzed" },
        "geoip"  : {
          "dynamic": true,
          "properties" : {
            "ip": { "type": "ip" },
            "location" : { "type" : "geo_point" },
            "latitude" : { "type" : "float" },
            "longitude" : { "type" : "float" }
          }
        }
      }
    }
  }
}

然后,您可以像这样修改elasticsearch输出:
output {
    elasticsearch {
      hosts => "localhost"
      index => "batchjob-*"
      template_name => "batchjob"
      template => "/path/to/batchjob.json"
    } 
}

关于elasticsearch - 创建索引时出现Logstash问题,删除kibana中的.raw字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37653522/

相关文章:

elasticsearch - 从 Kibana 仪表板发送电子邮件报告的最佳方式是什么?

elasticsearch - 如何(持久)更新 Elasticsearch 中的 index.number_of_replicas 设置而不重新启动集群?

elasticsearch - Elasticsearch 中的查询字符串与通配符之间有什么区别

java - elasticsearch 启动失败报错

ruby - 如何在ruby gem SearchKick中将字段添加到ElasticSearch以便按顺序排序

elasticsearch - ES查询忽略时间范围过滤器

elasticsearch - 使用Logstash自动解析日志字段

elasticsearch - Elasticsearch forcemerge 和磁盘空间问题

elasticsearch - Logstash-如何在一条消息中使用多个Geoip过滤器

java - 无法为从logstash JDBC 输入插件创建的索引创建elasticsearch 的映射