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

Problems with Cloudflare analytics engine Clickhouse after upgrading to 3.0.0

Open spelexander opened this issue 1 year ago • 25 comments

I use Cloudflare Analytics Engine and Grafana cloud. In the official documentation for Cloudflare Analytics Engine, using this plugin is the recommended option for integrating with Grafana.

I have been using Altinity plugin with Grafana for some time, but due to the Angular deprecation warnings I decided to upgrade today.

Since upgrading my plugin to 3.0.0 I have been unable to:

  • Edit query settings (e.g. to select a database, table or DateTime column) Screenshot 2024-05-12 at 6 47 49 pm
  • Edit the plugin configuration in Grafana settings Screenshot 2024-05-12 at 6 55 12 pm

Steps to reproduce:

  1. Follow the setup guide here: https://developers.cloudflare.com/analytics/analytics-engine/grafana/
  2. Create a new datasource
  3. You will be unable to Save and Test the datasource without a crash in Grafana

Error message:

An unexpected error happened
Details
TypeError: Cannot assign to read only property 'dataSourceUrl' of object '#<Object>'

    at https://renewview.grafana.net/public/plugins/vertamedia-clickhouse-datasource/module.js?_cache=3.0.0:2:3699851
    at div
    at vt (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/Connections.a1ad302de305309a8646.js:48:2348)
    at o (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:1:172)
    at form
    at Pt (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/Connections.a1ad302de305309a8646.js:56:1914)
    at At (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/Connections.a1ad302de305309a8646.js:56:1464)
    at f (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:239:18087)
    at div
    at div
    at div
    at div
    at te (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:902:4503)
    at d (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:63:30037)
    at c
    at div
    at K (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:239:22026)
    at wt (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/Connections.a1ad302de305309a8646.js:56:4946)
    at Bt (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/Connections.a1ad302de305309a8646.js:56:5358)
    at j (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1044:29171)
    at j (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1044:31348)
    at Gt (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/Connections.a1ad302de305309a8646.js:64:2099)
    at Suspense
    at l (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:63:125457)
    at er (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:184:11347)
    at j (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1044:29171)
    at co (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1035:4448)
    at lr (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1035:11997)
    at Nt (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1044:17387)
    at j (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1044:31348)
    at main
    at div
    at div
    at div
    at kn (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:184:2441)
    at div
    at kr (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:184:6891)
    at co (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1035:4448)
    at lr (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1035:11997)
    at hs (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1035:11333)
    at fr (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1044:17686)
    at j (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1044:25387)
    at v (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:111:8970)
    at _ (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1377:112624)
    at c (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:479:21361)
    at l (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:63:125457)
    at g (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:63:125966)
    at et (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/330.3e128f9f2fef2b8f895b.js:1016:530)
    at Ll (https://grafana-assets.grafana.net/grafana/11.1.0-70648/public/build/2540.a40dde18ed1e1774799b.js:195:127)

spelexander avatar May 12 '24 16:05 spelexander

duplicated https://github.com/Altinity/clickhouse-grafana/issues/516 fixed in 3.1.0 which was submit on Friday let's wait when review from Grafana Labs finish

Slach avatar May 13 '24 06:05 Slach

I cannot believe how long it takes

caglarsayin avatar May 16 '24 10:05 caglarsayin

@caglarsayin 3.1.0 was released recently, please check it

Slach avatar May 16 '24 11:05 Slach

Same issue on 3.2.3

dangeredwolf avatar Oct 19 '24 16:10 dangeredwolf

@dangeredwolf which grafana-server version do you use?

Slach avatar Oct 19 '24 20:10 Slach

@Slach I'm using Grafana Cloud, version 11.4.0-77383

dangeredwolf avatar Oct 19 '24 20:10 dangeredwolf

When you said "same" do you mean you see in console TypeError: Cannot assign to read only property 'dataSourceUrl' of object '#<Object>' ?

or just "save & test" doesn't work?

Slach avatar Oct 19 '24 20:10 Slach

I had the issue where the settings was broken with TypeError: Cannot assign to read only property 'dataSourceUrl' of object '#<Object>' (I found this GitHub issue by googling the error), and I also have the issue where I cannot set the timestamp column. Though now it's letting me access the settings without crashing this time.

dangeredwolf avatar Oct 19 '24 20:10 dangeredwolf

I am also using Cloudflare Analytics Engine and I am unable to set the timestamp column as the timestamp. In fact, it does not list any databases, tables, or columns.

Screenshot 2024-10-19 at 14 01 37 Screenshot 2024-10-19 at 13 57 34

I can get the data to properly display in Grafana, but I cannot filter it by an time range because I have been unable to set the timestamp column. Per spec, it is available under the timestamp column.

dangeredwolf avatar Oct 19 '24 20:10 dangeredwolf

Ok. let's try to figure out

could you share

curl -vvv -X POST "https://api.cloudflare.com/client/v4/accounts/<your-account-id>/analytics_engine/sql" -H "Authorization: Bearer <your-api-token>" --data "SELECT version()"

without sensitive credentials

Slach avatar Oct 20 '24 16:10 Slach

I ran it and

< HTTP/2 422 
...
* Connection #0 to host api.cloudflare.com left intact
Input was invalid: unknown function call: version

Huh... So there's that.

dangeredwolf avatar Oct 20 '24 16:10 dangeredwolf

sorry, try Version() instead version()

Slach avatar Oct 20 '24 16:10 Slach

ok. try

curl -vvv -X POST "https://api.cloudflare.com/client/v4/accounts/<your-account-id>/analytics_engine/sql" -H "Authorization: Bearer <your-api-token>" --data "SHOW CREATE TABLE system.columns"

Slach avatar Oct 20 '24 16:10 Slach

unknown function call: Version

unsupported SQL statement type: SHOW CREATE TABLE system.columns

🫠

dangeredwolf avatar Oct 20 '24 16:10 dangeredwolf

last check

same parameters but different --data

--data "SELECT name,database,table,type FROM system.columns WHERE type LIKE '%Date%' OR type LIKE '%DateTime%' OR type = 'UInt32' ORDER BY type,name FORMAT JSON"

Slach avatar Oct 20 '24 16:10 Slach

unsupported binary operator: LIKE

Sorry if these outputs aren't more helpful, seems Cloudflare's SQL API is a bit limited :/

Even though ironically Cloudflare still recommends this specific plugin for use with Analytics Engine

dangeredwolf avatar Oct 20 '24 18:10 dangeredwolf

check --data "SELECT name,database,table,type FROM system.columns WHERE substring(type,1,4) = 'Date' OR type = 'UInt32' ORDER BY type,name FORMAT JSON"

looks like they tested on 2.x

Slach avatar Oct 20 '24 19:10 Slach

cannot specify a database when selecting a dataset: system

dangeredwolf avatar Oct 21 '24 16:10 dangeredwolf

hm, looks like cloudflare workers analytics engine have too many restrictions

Slach avatar Oct 22 '24 08:10 Slach

did you try just setup database and table and time related column, manually in UI, instead of try to select it from drop down?

Slach avatar Oct 22 '24 08:10 Slach

did you try just setup database and table and time related column, manually in UI, instead of try to select it from drop down?

By manually in the UI do you mean typing it in and hitting enter? Cause if so, I did try that but Grafana won’t let me. If I’m missing something else though or if there’s a configuration file that I can manually edit I’d love to know about it

dangeredwolf avatar Oct 22 '24 15:10 dangeredwolf

@dangeredwolf are you sure do you use latest version of plugin? i just tried manual typing and just press enter in grafana cloud and everything works as expected. image

Slach avatar Oct 24 '24 09:10 Slach

@Slach 3.2.3 is the latest version, right? Screenshot 2024-10-24 at 04 46 40

dangeredwolf avatar Oct 24 '24 11:10 dangeredwolf

yes, i created data source after that i succesfully add panel

could you save screencast to reproduce whats failed on your side?

Slach avatar Oct 24 '24 11:10 Slach

I am able to add it but am unable to set Database or Columns in the UI even though I can write SQL queries to do so https://github.com/user-attachments/assets/8ba5332b-d056-42ab-8aef-61588a9ff55a

If I could somehow manually force timestamp as the timestamp column in the configuration somewhere it might be possible to work around this, but I'm not sure how to do that.

dangeredwolf avatar Oct 24 '24 12:10 dangeredwolf

on shared screencast you didn't try to use keyboard

try just press left click to field and instead of trying select from drop down type database and table name in edit field and press ENTER it shall added and $timeFilter and $timeSeries shall works after that

Slach avatar Oct 25 '24 11:10 Slach