grafana数据可视化-使用教程

一、Linux安装grafana

wget https://dl.grafana.com/oss/release/grafana-6.4.3-1.x86_64.rpm
sudo yum localinstall grafana-6.4.3-1.x86_64.rpm
sudo /sbin/chkconfig --add grafana-server
sudo service grafana-server start

二、登录grafana

默认端口:3000

地址:http://ip:3000

初始管理员账号:admin,密码:admin

三、连接数据库

 四、配置图表显示

左上角  +  create  dashboard

右上角菜单  add panel

先选择图表类型

选择数据库,写好sql

五、sql demo

select round(REAL_LOAN_DATETIME/1000) as 'time',sum(LOAN_AMOUNT) as '放款金额' 
from (select LOAN_AMOUNT,REAL_LOAN_DATETIME,DATE_FORMAT(FROM_UNIXTIME(ROUND(REAL_LOAN_DATETIME/1000)),'%Y-%m-%d') as LOAN_DATE,status 
from TABLE) tb 
where LOAN_DATE>date_sub(curdate(),interval 10 day) and status='8' group by LOAN_DATE;

select round(REAL_LOAN_DATETIME/1000) as 'time',count(LOAN_AMOUNT) as '放款量' 
from (select LOAN_AMOUNT,REAL_LOAN_DATETIME,DATE_FORMAT(FROM_UNIXTIME(ROUND(REAL_LOAN_DATETIME/1000)),'%Y-%m-%d') as LOAN_DATE,status 
from TABLE) tb 
where LOAN_DATE>date_sub(curdate(),interval 10 day) and status='8' group by LOAN_DATE

select now() as time_sec, other as '自动审批' from TABLE

 

select now() as time_sec, other as value from TABLE

六、插件扩展

以pie-chart为例

wget -nv https://grafana.com/api/plugins/grafana-piechart-panel/versions/latest/download -O   /var/lib/grafana/plugins/grafana-piechart-panel.zip
cd /var/lib/grafana/plugins/
unzip grafana-piechart-panel.zip
service grafana-server restart

 

 

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值