grafana使用json数据源监控数据

功能实现完后有部分数据一直在波动,就产生了想把这个数据波动集成到grafana形成可视化界面的监控,但grafana不支持mongo数据库又懒得去用其他工具转换,特意看了下grafana的database插件,因此看到了json数据源

JSON Datasource - a generic backend datasource

JSON Datasource is an enhanced version of the Simple JSON Datasource.

The JSON datasource executes JSON requests against arbitrary backends. To work with this datasource the backend needs to implement 4 urls:

  • / should return 200 ok. Used for "Test connection" on the datasource config page.
  • /search used by the find metric options on the query tab in panels.
  • /query should return metrics based on input.
  • /annotations should return annotations.

官方说明中写的也比较清楚,一共实现4个接口,简单说明一下就是:

/:啥都不用做,response返回200即可,用于绑定数据源的时候校验联通性
/search:返回指标,实际就是metric,用户配置
/query:返回指标值,实际就是(值,时间点)的列表,用于查询值
/annotations:返回注解,用于配置

具体参数可以参考下官方github

posted @ 2018-12-13 16:51  张q  阅读(13010)  评论(0编辑  收藏  举报