Skip to content

Flawed logic in calculation of top query metrics collection window #44162

@sv-splunk

Description

@sv-splunk

Component(s)

No response

Describe the issue you're reporting

Details of Bug

Based on current implementation the EffectiveLookbackTime is calculated as 2 x cfg.ControllerConfig.CollectionInterval which is wrong.

Below are the default values,

ControllerConfig's CollectionInterval = 10 * time.Second
TopQueryCollection's CollectionInterval = 1 minute.

With the existing logic the EffectiveLookbackTime will be calculated as 20 seconds (2 x 10 =20), and this will not cover the previous 1 minute collection window.

To fix the collection window, the logic to determine the window slot needs to be fixed too.
The collection latency (mostly a few milliseconds) is not taken into account when the next check is done. As a result when the top_query is configured to collect at 60 seconds, practically the collection is done only at next cycle after 1 minute (at 1 minute 10 seconds)

Fix Proposal

The logic should have been 2 X TopQueryCollection's CollectionInterval to effectively cover the collection period.

And to determine the window,

current check: if s.lastExecutionTimestamp.Add(s.config.TopQueryCollection.CollectionInterval).After(time.Now()) {...}

proposed fix: if int(math.Ceil(time.Now().Sub(s.lastExecutionTimestamp).Seconds())) < int(s.config.TopQueryCollection.CollectionInterval.Seconds()) {

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions