这是示例logstash输出过滤器。

output
{
    elasticsearch
    {
            hosts => ["localhost"]
            sniffing => true
            manage_template => false
            index => "mqtt-index-%{+YYYY.MM.dd}"
            document_id => "%{parsedMessage.device_id}"
            document_type => "iot_data"
    }
}

此代码将现有的_id更改为%{parsedMessage.device_id}。如何通过另一个字段更改_id?

最佳答案

从过滤器中删除了目标选项。
filter{ json { source => "message" }}
并使用以下输出来创建自定义文档ID。

output
{
    elasticsearch
    {
            hosts => ["localhost:9200"]
            sniffing => true
            manage_template => false
            index => "mqtt-index-%{+YYYY.MM.dd}"
            document_id => "%{device_id}"
            document_type => "iot_data"
    }
}

10-04 22:34
查看更多