Hello,
I’m trying to develop a telemetry server, for a real time application, that runs on a raspberry pi. At first I tried to configure a InfluxDB instance on it and simply set up a Influxdb datasource that queries the db with a frequency of 10Hz, but it turned out to be too much work for a single pi to handle.
there’s where I got the idea to bypass the database and simply stream directly to Grafana only data that changes in order to have a (pseudo) real time telemetry system.
For what I can read online, this was a requested feature in the past years but currently there doesn’t exist a fully working plugin that allows it. (correct me if I’m wrong).
I tried to develop my own streaming plugin following the tutorials “building a datasource plugin” and “building a streaming datasource plugin”, but I’m already facing a problem (probably first of many).
If there is another way to achieve my goal pleas tell me, otherwise a bit of help on my problem would be very appreciated!
I managed to set up a datasource and when I run a query I just receive a costant (default) value. I tried to change the code (see images) in datasource.ts by changing values to return and in types.ts and QueryEditor.tsx to change the “MyQuery” and allow the user to have an additional parameter in the query but the problem I get is the following:
- I keep receiving a costant value
- I cannot see the box for the additional variable of the query in grafana.
Could you please tell me what I’m doing wrong?
Grafana version : 7.4.3
[QueryEditor.tsx]
(As I am a new user I’m allowed to post only 2 pictures, I posted the most significative ones. I’ll report below the code of “MyQuery” and the “query” method in datasource.ts)
export interface MyQuery extends DataQuery {
queryText?: string;
constant: number;
offset: number,
}
async query(options: DataQueryRequest<MyQuery>): Promise<DataQueryResponse> {
const { range } = options;
const from = range!.from.valueOf();
const to = range!.to.valueOf();
// Return a constant for each query.
const data = options.targets.map(target => {
const query = defaults(target, );
const frame = new MutableDataFrame({
refId: query.refId,
fields: [
{ name: 'time', type: FieldType.time },
{ name: 'value', type: FieldType.number },
],
});
for(var i = 0; i < 10; i++) {
frame.add({ time: from + (i * 10), value: i + query.offset });
}
});
return { data };
}