当前位置:网站首页>Grafana 分享带可变参数的链接
Grafana 分享带可变参数的链接
2022-04-23 19:23:00 【杨林伟】
前言
最近有一个需求,就是把grafana上的页面分享给前端,前端只要拿到链接就可以通过传参数的方式去刷新页面。
那该如何实现呢?从描述中,可以知道需要解决几个问题:
- 前端如何不用登录打开链接就能看到页面?
- 如何分享链接?
- 如何使分享链接带有参数?
- 如何只得到自己想要的页面?
下面本文围绕这几个问题来讲讲。
step1:设置免登陆
如果想直接打开grafana的链接而不登录,需要修改defaults.ini
。
进入grafana的安装目录,编辑可以匿名访问:
vi vi /opt/prometheus_env/grafana-8.4.7/conf/defaults.ini
修改内容如下:
#################################### Anonymous Auth ######################
[auth.anonymous]
# enable anonymous access
enabled = true
然后重启grafana即可。
step2:分享链接
分享链接很简单,只要在界面点击如下图就可以分享:
分享 | 选择样式并复制链接 |
---|---|
我们复制出来的链接是这样子的:http://服务器地址:3000/d/pcip2Ow7z/shi-shi-cai-ji-jian-kong-zhi-biao?orgId=1&from=1650593694199&to=1650615294199&theme=light&viewPanel=5
显然,在这个链接中,我们是传入不了参数的,该如何传参呢?其实我们需要先定义一个全局参数。
step3:设置全局参数
点击右上角的设置按钮:
点击变量模块,并new 一个变量:
设置变量,内容如下:
点击update后,再点击Save dashboard,在我们的模板页面,可以看到多了一个查询输入框:
这不是最关键的,我们进去设置面板,面板里面再设置变量名:
ok,到这里,我们可以正式分享链接了
step4:分享带参数的链接
打开分享的链接,并输入我们要查询的内容:
在把浏览器的链接复制出来:
可以看到这个链接带有一个查询条件:var-exported_job
,所以只要我们提供这个链接给前端,并让前端传入var-exported_job
的值,就可以对传入不同的条件去查询了。
但是还有一个问题,界面有Grafana状态栏和菜单栏,我们改如何去掉呢?
step5:优化界面
我们通过在链接后面增加kiosk
参数,即可去掉,链接修改后为:
效果如下图:
看,这个界面是不是前端直接就能使用了。
好了,到此,本文就讲解完毕了,希望能帮助到大家!
版权声明
本文为[杨林伟]所创,转载请带上原文链接,感谢
https://yanglinwei.blog.csdn.net/article/details/124348589
边栏推荐
- Summary of several relationships of UML class diagram
- Quick start to static class variables
- Web Security
- Openharmony open source developer growth plan, looking for new open source forces that change the world!
- Decompile and get the source code of any wechat applet - just read this (latest)
- [transfer] summary of new features of js-es6 (one picture)
- OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
- The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics
- [报告] Microsoft :Application of deep learning methods in speech enhancement
- Common processing of point cloud dataset
猜你喜欢
Oracle配置st_geometry
Wechat video extraction and receiving file path
网络协议之:sctp流控制传输协议
8266 obtain 18b20 temperature
On the forced conversion of C language pointer
Virtual machine performance monitoring and fault handling tools
White screen processing method of fulter startup page
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
Prefer composition to inheritance
命令-sudo
随机推荐
C1000k TCP connection upper limit test 1
FTP, SSH Remote Access and control
Strange problems in FrameLayout view hierarchy
Prefer composition to inheritance
Codeforces Round #784 (Div. 4)
SSDB foundation 1
The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics
Easy mock local deployment (you need to experience three times in a crowded time. Li Zao will do the same as me. Love is like a festival mock)
Openlayers 5.0 loading ArcGIS Server slice service
Class loading mechanism
MySQL lock
Openlayers 5.0 two centering methods
Codeworks round 783 (Div. 2) d problem solution
Openlayers 5.0 thermal diagram
Openlayers draw rectangle
openlayers 5.0 加载arcgis server 切片服务
PostgreSQL
[play with lighthouse] Tencent cloud lightweight server builds a full platform video analysis video download website
goroutine
SQL server requires to query the information of all employees with surname 'Wang'