Grafana 安装
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.6.2-1.x86_64.rpm
配置文件 /etc/grafana/grafana.ini
日志目录 /var/log/grafana
启动命令 sudo service grafana-server start
Grafana 元数据存储 sqlite3 /var/lib/grafana/grafana.db
Grafana启动到80端口
http://www.cnblogs.com/creazylinux/p/7206942.html
报错信息
grafana使用介绍
msg=”Fail to start server” logger=server error=”listen tcp 0.0.0.0:80: bind: permission denied”
解决办法
setcap ‘cap_net_bind_service=+ep’ /usr/sbin/grafana-server
service grafana-server restart
配置MySQL数据源
增加DashBoard 选择metric
SELECT
UNIX_TIMESTAMP(time) as time_sec,
sum(selectnum)/60 as value,
'TotalQps' as metric
FROM _status_statistic
WHERE $__timeFilter(time)
group by time
ORDER BY time ASC
实际下发的SQL
select UNIX_TIMESTAMP(`_status_statistic`.`time`) as `time_sec`,(SUM(`_status_statistic`.`selectnum`) / 60) as `value`,('TotalQps') as `metric` from `_status_statistic_20171121_0` `_status_statistic` where ((`_status_statistic`.`time` >= '2017-11-21 10:03:29') AND (`_status_statistic`.`time` <= '2017-11-21 10:18:29')) group by `_status_statistic`.`time` order by `_status_statistic`.`time` asc
CREATE TABLE `_status_statistic` (
`time` datetime DEFAULT NULL,
`serverip` varchar(32) DEFAULT NULL COMMENT 'ip',
`selectNum` bigint(20) DEFAULT NULL,
`loadNum` bigint(20) DEFAULT NULL,
`insertNum` bigint(20) DEFAULT NULL,
`failedInsertNum` bigint(20) DEFAULT NULL
) ENGINE= DEFAULT CHARSET=utf8mb4