Skip to content

Commit

Permalink
address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aschepis committed Dec 11, 2024
1 parent 9a8a115 commit 117fb45
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 29 deletions.
2 changes: 1 addition & 1 deletion chronosphere/intschema/generateintschema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var sharedSchemaTypeNames = map[*schema.Schema]string{
tfschema.TraceTagFilterSchema: "TraceTagFilter",
tfschema.ValueMappingsSchema: "ValueMappings",
tfschema.SLOAdditionalPromQLFilters: "SLOAdditionalPromQLFilters",
tfschema.MonitorSignalGrouping: "MonitorSignalGrouping",
tfschema.SignalGrouping: "SignalGrouping",
}

// Add shared element references here to generate shared types. Usually we
Expand Down
2 changes: 1 addition & 1 deletion chronosphere/intschema/monitor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions chronosphere/intschema/shared_schemas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions chronosphere/intschema/slo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions chronosphere/resource_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func monitorConditionsFromModel(
}

func monitorSignalGroupingToModel(
g *intschema.MonitorSignalGrouping,
g *intschema.SignalGrouping,
) *models.MonitorSignalGrouping {
if g == nil {
return nil
Expand All @@ -428,11 +428,11 @@ func monitorSignalGroupingToModel(

func monitorSignalGroupingFromModel(
g *models.MonitorSignalGrouping,
) *intschema.MonitorSignalGrouping {
) *intschema.SignalGrouping {
if g == nil {
return nil
}
return &intschema.MonitorSignalGrouping{
return &intschema.SignalGrouping{
LabelNames: g.LabelNames,
SignalPerSeries: g.SignalPerSeries,
}
Expand Down
6 changes: 3 additions & 3 deletions chronosphere/resource_slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func reportingWindowsFromModel(windows []*models.DefinitionTimeWindow) []intsche

// TODO: once SLOs have been promoted to v1 this can be removed and monitorSignalGroupingToModel can be used.
func unstableMonitorSignalGroupingToModel(
g *intschema.MonitorSignalGrouping,
g *intschema.SignalGrouping,
) *models.MonitorSignalGrouping {
if g == nil {
return nil
Expand All @@ -241,11 +241,11 @@ func unstableMonitorSignalGroupingToModel(
// TODO: once SLOs have been promoted to v1 this can be removed and monitorSignalGroupingFromModel can be used.
func unstableMonitorSignalGroupingFromModel(
g *models.MonitorSignalGrouping,
) *intschema.MonitorSignalGrouping {
) *intschema.SignalGrouping {
if g == nil {
return nil
}
return &intschema.MonitorSignalGrouping{
return &intschema.SignalGrouping{
LabelNames: g.LabelNames,
SignalPerSeries: g.SignalPerSeries,
}
Expand Down
2 changes: 1 addition & 1 deletion chronosphere/tfschema/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var MatcherListSchema = &schema.Schema{
}

// Used by both Monitor and SLO
var MonitorSignalGrouping = &schema.Schema{
var SignalGrouping = &schema.Schema{
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Expand Down
2 changes: 1 addition & 1 deletion chronosphere/tfschema/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var Monitor = map[string]*schema.Schema{
},
},
},
"signal_grouping": MonitorSignalGrouping,
"signal_grouping": SignalGrouping,
"series_conditions": {
Type: schema.TypeList,
Required: true,
Expand Down
2 changes: 1 addition & 1 deletion chronosphere/tfschema/slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var Slo = map[string]*schema.Schema{
Schema: SloDefinition,
},
},
"signal_grouping": MonitorSignalGrouping,
"signal_grouping": SignalGrouping,
"annotations": {
Type: schema.TypeMap,
Optional: true,
Expand Down
29 changes: 26 additions & 3 deletions examples/slo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ resource "chronosphere_slo" "slo" {
}
}

resource "chronosphere_slo" "slo_with_signal_grouping" {
name = "SLO With Signal Grouping"
resource "chronosphere_slo" "slo_with_signal_grouping_signal_per_series" {
name = "SLO With Signal Grouping (Signal per series)"
collection_id = chronosphere_collection.c.id
notification_policy_id = chronosphere_notification_policy.np.id

signal_grouping {
label_names = ["label1", "label2"]
signal_per_series = true
}

Expand All @@ -67,3 +66,27 @@ resource "chronosphere_slo" "slo_with_signal_grouping" {
}
}
}

resource "chronosphere_slo" "slo_with_signal_grouping_labels" {
name = "SLO With Signal Grouping (Labels"
collection_id = chronosphere_collection.c.id
notification_policy_id = chronosphere_notification_policy.np.id

signal_grouping {
label_names = ["label1", "label2"]
}

definition {
objective = 99.95
reporting_windows {
duration = "28d"
}
}

sli {
custom_indicator {
bad_query_template = "sum(rate(http_request_duration_seconds_count{error=\"true\"}[{{ .Window }}]))"
total_query_template = "sum(rate(http_request_duration_seconds_count[{{ .Window }}]))"
}
}
}

0 comments on commit 117fb45

Please sign in to comment.