-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from instana/API_implementation_Infra_Alert_Co…
…nfig Add API implementation for Infra Alert Config
- Loading branch information
Showing
8 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package restapi | ||
|
||
const InfraAlertConfigResourcePath = EventSettingsBasePath + "/infra-alert-configs" | ||
|
||
type InfraAlertConfig struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
TagFilterExpression *TagFilter `json:"tagFilterExpression"` | ||
GroupBy []string `json:"groupBy"` | ||
AlertChannelIDs []string `json:"alertChannelIds"` | ||
Granularity Granularity `json:"granularity"` | ||
TimeThreshold InfraTimeThreshold `json:"timeThreshold"` | ||
CustomerPayloadFields []CustomPayloadField[any] `json:"customPayloadFields"` | ||
Rules []RuleWithThreshold[InfraAlertRule] `json:"rules"` | ||
} | ||
|
||
func (config *InfraAlertConfig) GetIDForResourcePath() string { | ||
return config.ID | ||
} | ||
|
||
func (config *InfraAlertConfig) GetCustomerPayloadFields() []CustomPayloadField[any] { | ||
return config.CustomerPayloadFields | ||
} | ||
|
||
func (config *InfraAlertConfig) SetCustomerPayloadFields(fields []CustomPayloadField[any]) { | ||
config.CustomerPayloadFields = fields | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package restapi | ||
|
||
type InfraAlertRule struct { | ||
AlertType string `json:"alertType"` | ||
MetricName string `json:"metricName"` | ||
EntityType string `json:"entityType"` | ||
Aggregation *Aggregation `json:"aggregation"` | ||
CrossSeriesAggregation *Aggregation `json:"crossSeriesAggregation"` | ||
Regex bool `json:"regex"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package restapi | ||
|
||
type InfraTimeThreshold struct { | ||
Type string `json:"type"` | ||
TimeWindow *int64 `json:"timeWindow"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package restapi | ||
|
||
type RuleWithThreshold[R InfraAlertRule | ApplicationAlertRule | WebsiteAlertRule] struct { | ||
ThresholdOperator ThresholdOperator `json:"thresholdOperator"` | ||
Rule R `json:"rule"` | ||
Thresholds map[AlertSeverity]ThresholdRule `json:"thresholds"` | ||
} | ||
|
||
type AlertSeverity string | ||
type AlertSeverities []AlertSeverity | ||
|
||
const ( | ||
WarningSeverity = AlertSeverity("WARNING") | ||
CriticalSeverity = AlertSeverity("CRITICAL") | ||
) | ||
|
||
// SupportedAlertSeverities : will be used as part of validation in a follow-up. | ||
var SupportedAlertSeverities = AlertSeverities{WarningSeverity, CriticalSeverity} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters