I'm quite unclear of how to use :sql_last_value
in my mongodb query statement like:
statement => "var lastId = ':sql_last_value'; db.docs.find({ _id: { $gte : lastId }})"
my config is like this
input {
jdbc {
jdbc_driver_library => "C:\Users\scott\Downloads\logstash-7.8.1\mongojdbc2.2.jar"
jdbc_driver_class => "com.dbschema.MongoJdbcDriver"
jdbc_connection_string => "jdbc:mongodb://localhost:27017/edb"
jdbc_user => "admin"
schedule => "* * * * *"
tracking_column => "_id"
use_column_value => true
statement => "var lastId = ':sql_last_value'; db.docs.find({ _id: { $gte : lastId }})"
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "edb"
}
}
when I try to use this it gives an error:
tracking_column not found in dataset. {:tracking_column=>"_id"}
here is a sample mongodb doc
{
"_id": "56ea4034559c3908e0199453",
"56e9e2dca39c3453459173_initials": "",
"56e9e2dc345358e0199173_date_range": "",
"_my_metadata": {
"ClientId": "333",
"Type": "Test File",
"FileName": "test asd as.pdf",
"UploadDate": "2018-03-17T04:29:19.700Z",
"AccessGroups": "[19453,345345]",
"StateId": "0",
"State": "null",
"TypeId": "56ea423345345d8c3908e019944e",
"Links": "[]",
"Id": "56ea43453455508e0199453",
"LastActionDate": "null",
"WorkflowVersion": "0"
}
}
I am wanting to store the document's '_id' field as the :sql_last_value and then use that value in the statement above.
Currently, from the log, it is using a 0 for the last value
var lastId = '0'; db.edb2.find({ _id: { $gte : lastId }})
How do I store a mongodb field in :sql_last_value? All the examples I can find use a SQL query, which mongodb doesnt use.
I have tried these with no success:
tracking_column => "_id"
tracking_column => "id"
tracking_column => "document._id"
Thanks for any help.