What happened:
日志量较大场景下(历史日志100w条左右),日志上下文检索时间范围过大导致sql执行超时
What you expected to happen:
将grafana内置变量$__from&to=$__to分别加到下文和上文查询sql中限制数据
How to reproduce it (as minimally and precisely as possible):
grafana探索界面greptimedb数据源日志查询模式,查询日志后点击日志logcontext链接,在历史日志超过100w条时滚动下文复现
例如现在的下文sql是:
SELECT "real_log_time" as "timestamp", "message" as "body", "appname", "ip", "hostname", "context_id" FROM "public"."kafka_logs_table" WHERE ( "real_log_time" <= '2026-04-02T09:51:46.535Z' ) AND ( "context_id" = 'host004' ) ORDER BY timestamp DESC LIMIT 100 #日志历史数据量相当庞大,很容易导致sql执行超时
增加$__from时间上界限制解决
SELECT "real_log_time" as "timestamp", "message" as "body", "appname", "ip", "hostname", "context_id" FROM "public"."kafka_logs_table" WHERE ( "real_log_time" <= '2026-04-02T09:51:46.535Z' and "real_log_time" >= '$__from') AND ( "context_id" = 'host004' ) ORDER BY timestamp DESC LIMIT 100
上文sql在查询较早时间日志时也会出现上述问题,同上在上文sql中增加$__to时间下界限制可以解决
#Screenshots
Anything else we need to know?:
Environment:
- Grafana version:
- Plugin version:
- OS Grafana is installed on:
- User OS & Browser:
- Others:
What happened:
日志量较大场景下(历史日志100w条左右),日志上下文检索时间范围过大导致sql执行超时
What you expected to happen:
将grafana内置变量$__from&to=$__to分别加到下文和上文查询sql中限制数据
How to reproduce it (as minimally and precisely as possible):
grafana探索界面greptimedb数据源日志查询模式,查询日志后点击日志logcontext链接,在历史日志超过100w条时滚动下文复现
例如现在的下文sql是:
SELECT "real_log_time" as "timestamp", "message" as "body", "appname", "ip", "hostname", "context_id" FROM "public"."kafka_logs_table" WHERE ( "real_log_time" <= '2026-04-02T09:51:46.535Z' ) AND ( "context_id" = 'host004' ) ORDER BY timestamp DESC LIMIT 100 #日志历史数据量相当庞大,很容易导致sql执行超时
增加$__from时间上界限制解决
SELECT "real_log_time" as "timestamp", "message" as "body", "appname", "ip", "hostname", "context_id" FROM "public"."kafka_logs_table" WHERE ( "real_log_time" <= '2026-04-02T09:51:46.535Z' and "real_log_time" >= '$__from') AND ( "context_id" = 'host004' ) ORDER BY timestamp DESC LIMIT 100
上文sql在查询较早时间日志时也会出现上述问题,同上在上文sql中增加$__to时间下界限制可以解决
#Screenshots
Anything else we need to know?:
Environment: