# Jdbc input logstash

**URL:** <https://community.graylog.org/t/jdbc-input-logstash/3998>\
**Category:** Graylog Central (peer support)\
**Created:** [January 31, 2018, 12:48pm UTC](https://community.graylog.org/t/jdbc-input-logstash/3998 "2018-01-31T12:48:37Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![hudojnick](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@hudojnick](https://community.graylog.org/u/hudojnick)\
**Post date:** [January 31, 2018, 12:48pm UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/1 "2018-01-31T12:48:38Z")

</div>

Hello everybody!  
Help me please with @timestamp, i have jdbc input with mssql server, and in my output i have variable - datetime, which include time of created table. How i can use it instead @timestamp?  
this is my conf file:

```auto
input {
 jdbc {
 jdbc_driver_library => "/etc/logstash/drivers/sqljdbc42.jar"
 jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
 jdbc_connection_string => "jdbc:sqlserver://server:1433;databasename=db"
 jdbc_user => "login"
 jdbc_password => "pass"
 statement => "SELECT m.*
 , mc.nameRu AS CategoryNameRu
, mt.nameRu AS TypeNameRu
, ms.nameRu AS SourceNameRu
, p.Fio_Ru
, s.RowName AS LoginName
, pos.FullNameRu AS PositionNameRu
  FROM LOG_Messages m
  JOIN DIC_LOG_MESSAGE_SOURCE_TO_TYPE mst ON mst.id = m.refMessageSourceType
  JOIN DIC_LOG_MESSAGE_CATEGORY mc ON mc.id = mst.refMessageCategory
  JOIN DIC_LOG_MESSAGE_TYPE mt ON mt.id = mst.refMessageType
  JOIN DIC_LOG_MESSAGE_SOURCE ms ON ms.id = mst.refMessageSource
  LEFT JOIN ULS_Persons p ON p.id = m.refRecordCard
  LEFT JOIN LOG_SidIdentification s ON s.id = m.refSid
  LEFT JOIN ULS_SubdivisionPositions pos ON pos.id = m.refPosition
  ORDER BY id DESC"
    }
  }   

  filter {
   mutate {
add_field => { "message" => "%{typenameru}" }
            convert => ["datetime", "string"]
  copy => { "datetime" => "@timestamp" }
  }
   	}
  output {
    gelf{
         	host => "0.0.0.0"
            port => 12231
            short_message => 'short_message'
            }
  stdout { codec => rubydebug}
     }

```

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [January 31, 2018, 1:16pm UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/2 "2018-01-31T13:16:49Z")

</div>

You might want to post your question to the Logstash discussion forums:

> **[Logstash](https://discuss.elastic.co/c/logstash)**
>
> Everything related to your favorite centralized logging platform, including plugins and recipes.

---

<div class="post-metadata">

**Author:** ![hudojnick](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@hudojnick](https://community.graylog.org/u/hudojnick)\
**Post date:** [January 31, 2018, 3:28pm UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/3 "2018-01-31T15:28:30Z")

</div>

No, i use logstash with graylog)

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [January 31, 2018, 3:32pm UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/4 "2018-01-31T15:32:02Z")

</div>

Until now I haven’t seen Graylog-specific in your first post.

Please elaborate on what you want to achieve.

---

<div class="post-metadata">

**Author:** ![hudojnick](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@hudojnick](https://community.graylog.org/u/hudojnick)\
**Post date:** [February 1, 2018, 2:43am UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/5 "2018-02-01T02:43:38Z")

</div>

Can i change timestamp in graylog with other datetime?

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [February 1, 2018, 9:59am UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/6 "2018-02-01T09:59:59Z")

</div>

Yes, that’s possible.

---

<div class="post-metadata">

**Author:** ![hudojnick](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@hudojnick](https://community.graylog.org/u/hudojnick)\
**Post date:** [February 1, 2018, 10:00am UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/7 "2018-02-01T10:00:48Z")

</div>

And, how i can do it?

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [February 1, 2018, 10:03am UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/8 "2018-02-01T10:03:34Z")

</div>

You can replace the “timestamp” field with another valid DateTime instance.

[http://docs.graylog.org/en/2.4/pages/pipelines/functions.html#parse-date](http://docs.graylog.org/en/2.4/pages/pipelines/functions.html#parse-date)

---

<div class="post-metadata">

**Author:** ![hudojnick](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@hudojnick](https://community.graylog.org/u/hudojnick)\
**Post date:** [February 1, 2018, 10:51am UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/9 "2018-02-01T10:51:13Z")

</div>

> [@jochen](#):
>
> DateTime

Ok, can are you please help me and check my pipeline? I have field “datetime”, but i want replace in @timestamp field my value.

> ```
> rule "datetime"
> when
> has_field("datetime")
> then
> let new_date = parse_date(to_string($message.datetime), "yyyy-MM-dd HH:mm:ss.SSS");
> set_field("@timestamp", new_date.year);
> end
> 
> ```

this is from my stream

 ![57](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/2X/5/52bb6efc9dac80856f93c8e624a820d00326c3f7.png)

---

<div class="post-metadata">

**Author:** ![jan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jan/32/11_2.png) [@jan](https://community.graylog.org/u/jan)\
**Post date:** [February 1, 2018, 11:18am UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/10 "2018-02-01T11:18:07Z")

</div>

why not

```auto
rule "datetime"
when
    has_field("datetime")
then
   // parse_date default to UTC if no timezone is given, would need the information what
   // timezone the timestamp is located in if not UTC
    let new_date = parse_date(to_string($message.datetime), "yyyy-MM-dd HH:mm:ss.SSS");
    set_field("timestamp", new_date);
end

```

Or really simple (if no parsing is needed)

why not

```auto
rule "datetime"
when
    has_field("datetime")
then
    set_field("timestamp", to_string($message.datetime);
end

```

---

<div class="post-metadata">

**Author:** ![hudojnick](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@hudojnick](https://community.graylog.org/u/hudojnick)\
**Post date:** [February 1, 2018, 11:34am UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/11 "2018-02-01T11:34:18Z")

</div>

I don’t know why, but it is didn’t work…can are you help me please and can we chating in some messenger, like skype or telegram?)) My Skype - anuar\_mukatov

---

<div class="post-metadata">

**Author:** ![hudojnick](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@hudojnick](https://community.graylog.org/u/hudojnick)\
**Post date:** [February 1, 2018, 12:05pm UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/12 "2018-02-01T12:05:41Z")

</div>

And when i try simulate it, i haven’t changes…and i have this message in right box - Original message would be not be modified during processing. Does it matter that I use Gelf input?

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [February 1, 2018, 1:36pm UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/13 "2018-02-01T13:36:36Z")

</div>

> [@jan](#):
>
> why not

Because that doesn’t work since the “timestamp” field has to be a proper DateTime object. 😉

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [February 1, 2018, 1:37pm UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/14 "2018-02-01T13:37:26Z")

</div>

Graylog is using the “timestamp” field as the message timestamp. You’re trying to set the “@timestamp” field which isn’t used by Graylog.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [February 15, 2018, 1:37pm UTC](https://community.graylog.org/t/jdbc-input-logstash/3998/15 "2018-02-15T13:37:27Z")

</div>

Closed on February 15, 2018, 1:37pm UTC

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