Skip to content

[FEATURE] Implementing blackout window(s) to skip data entirely. #892

@pgfiore

Description

@pgfiore

Which component(s) does this affect?

  • Full Dashboard
  • Lite
  • SQL collection scripts
  • Installer
  • Documentation

Problem Statement

The collectors work on anything that happened in the system. Generally speaking, they always collect from the last run up to now. Overnight, we have just maintenance jobs and DW feeding; they do not add anything useful and, what’s worse, could blow the tempdb (#885).
Note: I'm not use to this environment; sorry for any misunderstanding. Furthermore, drop a msg to pgfiore@hotmail.it for any further consideration.

Proposed Solution

Adding a blackout window(s) when data is skipped in whole and will never ever be collected.

I see two main ways to implement it:

a) The simple approach involves adding a single daily time range (start time and end time) into the config.collection_schedule to define the blackout window.

b) The more thorough one uses a child table that defines multiple daily time ranges. And specific dates are not needed because the blackout window does repeat daily.

Use Case

-- CAN BE RUN IN PROD - IT DOES NOT CHANGE ANYTHING
-- this example is supposed to hack the collect.query_stats_collector in Stage 1: Collect query statistics into temp table
-- adding features to this clause: "WHERE qs.last_execution_time >= @cutoff_time"

drop table if exists #tblBlackouts
drop table if exists #tmpQueryStats
-- Blackout ranges
select start_time=convert(time(3), '23:00:00'), end_time=convert(time(3), '23:59:59.999')
into #tblBlackouts
insert into #tblBlackouts select '00:00:00', '01:59:59.999'
insert into #tblBlackouts select '15:00:00', '15:30:00.000'
-- select * from #tblBlackouts

-- debug data
-- select * from #tmpQueryStats
select top 5 *
into #tmpQueryStats
from sys.dm_exec_query_stats qs
where convert(time(3), qs.last_execution_time) between '23:00:00' and '23:59:59.999'
insert into #tmpQueryStats
select top 5 *
from sys.dm_exec_query_stats qs
where convert(time(3), qs.last_execution_time) between '22:00:00' and '22:59:59.999'

-- output queries that are not in the blackout ranges
select *
from #tmpQueryStats qs -- debug data
where not exists (select 1 from #tblBlackouts B where convert(time(3), qs.last_execution_time) between B.start_time and B.end_time)

select top 10 *
from sys.dm_exec_query_stats qs -- original data
cross apply (VALUES (convert(time(3), qs.last_execution_time))) as ca(lastexec_time) -- Used to assess the performance of the convert function
where not exists (select 1 from #tblBlackouts B where convert(time(3), ca.lastexec_time) between B.start_time and B.end_time)

Alternatives Considered

Additional Context

  • I wonder if this blackout window should spread through all the collectors or only some of them…
  • Can a collector run during blackout windows with zero rows (thank to this fix in the where clause)? Or is a fix in the collect.scheduled_master_collector is required to correctly set config.collection_schedule.next_run_time?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions