Logstash - set @timestamp in .conf files

Hi, I need to update existing logstash .conf files to generate indexes with tiemstamp*

*Reason: ensure new indexes are regularly generated when rollup of index when ILM policy rules are reach which then allow me to cleanup disk space by deleting old indexes...

Example: Here is my conf file: with CurrentDate a string of type nvarchar(100) generated by the sql query.

nput {
jdbc {
jdbc_driver_library => ""
jdbc_driver_class => "Java::com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://server-name;databaseName=master"
jdbc_user => "els_reader"
jdbc_password => "pw"
statement_filepath => "/etc/logstash/sql_queries/request_stats_light.sql"
schedule => "*/15 * * * *"
}
}

filter {
ruby {
code => event.set("@timestamp", event.get("CurrentDate"))
}
}

output {
elasticsearch {
hosts => ["es-server-name:9200"]
index => "sql_query_stats-%{+yyyy.MM.dd}"
document_id => "%{uid}"
action => "update"
doc_as_upsert => true
}
}

-> after having restarted logstash, I expected to see an sql-query-stats- index appear. But nothing happens, however, I see the data comming in in discover (on the sql-query-stats* pattern).

Any idea why this don't work?

FYI.: I tried what was described in Logstash - set @timestamp from sql date column with JDBC input

If the date is processed by the jdbc driver as a string then you need to use a date filter to parse it and set @timestamp. See the last post in the thread you linked to.

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