Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Convert JSON String field to ES Object? #702

Open
jseparovic opened this issue Jun 25, 2023 · 0 comments
Open

How to Convert JSON String field to ES Object? #702

jseparovic opened this issue Jun 25, 2023 · 0 comments

Comments

@jseparovic
Copy link

What's the recommended way to convert a JSON String field (from Debezium MySQL JSON field) into an ES structured object field?

Here's my ES record:

"hits": [
            {
                "_index": "instance._b5523bb03a3d4d9cb2649a82a4e58ec5._00d4c37c0b493d1c9b68fd4f8fd4bc0d.record",
                "_id": "4c8a411a-6aac-41b1-8376-4301efe1f7ee",
                "_score": 1.0,
                "_ignored": [
                    "data.keyword"
                ],
                "_source": {
                    "startDateTime": 1687579920158,
                    "endDateTime": 1687579921872,
                    "data": "{\"CPU\":{\"user\":\"11.2\",\"system\":\"0.2\",\"userNice\":\"0.0\",\"idle\":\"88.3\",\"IOWait\":\"0.0\",\"hardwareIRQ\":\"0.0\",\"softwareIRQ\":\"0.2\",\"stealTime\":\"0.0\"},\"load\":{\"oneMinute\":\"4.68\",\"fiveMinute\":\"4.87\",\"fifteenMinute\":\"5.03\"},\"memory\":{\"total\":128570,\"free\":15776,\"used\":87385},\"swap\":{\"total\":4096,\"free\":1279,\"used\":2817}}"
                }
            },

As you can see from above I have 3 fields coming from MySQL:

  • startDateTime (timestamp)
  • endDateTime (timestamp)
  • data (string)

I want to convert the data field into an object from a JSON string. I'm not able to change it on the source so it must be transformed on the sink.

Does something exist for this? Or do I need to write a transformation for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant