grafana配置完成后,经常在mysql的数据库内读取数据。有时候采用变量的形式,通过一下方法设置变量。
DropCounts
SELECT 'DropCounts' AS __text, ROUND((${__to}+1000-${__from})/6000000) AS __value FROM report limit 1
OUT_ITEMS
SELECT 'OUT_ITEMS' AS __text, '(401,402, 467,468)' as __value
SELECT 'O_OUTRATE' AS __text, SUM(value) as __value
FROM
(SELECT
date_format(from_unixtime(clock), '%Y-%m-%d %H:%i') as time, value
FROM history
WHERE itemid IN ${OUT_ITEMS}
AND $__unixEpochFilter(clock)
ORDER BY time
)
AS temp
GROUP BY time
ORDER by __value
DESC LIMIT ${DROPCOUNTS},1
SELECT
unix_timestamp(time) as time_sec,
${O_OUTRATE} as value,
'Out端口流量95值' as metric
FROM
(SELECT date_format(from_unixtime(clock), '%Y-%m-%d %H:%i') as time
FROM history
WHERE itemid IN ${OUT_ITEMS}
AND $__unixEpochFilter(clock)
ORDER BY time)
AS temp
GROUP BY time;
本文共 70 个字数,平均阅读时长 ≈ 1分钟
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有