5

处理数据后:输入| 过滤器 | output > 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 亿条日志,我想在排除此默认字段的情况下运行一些性能测试(我只是不使用这些字段)。

4

3 回答 3

7

这会从输出中删除字段:

filter {
    mutate {
        # remove duplicate fields
        # this leaves timestamp from message and source_path for source
        remove => ["@timestamp", "@source"]
    }
 }
于 2013-03-25T21:41:13.070 回答
0

其中一些将取决于您用于查看日志的 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 中,并且源字段不存在。

于 2013-03-13T22:30:15.030 回答
0

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

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

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

bin/logstash-plugin install logstash-filter-prune
于 2018-07-01T10:18:28.453 回答