简体   繁体   English

Logstash中的两个输出。 仅用于某些聚合

[英]Two outputs in logstash. One for certain aggregations only

I'm trying to specify a second output of logstash in order to save certain aggregated data only. 我正在尝试指定logstash的第二个输出,以便仅保存某些聚合数据。 No clue how to achieve it at the moment. 目前尚不知道如何实现。 Documentation doesn't cover such a case. 文档没有涵盖这种情况。

At the moment I use a single input and a single output. 目前,我使用一个输入和一个输出。

Input definition ( logstash-udp.conf ): 输入定义( logstash-udp.conf ):

input { 
    udp { 
        port => 25000
        codec => json
        buffer_size => 5000
        workers => 2
    }
}

filter {
  grok {
    match => [ "message", "API call happened" ]
  }

  aggregate {
    task_id => "%{example_task}"
    code => "
        map['api_calls'] ||= 0
        map['api_calls'] += 1
        map['message'] ||= event.get('message')
        event.cancel()
    "
    timeout => 60
    push_previous_map_as_event => true
    timeout_code => "event.set('aggregated_calls', event.get('api_calls') > 0)"
    timeout_tags => ['_aggregation']
  }
}

Output definition ( logstash-output.conf ): 输出定义( logstash-output.conf ):

output {
  elasticsearch {
    hosts => ["localhost"]
    manage_template => false
    index => "%{[@metadata][udp]}-%{+YYYY.MM.dd}"
    document_type => "%{[@metadata][type]}"
  }
}

What I want to achieve now? 我现在想实现什么? I need to add a second, different aggregation (different data and conditions) which will save all the not aggregated data to Elasticsearch like now however aggregated data for this aggregation would be saved to Postgres. 我需要添加第二个不同的聚合(不同的数据和条件),它将像现在一样将所有未聚合的数据保存到Elasticsearch,但是此聚合的聚合数据将保存到Postgres。 I'm pretty much stuck at the moment and searching the web for some docs/examples doesn't help. 我目前陷入困境,在网络上搜索一些文档/示例无济于事。

I'd suggest using multiple pipelines: https://www.elastic.co/guide/en/logstash/current/multiple-pipelines.html 我建议使用多个管道: https : //www.elastic.co/guide/en/logstash/current/multiple-pipelines.html

This way you can have one pipeline for aggregation and second one for pure data. 这样,您可以有一个管道用于聚合,第二个管道用于纯数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何组合两个查询还是只有一个? - How do combine two Queries or is it only one? 将 Flyway 用于两个数据库,但一次只能使用一个 - Using Flyway for two databases, but only one at a time logstash :使用一个 logstash conf 文件创建多个索引 - logstash : creating multiple indices using one logstash conf file PostgresQL:值只允许在两列之一中 - PostgresQL: Value is only allowed in one of two columns 寻找两个数据输出之间的差距 - Finding gap between two data outputs PostgreSQL检查约束,仅允许两个布尔值之一为真 - PostgreSQL Check Constraint to Only Allow One of Two Booleans to be True LOGSTASH:如何设置 logstash 以获取所有查询的数据,而不仅仅是其中的一部分? - LOGSTASH: How to setup logstash to get all query's data not only a part of it? 在一个postgres查询中,确定任何单个用户是否在一定的时间内发生了两个事件 - In one postgres query, determine whether two events happened with a certain amount of time for any individual user 有两个操作按钮,但是只有第一个操作按钮(写在服务器文件中)有效吗? - Two action buttons, but only the first one, that is written in the server file, works? 为什么在PGAdmin中,两条语句只显示一个结果 - why in PGAdmin, two statement only show one result
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM