Grafana with TorQ Gateway

63 views
Skip to first unread message

JerLucid

unread,
Mar 27, 2023, 3:19:58 AM3/27/23
to AquaQ kdb+/TorQ
Hi team,

Is it possible to connect Grafana to the TorQ Gateway directly and call function like
.gw.syncexec? I read in some previous threads that this was not possible
and to use a relay process, which I have done, and that works fine.

I'm just thinking that if I am to scale to many users the singe relay
may become a bottleneck, unless I have multiple relays, or use deferred response
on the relay.
Wondering if anyone has experience with this or advice? 

Jer



Daniel - AQ

unread,
Mar 27, 2023, 7:18:14 AM3/27/23
to AquaQ kdb+/TorQ
Hi Jer,

JerLucid

unread,
Mar 28, 2023, 3:36:56 AM3/28/23
to AquaQ kdb+/TorQ
Hi Daniel,

I'm using the Websocket based Grafana plugin.

I wasn't even aware of the other one you mentioned, so thanks for highlighting that. 

Daniel - AQ

unread,
Mar 29, 2023, 7:20:30 AM3/29/23
to AquaQ kdb+/TorQ
Re-posting for public visibility:

----

Hi Jer,

Officially the WebSocket plugin does not support TorQ Gateway's .gw functionality. For that users should migrate over to the backend plugin which supports .gw.syncexecjt and its derivatives (.gw.syncexecj, .gw.syncexec).
Alternatively, as you are aware users can setup a relay process to call .gw functions on the Gateway in a synchronous manner.

If that is not possible, you can manipulate .z.ws and add custom .gw functions to the TorQ Gateway to provide limited .gw.asyncexecjpts functionality, e.g.:

.gw.grafasyncexecjpt:{[q;p;j;t;s;id].gw.asyncexecjpt[q;p;{[res;j;id]-8! `o`ID!(`payload`id`error`success!({`columns`rows!(enlist ([]text:cols x);enlist flip value flip x)}@[j;res];"";"OK";1b);id)}[;j;id];();0Wn]};
.gw.grafasyncexec:.gw.grafasyncexecjpt[;;raze;();0Wn]
.z.ws:{ds:-9!x;if[not `function~ds[`i;1;`queryParam;`query;`type];neg[.z.w]-8!`o`ID!("'GW only supports function queries";ds[`ID])];@[value;ds[`i;1;`queryParam;`query;`value]][ds`ID]}

This would enable queries to be run from the WebSocket plugin on the Gateway such as:
.gw.grafasyncexec["delete date from select from trade where sym=`AMD";`hdb`rdb]

This would be dependent on each user's conditions and requirements though; the above setup for example will only work with Free-Form Queries, does not support row-limits or conflation, and only supports queries which call these new functions. It also does not support error handling, so would be difficult to debug.

Overall, if possible, your best bet would be migrating over to the new backend plugin as that already has support for .gw.syncexec as well as a number of other newer Grafana features. The backend plugin is what we will be supporting going forward, with only legacy support for the WebSocket plugin.

Thanks,
Daniel

jer04

unread,
Mar 30, 2023, 3:55:35 AM3/30/23
to Daniel - AQ, AquaQ kdb+/TorQ
Thanks for the in-depth explanation Daniel, and examples, you've convinced me. I'll migrate over to the newer version to make use of the new functionality.

--
www.aquaq.co.uk
www.aquaq.co.uk/blog
www.aquaq.co.uk/training
---
You received this message because you are subscribed to a topic in the Google Groups "AquaQ kdb+/TorQ" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kdbtorq/ZkgnMq_hBhE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kdbtorq+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/kdbtorq/0b7608f2-f74a-4ccc-b669-2f8d38ea9e35n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages