【问题标题】:Leave out default Logstash fields in ElasticSearch在 ElasticSearch 中省略默认的 Logstash 字段
【发布时间】:2013-02-22 10:25:50
【问题描述】:

处理数据后:输入|过滤器 |输出 > ElasticSearch 存储它的格式有点像:

"_index": "logstash-2012.07.02",
"_type": "stdin",
"_id": "JdRaI5R6RT2do_WhCYM-qg",
"_score": 0.30685282,
"_source": {
    "@source": "stdin://dist/",
    "@type": "stdin",
    "@tags": [
        "tag1",
        "tag2"
    ],
    "@fields": {},
    "@timestamp": "2012-07-02T06:17:48.533000Z",
    "@source_host": "dist",
    "@source_path": "/",
    "@message": "test"
}

我在特定字段中过滤/存储大部分重要信息,是否可以省略默认字段,例如:@source_path 和 @source_host?在不久的将来,它将每月存储 80 亿条日志,我想在排除此默认字段的情况下运行一些性能测试(我只是不使用这些字段)。

【问题讨论】:

    标签: elasticsearch field logstash


    【解决方案1】:

    其中一些取决于您用于查看日志的 Web 界面。我正在使用 Kibana,以及一个索引以下内容的客户记录器 (c#):

    {
      "_index": "logstash-2013.03.13",
      "_type": "logs",
      "_id": "n3GzIC68R1mcdj6Wte6jWw",
      "_version": 1,
      "_score": 1,
      "_source": 
      {
        "@source": "File",
        "@message": "Shalom",
        "@fields": 
        {
          "tempor": "hit"
        },
        "@tags": 
        [
          "tag1"
        ],
        "level": "Info"
        "@timestamp": "2013-03-13T21:47:51.9838974Z"
      }
    }
    

    这显示在 Kibana 中,而源字段不存在。

    【讨论】:

    • 我真的不认为它依赖于网络界面。我将数据从 Logstash 直接存储到 ElasticSearch 中,当通过 ES 的 REST API 检索此数据时,它已经具有这些字段。
    【解决方案2】:

    这会从输出中删除字段:

    filter {
        mutate {
            # remove duplicate fields
            # this leaves timestamp from message and source_path for source
            remove => ["@timestamp", "@source"]
        }
     }
    

    【讨论】:

      【解决方案3】:

      要排除某些字段,您可以使用prune filter plugin

      filter {
          prune {
              blacklist_names => [ "@timestamp", "@source" ]
          }
      }
      

      修剪过滤器不是logstash默认插件,必须先安装:

      bin/logstash-plugin install logstash-filter-prune
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-11-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-20
        • 1970-01-01
        相关资源
        最近更新 更多