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

Can't visualise db data with spaces in JSON Object fields on grafana. #620

Closed
mallikarjun-12 opened this issue Dec 6, 2023 · 7 comments
Closed

Comments

@mallikarjun-12
Copy link

What happened:
When using the ClickHouse plugin in Grafana to retrieve data from a ClickHouse database, I have encountered issues when dealing with JSON data that contains fields with spaces. The sample JSON data provided is as follows:

{
  "timestamp": "2023-12-06 09:20:32",
  "level": "debug",
  "log": {
    "caller": "runtime/asm_arm64.s:1197",
    "cost": 0,
    "count": 0,
    "error": "ws closed: 1001 ",
    "error string": "ws closed: 1001 ",
    "errors": "",
    "id": "IHK9LYy8",
    "index": 0,
    "ip": "",
    "level": "debug",
    "method": "",
    "msg": "error reading client data",
    "path": "",
    "query": "",
    "requestID": "",
    "segment": "",
    "service": "ws",
    "status": 0,
    "statusCode": 0,
    "symbol": "",
    "time": 0,
    "time_taken": 0,
    "ts": "2023-12-06T09:20:32.903Z",
    "user": "",
    "user-agent": "",
    "userID": "",
    "userId": ""
  },
  "service": "ws",
  "msg": "error reading client data",
  "status": 0,
  "requestID": "",
  "ip": "0.0.0.0",
  "method": "",
  "path": "",
  "errors": "",
  "cost": 0
}

Query: SELECT "log", "level", "timestamp" FROM "default"."logs" LIMIT 10;

Error Field: error string

Error: error querying the database: clickhouse: unsupported column type "string String"

What you expected to happen:
Visualise data even if the JSON fields have spaces.

How to reproduce it (as minimally and precisely as possible):

  • Install Clickhouse plugin
  • add click house details and connect
  • Insert data into a sample table with one column as JSON which has a field with spaces.
  • Try to visualise table data on grafana

Screenshots
Screenshot 2023-12-06 at 3 15 16 PM

Environment:

  • Grafana version: 10.1.2 (commit: 8e428858dd, branch: HEAD)
  • Plugin version: 3.3.0
  • OS Grafana is installed on: 6.1.52-71.125.amzn2023.aarch64
  • User OS & Browser: Google Chrome
  • Others:
@adamyeats
Copy link
Contributor

adamyeats commented Dec 7, 2023

@mallikarjun-12 Hey there! I'm looking into reproducing this on my side currently. Would you be able to confirm the exact schema of the table you're trying to read from (DESCRIBE TABLE output for the table would be great), and the table engine (e.g. MergeTree, TinyLog etc.) that the table uses please?

@bossinc bossinc moved this from Incoming to Waiting in Partner Datasources Dec 29, 2023
@alyssabull
Copy link
Contributor

Hey @mallikarjun-12! Is this still an issue? If it is, can you provide us with more information (listed in the comment above)? Thanks!

@aangelisc
Copy link
Contributor

Hi @mallikarjun-12, are you able to confirm if this is still an issue? Reading the ClickHouse docs I can see that this type is obsolete. Does the Map type work instead?

@siva-vunet
Copy link

Hey @adamyeats I have encountered this exact same issue today. Follow the steps below for replication -

  1. Create a table with one JSON column using a MergeTree engine. Ex:

CREATE TABLE default.sample_table ( json_data Object('json') ) ENGINE = MergeTree ORDER BY tuple()

  1. Insert a json with a space in any one of the keys. Ex:

INSERT INTO sample_table VALUES ('{"key 1":10}')

  1. Try querying the table from the grafana plugin which should lead you to the following error -
    error querying the database: clickhouse: unsupported column type "1 Int8"`

@aangelisc
Copy link
Contributor

Thank you for the update @siva-vunet, have you also attempted a similar test with the Map type?

@SpencerTorres are you able to chime in here? It seems this may be related to how ClickHouse handles JSON rather than something specific to Grafana.

@siva-vunet
Copy link

Yes I have tried this with the Map data type and it doesn't throw any error there. Have tried with Array and Nested too just in case and was able to successfully query the rows with spaces in them.

@SpencerTorres
Copy link
Collaborator

I believe the map type is preferred for now if that works for you. ClickHouse docs say the JSON field is experimental and obsolete.

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

No branches or pull requests

6 participants