I'm trying to create a Grafana plugin that supports the logs panel. I'm following the directions from their website.
Unfortunately it doesn't seem to work. I've added "logs": true
to plugin.json
and am returning a field of type time
called "time"
, a field of type string
called "level"
, and a field of type string
called "content"
, following along with their example. I'm returning essentially the same thing as the example shows.
export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
constructor(instanceSettings: DataSourceInstanceSettings<MyDataSourceOptions>) {
super(instanceSettings);
}
async query(options: DataQueryRequest<MyQuery>): Promise<DataQueryResponse> {
// Return a constant for each query.
const data = options.targets.map(target => {
const query = defaults(target, defaultQuery);
const frame = new MutableDataFrame({
refId: query.refId,
fields: [
{ name: 'time', type: FieldType.time },
{ name: 'level', type: FieldType.string },
{ name: 'content', type: FieldType.string },
],
});
frame.add({ time: 1615422190000, level: 'warn', content: 'hi' });
frame.add({ time: 1615422191000, level: 'info', content: 'bye' });
return frame;
});
return { data };
}
async testDatasource() {
// Implement a health check for your data source.
return {
status: 'success',
message: 'Success',
};
}
}
Yet in Grafana (running the latest stable version, 7.4.3) when I load my plugin I am unable to get the log panel in Explore and in the Dashboard query interface if I choose the log panel it displays the data but incorrectly:
Is there something else I need to do to make the log panel work? The instructions claim I just need to return a field of type time
and a field of type string
with "logs": true
set in plugin.json
, but that's not working.
The only real hint I can find so far is this other SO question about the MSSQL plugin, which suggests that maybe something about this function in that plugin would show how the data needs to be formatted, but it's not clear to me reading the source what that might be and how it's different from what I'm doing now.
ETA: Looks like this question asked something similar but the answer doesn't make it clear what the issue was since it seems in their case they were returning a result of the wrong type altogether.