mayunlei / aliyun-log-grafana-datasource-plugin

MIT License
26 stars 37 forks source link

使用插件后grafana的自定义变量如何定义 #3

Open luweiv9988 opened 6 years ago

luweiv9988 commented 6 years ago

default

virnet commented 6 years ago

此处下面一行添加return request;

//aliyun-log-grafana-datasource-plugin/dist/datasource.js
                 {
                    key: "metricFindQuery",
                    value: function metricFindQuery(options) {
                        console.log(options);
                        var requests = [];
                        var slsclient = new SLS(this.defaultConfig, this.backendSrv, this.url);
                        var promise = Promise.resolve();
                        var query = this.templateSrv.replace(options, {}, 'glob');

                        var end = parseInt(new Date().getTime() / 1000);
                        var request = slsclient.GetData(this.projectName, this.logstore, {
                            "topic": "",
                            "from": end - 86400,
                            "to": end,
                            "query": query,
                            "reverse": "false",
                            "lines": "100",
                            "offset": "0"
                        }).then(this.mapToTextValue);
                        return request;     //这里添加一行
mayunlei commented 6 years ago

@luweiv9988 @virnet 您好,已经支持了query template,请参考下图配置 image

night1008 commented 5 years ago

自定义变量查询的时间范围只能是最近的24小时吗,不能指定吗

mayunlei commented 5 years ago

@night1008 自定义变量,如果是sls的数据源的话,只能是最近15分钟,你可以自己改代码指定一个固定时间。

night1008 commented 5 years ago

@mayunlei 好的,多谢,那应该可以改成跟随dashboard全局的过滤时间吧

"from": parseInt(options.range.from._d.getTime() / 1000),
"to": parseInt(options.range.to._d.getTime() / 1000),
krait8064 commented 1 year ago

@mayunlei @virnet 为啥代码中调用接口是索引查询GET /logstores/{logstore}/index HTTP/1.1,而不是数据查询GetLogs

截屏2023-05-23 16 01 00