I’ve since written a full blog on this particular Single Message Transform. It can be found at See also https://rmoff.net/2020/12/17/twelve-days-of-smt-day-8-timestampconverter/
Last active
February 26, 2021 12:03
-
-
Save rmoff/179ed4067b9f042344cf597286ac1840 to your computer and use it in GitHub Desktop.
Example of Using Kafka Single Message Transform TimestampConverter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"_comment": "Use SMT to cast op_ts and current_ts to timestamp datatype (TimestampConverter is Kafka >=0.11 / Confluent Platform >=3.3). Format from https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html", | |
"transforms": "convert_op_ts,convert_current_ts", | |
"transforms.convert_op_ts.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value", | |
"transforms.convert_op_ts.target.type": "Timestamp", | |
"transforms.convert_op_ts.field": "current_ts", | |
"transforms.convert_op_ts.format": "yyyy-MM-dd HH:mm:ss.SSSSSS", | |
"transforms.convert_current_ts.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value", | |
"transforms.convert_current_ts.target.type": "Timestamp", | |
"transforms.convert_current_ts.field": "op_ts", | |
"transforms.convert_current_ts.format": "yyyy-MM-dd HH:mm:ss.SSSSSS" |
U can use the "db.timezone" parameter in the connector configuration, just set your timezone and U will have the correct date in your target database.
I'm using a sink elasticsearch connector. I could'n find this parameter "db.timezone" in the docs. Actually, I thing this parameter db.timezone is exclusive for JDBC connectors.
Sorry I didn't notice the question is about elasticsearch sink connector.
It works like charm! Thank you a lot.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
U can use the "db.timezone" parameter in the connector configuration, just set your timezone and U will have the correct date in your target database.