Skip to content

Commit

Permalink
Merge pull request #28 from instana/allow_1m_granularity_for_smart_al…
Browse files Browse the repository at this point in the history
…erts

Allow 1m granularity for smart alert resources
  • Loading branch information
parekh-raj authored Mar 3, 2025
2 parents 03b4052 + be8907a commit 1dcbf08
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion instana/resource-application-alert-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ var (
Type: schema.TypeInt,
Optional: true,
Default: restapi.Granularity600000,
ValidateFunc: validation.IntInSlice(restapi.SupportedGranularities.ToIntSlice()),
ValidateFunc: validation.IntInSlice(restapi.SupportedSmartAlertGranularities.ToIntSlice()),
Description: "The evaluation granularity used for detection of violations of the defined threshold. In other words, it defines the size of the tumbling window used",
}
applicationAlertConfigSchemaIncludeInternal = &schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion instana/resource-infra-alert-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ var (
Type: schema.TypeInt,
Optional: true,
Default: restapi.Granularity600000,
ValidateFunc: validation.IntInSlice(restapi.SupportedGranularities.ToIntSlice()),
ValidateFunc: validation.IntInSlice(restapi.SupportedSmartAlertGranularities.ToIntSlice()),
Description: "The evaluation granularity used for detection of violations of the defined threshold. In other words, it defines the size of the tumbling window used",
}
infraAlertConfigSchemaTimeThreshold = &schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion instana/resource-website-alert-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var (
Type: schema.TypeInt,
Optional: true,
Default: restapi.Granularity600000,
ValidateFunc: validation.IntInSlice(restapi.SupportedGranularities.ToIntSlice()),
ValidateFunc: validation.IntInSlice(restapi.SupportedSmartAlertGranularities.ToIntSlice()),
Description: "The evaluation granularity used for detection of violations of the defined threshold. In other words, it defines the size of the tumbling window used",
}
websiteAlertConfigSchemaName = &schema.Schema{
Expand Down
16 changes: 9 additions & 7 deletions instana/restapi/granularity.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ func (granularities Granularities) ToIntSlice() []int {
}

const (
//Granularity300000 constant value for granularity of 30sec
//Granularity60000 constant value for granularity of 1min(60 sec)
Granularity60000 = Granularity(60000)
//Granularity300000 constant value for granularity of 5min(300 sec)
Granularity300000 = Granularity(300000)
//Granularity600000 constant value for granularity of 1min
//Granularity600000 constant value for granularity of 10min(600 sec)
Granularity600000 = Granularity(600000)
//Granularity900000 constant value for granularity of 1min 30sec
//Granularity900000 constant value for granularity of 15min(900 sec)
Granularity900000 = Granularity(900000)
//Granularity1200000 constant value for granularity of 2min
//Granularity1200000 constant value for granularity of 20min(1200 sec)
Granularity1200000 = Granularity(1200000)
//Granularity1800000 constant value for granularity of 3min
//Granularity1800000 constant value for granularity of 30min(1800 sec)
Granularity1800000 = Granularity(1800000)
)

// SupportedGranularities list of all supported Granularities
var SupportedGranularities = Granularities{Granularity300000, Granularity600000, Granularity900000, Granularity1200000, Granularity1800000}
// SupportedSmartAlertGranularities list of all supported Granularities
var SupportedSmartAlertGranularities = Granularities{Granularity60000, Granularity300000, Granularity600000, Granularity900000, Granularity1200000, Granularity1800000}
4 changes: 2 additions & 2 deletions instana/restapi/granularity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import (
)

func TestShouldReturnSupportedGranularitiesAsIntSlice(t *testing.T) {
expected := []int{300000, 600000, 900000, 1200000, 1800000}
require.Equal(t, expected, SupportedGranularities.ToIntSlice())
expected := []int{60000, 300000, 600000, 900000, 1200000, 1800000}
require.Equal(t, expected, SupportedSmartAlertGranularities.ToIntSlice())
}

0 comments on commit 1dcbf08

Please sign in to comment.