Skip to content

Commit

Permalink
feat: PC-12978 Add composite examples (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
BSski authored Jun 4, 2024
1 parent 229b8b9 commit 093a01f
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 8 deletions.
51 changes: 47 additions & 4 deletions docs/resources/slo.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "nobl9_service" "this" {
description = "Front page service"
}
resource "nobl9_slo" "this" {
resource "nobl9_slo" "slo_1" {
name = "${nobl9_project.this.name}-latency"
service = nobl9_service.this.name
budgeting_method = "Occurrences"
Expand Down Expand Up @@ -82,11 +82,11 @@ resource "nobl9_slo" "this" {
}
indicator {
name = "test-terraform-prom-agent"
name = "test-n9-terraform-prom-agent"
}
}
resource "nobl9_slo" "this" {
resource "nobl9_slo" "slo_2" {
name = "${nobl9_project.this.name}-ratio"
service = nobl9_service.this.name
budgeting_method = "Occurrences"
Expand Down Expand Up @@ -121,7 +121,7 @@ resource "nobl9_slo" "this" {
}
indicator {
name = "test-terraform-prom-agent"
name = "test-n9-terraform-prom-agent"
}
anomaly_config {
Expand All @@ -138,6 +138,49 @@ resource "nobl9_slo" "this" {
}
}
}
resource "nobl9_slo" "composite_slo" {
name = "${nobl9_project.this.name}-composite"
service = nobl9_service.this.name
budgeting_method = "Occurrences"
project = nobl9_project.this.name
depends_on = [nobl9_slo.slo_1, nobl9_slo.slo_2]
time_window {
unit = "Day"
count = 3
is_rolling = true
}
objective {
display_name = "OK"
name = "tf-objective-1"
target = 0.8
value = 1
composite {
max_delay = "45m"
components {
objectives {
composite_objective {
project = nobl9_slo.slo_1.project
slo = nobl9_slo.slo_1.name
objective = "tf-objective-1"
weight = 0.8
when_delayed = "CountAsGood"
}
composite_objective {
project = nobl9_slo.slo_2.project
slo = nobl9_slo.slo_2.name
objective = "tf-objective-1"
weight = 1.5
when_delayed = "Ignore"
}
}
}
}
}
}
```

<!-- schema generated by tfplugindocs -->
Expand Down
51 changes: 47 additions & 4 deletions examples/resources/nobl9_slo/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "nobl9_service" "this" {
description = "Front page service"
}

resource "nobl9_slo" "this" {
resource "nobl9_slo" "slo_1" {
name = "${nobl9_project.this.name}-latency"
service = nobl9_service.this.name
budgeting_method = "Occurrences"
Expand Down Expand Up @@ -67,11 +67,11 @@ resource "nobl9_slo" "this" {
}

indicator {
name = "test-terraform-prom-agent"
name = "test-n9-terraform-prom-agent"
}
}

resource "nobl9_slo" "this" {
resource "nobl9_slo" "slo_2" {
name = "${nobl9_project.this.name}-ratio"
service = nobl9_service.this.name
budgeting_method = "Occurrences"
Expand Down Expand Up @@ -106,7 +106,7 @@ resource "nobl9_slo" "this" {
}

indicator {
name = "test-terraform-prom-agent"
name = "test-n9-terraform-prom-agent"
}

anomaly_config {
Expand All @@ -123,3 +123,46 @@ resource "nobl9_slo" "this" {
}
}
}

resource "nobl9_slo" "composite_slo" {
name = "${nobl9_project.this.name}-composite"
service = nobl9_service.this.name
budgeting_method = "Occurrences"
project = nobl9_project.this.name

depends_on = [nobl9_slo.slo_1, nobl9_slo.slo_2]

time_window {
unit = "Day"
count = 3
is_rolling = true
}

objective {
display_name = "OK"
name = "tf-objective-1"
target = 0.8
value = 1
composite {
max_delay = "45m"
components {
objectives {
composite_objective {
project = nobl9_slo.slo_1.project
slo = nobl9_slo.slo_1.name
objective = "tf-objective-1"
weight = 0.8
when_delayed = "CountAsGood"
}
composite_objective {
project = nobl9_slo.slo_2.project
slo = nobl9_slo.slo_2.name
objective = "tf-objective-1"
weight = 1.5
when_delayed = "Ignore"
}
}
}
}
}
}

0 comments on commit 093a01f

Please sign in to comment.