clickhouse-grafana icon indicating copy to clipboard operation
clickhouse-grafana copied to clipboard

Displaying column as JSON View Cell display mode

Open chuprik opened this issue 5 years ago • 15 comments

Hello! I'm using your plugin for selecting data from CH and displaying it as a table. And I would like to display one column from selection as JSON View Cell. And I have weird Grafana behavior, it looks like selected column is quoted and Grafana can't parse JSON :)

image

image

image

image

Do you have any ideas on how to fix that? as I can see, CH returns JSON without escaping via HTTP. It looks like I need to tell somehow Grafana that this field should be processed as "raw".

chuprik avatar May 30 '20 17:05 chuprik

the fast stupid fix is here https://github.com/StrongSquirrel/clickhouse-grafana/commit/e62fb02dd2a96ccb5121c6a0507c83d3fe841e00

image

on hover:

image

chuprik avatar Jun 01 '20 11:06 chuprik

@kotchuprik big thanks for a workaround

unfortunately, I don't have any idea how to properly recognize when we shall use JSON.parse and when is not

cause ClickHouse database doesn't have data types like JSON / JSONB in PostgreSQL and Datasource plugin doesn't know anything about visualization method

Slach avatar Jun 25 '20 15:06 Slach

@Slach I had idea do one more update my code and replace string checking with:

try {
    r.push(JSON.parse(v));
} catch(e) {
    r.push(v);
}

but it looks weird :)

chuprik avatar Jun 25 '20 16:06 chuprik

@kotchuprik yep, but this solution will decrease performance when data amount will grow

Slach avatar Jun 25 '20 16:06 Slach

maybe it can be handled on golang side somehow?

chuprik avatar Jun 25 '20 16:06 chuprik

no, golang part of plugin use only for alerts maybe it can be handled by the "Transform" feature on grafana on the browser side? https://grafana.com/blog/2020/06/11/new-in-grafana-7.0-data-transformations-for-all-visualizations-that-support-queries/

Slach avatar Jun 25 '20 17:06 Slach

@kotchuprik please subscribe to https://github.com/ClickHouse/ClickHouse/pull/7426

Slach avatar Nov 13 '20 18:11 Slach