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

Parse json keys in log #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Parse json keys in log #161

wants to merge 1 commit into from

Conversation

kiaplayer
Copy link

Improvement for #115.
Allows to parse inner json objects (only one level deep).

For example, we have this log message:

{
    "message": "some message",
    "someData1": {
        "someKey1": "someValue1",
        "someKey2": "someValue2"
    },
    "someData2": {
        "someKey3": "someValue3",
        "someKey4": "someValue4"
    }
}

We'll get this data in Clickhouse:

string_fields.names string_fields.values
['message', 'someData1.someKey1', 'someData1.someKey2', 'someData2.someKey3', 'someData2.someKey4'] ['some message', 'someValue1', 'someValue2', 'someValue3', 'someValue4']

Now we can search records in Clickhouse by inner fields:

SELECT
    arrayElement(`string_fields.values`, indexOf(`string_fields.names`, 'someData1.someKey1')) AS searchValue
FROM logs
WHERE searchValue == 'someValue1'
ORDER BY timestamp DESC;

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

Successfully merging this pull request may close these issues.

1 participant