[英]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.