# Logstash - set @timestamp in .conf files

**URL:** <https://discuss.elastic.co/t/logstash-set-timestamp-in-conf-files/232449>\
**Category:** Logstash\
**Created:** [May 13, 2020, 1:42pm UTC](https://discuss.elastic.co/t/logstash-set-timestamp-in-conf-files/232449 "2020-05-13T13:42:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cedric2](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cedric2](https://discuss.elastic.co/u/cedric2)\
**Post date:** [May 13, 2020, 1:42pm UTC](https://discuss.elastic.co/t/logstash-set-timestamp-in-conf-files/232449/1 "2020-05-13T13:42:26Z")

</div>

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](https://discuss.elastic.co/t/logstash-set-timestamp-from-sql-date-column-with-jdbc-input/95873)

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 13, 2020, 2:19pm UTC](https://discuss.elastic.co/t/logstash-set-timestamp-in-conf-files/232449/2 "2020-05-13T14:19:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 10, 2020, 2:20pm UTC](https://discuss.elastic.co/t/logstash-set-timestamp-in-conf-files/232449/3 "2020-06-10T14:20:05Z")

</div>

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