当前位置:网站首页>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
边栏推荐
猜你喜欢

Android Development: the client obtains the latest value in the database in real time and displays it on the interface

MySQL syntax collation (5) -- functions, stored procedures and triggers

The platinum library cannot search the debug process records of some projection devices

浅谈c语言指针的强制转换
![[transfer] summary of new features of js-es6 (one picture)](/img/45/76dba32e4fa7ed44a42e5f98ea8207.jpg)
[transfer] summary of new features of js-es6 (one picture)

Is meituan, a profit-making company with zero foundation, hungry? Coupon CPS applet (with source code)

Decompile and get the source code of any wechat applet - just read this (latest)

Common SQL commands

命令-sudo

Build intelligent garbage classification applet based on Zero
随机推荐
Openharmony open source developer growth plan, looking for new open source forces that change the world!
Some speculation about the decline of adults' language learning ability
js获取本机ip地址
SSDB基础2
Network protocol: SCTP flow control transmission protocol
Prefer composition to inheritance
Translation of audio signal processing and coding: Preface
2022.04.23 (the best time for lc_714_to buy and sell stocks, including handling charges)
Keysight has chosen what equipment to buy for you
An idea of rendering pipeline based on FBO
Installation, use and problem summary of binlog2sql tool
Redis optimization series (III) solve common problems after master-slave configuration
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
Data analysis learning directory
Redis core technology and practice 1 - start with building a simple key value database simplekv
Some records used by VS2010
坐标转换WGS-84 转 GCJ-02 和 GCJ-02转WGS-84
网络协议之:sctp流控制传输协议
ArcMap连接 arcgis server
Matlab 2019 installation of deep learning toolbox model for googlenet network

