# logstashとpostgresDBを同期して取得する日付データが9時間ずれる

**URL:** <https://discuss.elastic.co/t/logstash-postgresdb-9/276254>\
**Category:** Logstash\
**Created:** [June 17, 2021, 10:30am UTC](https://discuss.elastic.co/t/logstash-postgresdb-9/276254 "2021-06-17T10:30:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lee0745](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lee0745](https://discuss.elastic.co/u/lee0745)\
**Post date:** [June 17, 2021, 10:30am UTC](https://discuss.elastic.co/t/logstash-postgresdb-9/276254/1 "2021-06-17T10:30:31Z")

</div>

logstashとpostgresDBを同期して取得する日付データが9時間ずれます。

postgres（sample\_date)：2021/06/17 11:45:59.740  
logstash同期後：2021-06-17T02:45:59.740Z

私のconfファイルです。

```auto
input {
  jdbc {
     jdbc_driver_library => "../logstash/logstash-core/lib/jars/postgresql-42.2.14.jar"
     jdbc_driver_class => "org.postgresql.Driver"
     jdbc_connection_string => "jdbc:postgresql://IP:5432/rtt"
     jdbc_user => "user"
     jdbc_password => "pwd"
     jdbc_default_timezone => "Asia/Tokyo"
     plugin_timezone => "local"
     last_run_metadata_path => "/tmp/.logstash_jdbc_last_run"
     statement => "SELECT sample_date from table"
     #schedule => "* * * * *"
 }
}

filter {

  date {
    match => ['sample_date', "YYYY-MM-dd HH:mm:ss.sss"]
    timezone => "Asia/Tokyo"
    locale => "ja"
    target => 'sample_date'
  }
}
output {
    stdout { codec => json_lines }
}

```

やりたいこと：原本データ通り取得

上記の設定ではできませんでしたが、何かの追加設定が必要でしょうか。  
上記以外にrubyプラグインなども使いましたが、うまく利きませんでした。  
ここではまっていますが、どうかご存じのかた教えてください。

---

<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:** [June 17, 2021, 5:40pm UTC](https://discuss.elastic.co/t/logstash-postgresdb-9/276254/2 "2021-06-17T17:40:39Z")

</div>

logstash and elasticsearch always store dates as UTC. If you have a timestamp from Asia/Tokyo then a date filter will result in a timestamp 9 hours earlier.

kibana will transform that to whatever the browser's local timezone is.

---

<div class="post-metadata">

**Author:** ![lee0745](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lee0745](https://discuss.elastic.co/u/lee0745)\
**Post date:** [June 23, 2021, 7:29am UTC](https://discuss.elastic.co/t/logstash-postgresdb-9/276254/3 "2021-06-23T07:29:29Z")

</div>

my issue is solved for your reply.  
thank you.

---

<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:** [July 21, 2021, 7:30am UTC](https://discuss.elastic.co/t/logstash-postgresdb-9/276254/4 "2021-07-21T07:30:01Z")

</div>

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