Hey guys,
I am having a bit of an issue attempting to apply some logic to mimic a previous mysql functionality.
The idea is that after parsing i create a unique id, Doc_id of 3 fields concatenated. Then i query elasticsearch to see if that field already exists and to pull the value. in the output i have an if statement that should compare "previousValue", from elastic, and EndpointValue, from the document, and if they are NOT the same, to go into elasticsearch output. This should cover if it doesnt exist as it will not be the same. If it is the same, it should do nothing.
Then on the elastic output i have chosen to do upsert, which from my reading should update existing or create a new record. The following is working some what, it inserts records, but not in the way that i was hoping.
I'd like to have the record updated, if existing and value is different, such that @timestamp gets updated and @version is incremented. However, what i see appears to be a new document everytime with latest @timestamp, but @version is always set to 1.
Perhaps i am overcomplicating this or missing something?
I have logs that look like:
Test-USPS|uspsUri|global|http://test.usps.com
Pattern:
NOTPIPE [^|]+
My config is:
input{
beats{
port => 5044
}
}
filter{
grok{
patterns_dir => "/opt/logstash/patterns"
match => [
"message", "%{WORD:Environment}-%{NOTPIPE:ApplicationName}|%{NOTPIPE:EndpointName}|%{NOTPIPE:ignore}|%{NOTPIPE:EndpointValue}"
]
}
mutate{
add_field => { "Doc_id" => "%{Environment}%{ApplicationName}%{EndpointName}" }
remove_field => [ "ignore" ]
}
elasticsearch{
hosts => ["localhost"]
query => "Doc_id=%{Doc_id}"
fields => { "EndpointValue" => "previousValue" }
}
}
output{
if "%{previousValue}" != [EndpointValue]{
elasticsearch {
hosts => ["localhost"]
index => "esb-endpoints"
action => "update"
doc_as_upsert => "true"
document_id => "%{Doc_id}"
}
}