概述
今天尝试使用了一把worldmap插件,昨天下午开始弄的,安装还是挺容易的,实际制作pannel时,卡住了,今天早晨才搞定,挺开心,哈哈。
插件安装
1.
worldmap1.PNG
2.
image.png
3.
image.png
4.cmd 进入grafana安装目录/bin:执行步骤3中的命令
5.安装完成后,重启grafana-server
6.此时进去,你就能惊喜的发现,有worldmap可选了
image.png
使用方法
我使用的数据库是MySQL,这里数据查询有两种方式:geohash(坐标是一个字符串,这个我之前是不懂的,备注下)和coordinates(坐标是经度+纬度)
geohash方式
1.底层数据表
构造字段:time(时间,暂时没啥用),geohash(字符串模式坐标),host(地点名称),value(值,貌似是用来画圈圈的),我一般会把命名给固定下来。
示例查询语句:
select now() as time
,'wttf5jy' as geohash
,'cmbsu' as host
,rand()*2 as value
from tb_location
2.图表配置
Field Mapping/Table Query Format选"geohash",其他应该不用变,因为字段名已设定一致
image.png
initial Zoom设置为5,不然地图太大了,搞小一点
image.png
最后呈现,像这样
image.png
coordinates方式
1.底层数据表
构造字段:time(时间,暂时没啥用),longitude(经度),latitude(纬度),host(地点名称),value(值),我还是一般会把命名给固定下来。
示例查询语句:
select now() as time
,address as host
,longitude
,latitude
,rand()*2 as value
from tb_location
2、图表配置
直接上图
image.png
其他的参考geohash方式,差不多的
结束语
复杂的地图应用,往往都是从简单的开始的,下来就是发挥worldmap的魅力时刻!还有3D地图等我去探索,哈哈哈哈哈哈哈哈哈