从grafana日志面板数据源插件的datasource.js的查询函数中返回什么? [英] What do I return from the query function of datasource.js for grafana log panel datasource plugin?

查看:83
本文介绍了从grafana日志面板数据源插件的datasource.js的查询函数中返回什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重现

基于 Github链接|oci-datasource-file

对于其他面板类型,我修改了代码以返回其中包含数据的响应.

我的回复看起来像这样,并用

替换了数据

  result.data = frame.toJSON()返回结果 

此外,如果您可以粘贴我可以查看的工作示例数据,那将非常有帮助.更确切地说,我正在寻找日志面板的示例json数据

解决方案

在Grafana中查看了其中一个测试文件后| LogDetails.test.tsx

看起来像必须返回一样,必须返回为

  result.data = [frame]返回结果 

I am trying to reproduce the steps given in grafana log data source plugin so that I can replace the current-query function with a hardcoded log-panel compatible query function in oci-datasource-plugin Github link| oci-datasource-file

From the documentation of log-panel build guide

      const frame = new MutableDataFrame({
        refId: query.refId,
        fields: [
          { name: 'time', type: FieldType.time },
          { name: 'content', type: FieldType.string, labels: { filename: 'file.txt' } }
        ],
      });
    
      frame.add({ time: 1589189388597, content: 'user registered' })
      frame.add({ time: 1589189406480, content: 'user logged in' })

  1. The documentation suggests to return a Frame.
  2. The steps given shows a Mutable data frame.
  3. But the panel expects a response.

If a frame is returned instead of a response data, the following error appears

Based on the working code found in Github link| oci-datasource-file

for a different panel type , I modified my code to return a response with data inside it.

My response look this and replacing the data with

   result.data = frame.toJSON()
   return result

Also, if you can paste a working sample data that I can look at , it will be really helpful. To be more precise, I am looking for the sample json data for log panel

解决方案

After looking into one of the test files in Grafana | LogDetails.test.tsx

Looks, like it must be returned must be returned as

result.data = [frame]
return result

这篇关于从grafana日志面板数据源插件的datasource.js的查询函数中返回什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆