折线图

sql模式编写

1
2
3
4
5
6
7
8
9
10
11
SELECT
$__timeGroupAlias(create_time, $interval),
count(order_no) count
FROM table_name
WHERE
merchant_id = $merchant_id AND
$__timeFilter(create_time)
GROUP BY 1
ORDER BY
$__timeGroup(create_time, $interval);

$__timeFilter是返回当前选择的时间范围为表达
折线统计图需要有一个时间列,如果没有使用grafana函数,直接使用字段,需要重命名为time

实例如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
select
$__timeGroupAlias(a.start_time,3000s),
count(a.id) as 'pod重启总数'
from
alert_event a
where $__timeFilter(a.start_time)
and a.env in ('prod','cne2-prod')
and a.severity in ('P1','P2','P3')
and a.alert_title like "%Pod%"
and silence = '0'
and a.application in ($application)
group by 1
order by a.start_time asc