clickhouse-grafana
clickhouse-grafana copied to clipboard
Displaying column as JSON View Cell display mode
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 :)




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".
the fast stupid fix is here https://github.com/StrongSquirrel/clickhouse-grafana/commit/e62fb02dd2a96ccb5121c6a0507c83d3fe841e00

on hover:

@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 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 :)
@kotchuprik yep, but this solution will decrease performance when data amount will grow
maybe it can be handled on golang side somehow?
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/
@kotchuprik please subscribe to https://github.com/ClickHouse/ClickHouse/pull/7426