Document_id is value

Hi all, when I run the logstash config, why is my document id its value? Any one can help me?

This is my configuration logstash

input {
    http_poller {
        urls => {
            users => {
                method => GET
                user => "user@gmail.com"
                password => "password"
                url => "https://api.id/api/report/product"
                headers => {
                    "Content-Type" => "application/json"
                    Authorization => "Bearer token"
                }
            }
        }
        request_timeout => 60
        schedule => { every => "20s"}
        codec => "json" 
        type => "Http_poller"  
    }
}

filter {
    split {
        field => "[result][data][products]"
        add_field => {"id" => "[result][data][products][id]"}
    }
    }
}

output {
    elasticsearch {
        hosts => ["localhost:9200"]
        index => "contoh96"
        document_id => "%{id}"
    }
    stdout {
        codec => rubydebug 
    }
}

Did you mean that to be a sprintf reference to the value of the field?

add_field => {"id" => "%{[result][data][products][id]}"}

Note that you could use that sprintf reference in the document_id option, you do not have to use an intermediate field.

Thanks Badger, your solution worked

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.