Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add anomaly provider interface #5856

Merged
merged 32 commits into from
Sep 13, 2024
Merged

chore: add anomaly provider interface #5856

merged 32 commits into from
Sep 13, 2024

Conversation

srikanthccv
Copy link
Member

@srikanthccv srikanthccv commented Sep 4, 2024

Summary

Part of #5469

This is the main part of the PR. It describes how we arrive at the predicted value using the existing data. Supplementary reading https://about.gitlab.com/blog/2019/07/23/anomaly-detection-using-prometheus/

// anomalyParams is the params for anomaly detection
// prediction = avg(past_period_query) + avg(current_season_query) - avg(past_season_query)
//
//	                  ^                                  ^
//		              |                                  |
//			(rounded value for past peiod)    +      (seasonal growth)
//
// score = abs(value - prediction) / stddev (current_season_query)
type anomalyQueryParams struct {
	// CurrentPeriodQuery is the query range params for period user is looking at or eval window
	// Example: (now-5m, now), (now-30m, now), (now-1h, now)
	// The results obtained from this query are used to compare with predicted values
	// and to detect anomalies
	CurrentPeriodQuery *v3.QueryRangeParamsV3
	// PastPeriodQuery is the query range params for past seasonal period
	// Example: For weekly seasonality, (now-1w-4h-5m, now-1w)
	//        : For daily seasonality, (now-1d-2h-5m, now-1d)
	//        : For hourly seasonality, (now-1h-30m-5m, now-1h)
	PastPeriodQuery *v3.QueryRangeParamsV3
	// CurrentSeasonQuery is the query range params for current period (seasonal)
	// Example: For weekly seasonality, this is the query range params for the (now-1w-5m, now)
	//        : For daily seasonality, this is the query range params for the (now-1d-5m, now)
	//        : For hourly seasonality, this is the query range params for the (now-1h-5m, now)
	CurrentSeasonQuery *v3.QueryRangeParamsV3
	// PastSeasonQuery is the query range params for past seasonal period to the current season
	// Example: For weekly seasonality, this is the query range params for the (now-2w-5m, now-1w)
	//        : For daily seasonality, this is the query range params for the (now-2d-5m, now-1d)
	//        : For hourly seasonality, this is the query range params for the (now-2h-5m, now-1h)
	PastSeasonQuery *v3.QueryRangeParamsV3
}

@github-actions github-actions bot added the chore label Sep 4, 2024
Base automatically changed from introduce-base-rule to develop September 11, 2024 04:27
Copy link
Member

@nityanandagohain nityanandagohain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments.

ee/query-service/anomaly/params.go Show resolved Hide resolved
ee/query-service/anomaly/params.go Show resolved Hide resolved
ee/query-service/anomaly/params.go Outdated Show resolved Hide resolved
ee/query-service/anomaly/seasonal.go Show resolved Hide resolved
Copy link
Member

@nityanandagohain nityanandagohain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to start with.

@srikanthccv srikanthccv merged commit 3596f73 into develop Sep 13, 2024
12 of 13 checks passed
@srikanthccv srikanthccv deleted the anomaly-provider branch September 13, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants