How to open a tcp socket via a grafana plugin to stream data from it

I’m currently writing a datasource plugin for Grafana and so far I only use Typescript.

What do I need?

I have a service written in C# that has a listening TCP socket on the server. My Grafana plugin opens a TCP socket and sends a request to the service to open one for me as well. The service creates a new socket and transfers my connection data to this new socket. Now I want to subscribe to this socket with parameters so that I can stream data into my dashboard panel.

What is my problem?

I can only open a web socket with Typescript but no TCP socket.

What have I tried so far?

  1. I have tried to write the plugin as a backend based plugin with typescript and go. But then I encountered the problem how to get the data from the frontend to the backend.
  2. In the frontend code you can import the class BackendSrv to get access to the Grafana backend or a data source. Only I am not sure if this leads me to my goal.

import { getBackendSrv } from ‘@grafana/runtime’;

Since I couldn’t find anything on the internet how to open a TCP socket with Grafana and the documentation is rather poor I would like to know if you have any ideas what to do.

Sounds like you want to make your data source into a TCP client. Have you tried using the net package?

I found this article that looks like it could be useful for you: