功能實現完后有部分數據一直在波動,就產生了想把這個數據波動集成到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./searchused by the find metric options on the query tab in panels./queryshould return metrics based on input./annotationsshould return annotations.
官方說明中寫的也比較清楚,一共實現4個接口,簡單說明一下就是:
/:啥都不用做,response返回200即可,用於綁定數據源的時候校驗聯通性 /search:返回指標,實際就是metric,用戶配置 /query:返回指標值,實際就是(值,時間點)的列表,用於查詢值 /annotations:返回注解,用於配置
具體參數可以參考下官方github
