From c41b0a71cf68b550a5a246541f1283ef1ce0d2f0 Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Thu, 4 Apr 2024 14:06:15 +0200 Subject: [PATCH] Alerting: Add state history polling interval (#84837) --- .../rules/state-history/LokiStateHistory.tsx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/public/app/features/alerting/unified/components/rules/state-history/LokiStateHistory.tsx b/public/app/features/alerting/unified/components/rules/state-history/LokiStateHistory.tsx index 33de4bfc980..68de5f9892a 100644 --- a/public/app/features/alerting/unified/components/rules/state-history/LokiStateHistory.tsx +++ b/public/app/features/alerting/unified/components/rules/state-history/LokiStateHistory.tsx @@ -19,6 +19,7 @@ interface Props { ruleUID: string; } +const STATE_HISTORY_POLLING_INTERVAL = 10 * 1000; // 10 seconds const MAX_TIMELINE_SERIES = 12; const LokiStateHistory = ({ ruleUID }: Props) => { @@ -38,12 +39,19 @@ const LokiStateHistory = ({ ruleUID }: Props) => { isLoading, isError, error, - } = useGetRuleHistoryQuery({ - ruleUid: ruleUID, - from: queryTimeRange.from.unix(), - to: queryTimeRange.to.unix(), - limit: 250, - }); + } = useGetRuleHistoryQuery( + { + ruleUid: ruleUID, + from: queryTimeRange.from.unix(), + to: queryTimeRange.to.unix(), + limit: 250, + }, + { + refetchOnFocus: true, + refetchOnReconnect: true, + pollingInterval: STATE_HISTORY_POLLING_INTERVAL, + } + ); const { dataFrames, historyRecords, commonLabels, totalRecordsCount } = useRuleHistoryRecords( stateHistory,