grafana:基本操作

grafana用户

  • user: admin
  • password: xxxx

配置数据源

configuration图标--->datasource--->settings--->mysql--->配置数据库地址和连接

配置图表(比如通过mysql语句形成横纵坐标)

add符号--->create dashboard--->add query(建立查询语句)--->queries to db(选择数据库名)--->构造查询语句

时间横轴和指标纵轴

grafana sql:Data points outside time range
一定要有as time 或者 as  time_sec 转换为时间戳或者Unix 时间戳, 作为横轴; 
剩下的作为衡量指标, 作为纵轴
====> ctrl+s保存为新面板放在自己文件夹下。

SELECT
UNIX_TIMESTAMP(data_time) as time_sec,
current_offset, last_offset, offset_diff
FROM monitor_kafka_offsets;
SELECT
  UNIX_TIMESTAMP(data_time) as time_sec,
  current_offset, 
  last_offset, 
  offset_diff
FROM monitor_kafka_offsets 
where cluster in ($cluster) 
and topic in ($topic) 
and frequency in($frequency);
SELECT * FROM `supervision`.`monitor_kafka_offsets` 
WHERE cluster="xingguang" 
and data_time="2019-08-15 07:45:00";

配置报警

alert按钮--->
notification channels(建立报警渠道)--->
name(报警渠道名字)+type(可选择以email报警)+包含图表邮件会接收到报警图表--->
send test(发送不了要检查)

配置报警规则

在面板处(键盘E编辑,V展示)--->
点击报警按钮开始报警--->
配置报警规则
dashboard-setting--->
variables--->如cluster, query="select cluster from monitor-kafka-offsets"
Conditions
目前唯一存在的条件类型是一个查询条件,允许您指定查询字母(metric里查询语句的字母,代表哪个查询语句)、时间范围和聚合函数。
Query condition example
例:avg() OF query(A, 5m, now) IS BELOW 14:
从现在开始,往前的5分钟Metric那条sql查出来数据的平均值 小于14
avg() :控制如何将每个serie 值降低到一个可以与阈值比较的值。 点击该功能可以选择另一个聚合函数。
query(A, 5m, now) :字母A代表从Metrics页签查询A查询条件语句。第二个参数定义了时间范围, 5m, now 意思从现在到现在的5分钟。这是有用的,如果你想忽略最后2分钟的数据。
IS BELOW 14:定义的阈值和阈值的类型。你可以点击IS BELOW 改变阈值的类型

删除面板

dashboard 下面包含panel
矩形图标=》manage=》文件夹下的panel删除
或面板删除

datasource: yinli_mysql_90
cluster  yinli_mysql_90
select  distinct cluster from supervision.monitor_kafka_offsets
SELECT
  UNIX_TIMESTAMP(data_time) as time_sec,
  current_offset, last_offset, offset_diff
FROM supervision.monitor_kafka_offsets
where cluster='$cluster' and topic='$topic'
query inspector检查员resonse=》results=>objects===>sql:
SELECT UNIX_TIMESTAMP(data_time) as time_sec, current_offset, last_offset, offset_diff FROM supervision.monitor_kafka_offsets where cluster='xingguang' and topic='0iady1hzawwe7nj0'
报警:WHEN sum () OF query (A, 5m, now) IS BELOW 1

##########################
SELECT
stream,
COUNT(1) AS happen_times
FROM bi_data.renren_zhibo_video_monitor
WHERE curfps<10 AND $__timeFilter(date_time)
GROUP BY stream HAVING happen_times > 1

min b, 1, now is above 1
##########################

posted @ 2019-12-11 15:59  Adamanter  阅读(4028)  评论(0编辑  收藏  举报