Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions docs/resources/kibana_slo.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,41 @@ resource "elasticstack_kibana_slo" "custom_metric" {
timeslice_window = "5m"
}

}

//Available from 8.12.0
resource "elasticstack_kibana_slo" "timeslice_metric" {
name = "timeslice metric"
description = "timeslice metric"

timeslice_metric_indicator {
index = "my-index"
timestamp_field = "@timestamp"
metric {
metrics {
name = "A"
aggregation = "sum"
field = "latency"
}
equation = "A"
comparator = "GT"
threshold = 100
}
}

time_window {
duration = "7d"
type = "rolling"
}

budgeting_method = "timeslices"

objective {
target = 0.95
timeslice_target = 0.95
timeslice_window = "5m"
}

}
```

Expand All @@ -216,6 +251,7 @@ resource "elasticstack_kibana_slo" "custom_metric" {
- `slo_id` (String) An ID (8 and 36 characters). If omitted, a UUIDv1 will be generated server-side.
- `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used.
- `tags` (List of String) The tags for the SLO.
- `timeslice_metric_indicator` (Block List, Max: 1) Defines a timeslice metric indicator for SLO. (see [below for nested schema](#nestedblock--timeslice_metric_indicator))

### Read-Only

Expand Down Expand Up @@ -405,6 +441,44 @@ Optional:
- `frequency` (String)
- `sync_delay` (String)


<a id="nestedblock--timeslice_metric_indicator"></a>
### Nested Schema for `timeslice_metric_indicator`

Required:

- `index` (String)
- `metric` (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--timeslice_metric_indicator--metric))
- `timestamp_field` (String)

Optional:

- `filter` (String)

<a id="nestedblock--timeslice_metric_indicator--metric"></a>
### Nested Schema for `timeslice_metric_indicator.metric`

Required:

- `comparator` (String)
- `equation` (String)
- `metrics` (Block List, Min: 1) (see [below for nested schema](#nestedblock--timeslice_metric_indicator--metric--metrics))
- `threshold` (Number)

<a id="nestedblock--timeslice_metric_indicator--metric--metrics"></a>
### Nested Schema for `timeslice_metric_indicator.metric.metrics`

Required:

- `aggregation` (String) The aggregation type for this metric. One of: sum, avg, min, max, value_count, percentile, doc_count. Determines which other fields are required:
- `name` (String) The unique name for this metric. Used as a variable in the equation field.

Optional:

- `field` (String) Field to aggregate. Required for aggregations: sum, avg, min, max, value_count, percentile. Must NOT be set for doc_count.
- `filter` (String) Optional KQL filter for this metric. Supported for all aggregations except doc_count.
- `percentile` (Number) Percentile value (e.g., 99). Required if aggregation is 'percentile'. Must NOT be set for other aggregations.

## Import

Import is supported using the following syntax:
Expand Down
35 changes: 35 additions & 0 deletions examples/resources/elasticstack_kibana_slo/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,38 @@ resource "elasticstack_kibana_slo" "custom_metric" {
}

}

//Available from 8.12.0
resource "elasticstack_kibana_slo" "timeslice_metric" {
name = "timeslice metric"
description = "timeslice metric"

timeslice_metric_indicator {
index = "my-index"
timestamp_field = "@timestamp"
metric {
metrics {
name = "A"
aggregation = "sum"
field = "latency"
}
equation = "A"
comparator = "GT"
threshold = 100
}
}

time_window {
duration = "7d"
type = "rolling"
}

budgeting_method = "timeslices"

objective {
target = 0.95
timeslice_target = 0.95
timeslice_window = "5m"
}

}
12 changes: 12 additions & 0 deletions generated/slo-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,18 @@ components:
description: List of metrics with their name, aggregation type, and field.
type: array
items:
discriminator:
propertyName: aggregation
mapping:
percentile: '#/components/schemas/timeslice_metric_percentile_metric'
doc_count: '#/components/schemas/timeslice_metric_doc_count_metric'
sum: '#/components/schemas/timeslice_metric_basic_metric_with_field'
avg: '#/components/schemas/timeslice_metric_basic_metric_with_field'
min: '#/components/schemas/timeslice_metric_basic_metric_with_field'
max: '#/components/schemas/timeslice_metric_basic_metric_with_field'
std_deviation: '#/components/schemas/timeslice_metric_basic_metric_with_field'
last_value: '#/components/schemas/timeslice_metric_basic_metric_with_field'
cardinality: '#/components/schemas/timeslice_metric_basic_metric_with_field'
anyOf:
- $ref: '#/components/schemas/timeslice_metric_basic_metric_with_field'
- $ref: '#/components/schemas/timeslice_metric_percentile_metric'
Expand Down
14 changes: 13 additions & 1 deletion generated/slo/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1702,9 +1702,21 @@ components:
type: object
indicator_properties_timeslice_metric_params_metric_metrics_inner:
anyOf:
- $ref: '#/components/schemas/timeslice_metric_basic_metric_with_field'
- $ref: '#/components/schemas/timeslice_metric_percentile_metric'
- $ref: '#/components/schemas/timeslice_metric_basic_metric_with_field'
- $ref: '#/components/schemas/timeslice_metric_doc_count_metric'
discriminator:
mapping:
percentile: '#/components/schemas/timeslice_metric_percentile_metric'
doc_count: '#/components/schemas/timeslice_metric_doc_count_metric'
sum: '#/components/schemas/timeslice_metric_basic_metric_with_field'
avg: '#/components/schemas/timeslice_metric_basic_metric_with_field'
min: '#/components/schemas/timeslice_metric_basic_metric_with_field'
max: '#/components/schemas/timeslice_metric_basic_metric_with_field'
std_deviation: '#/components/schemas/timeslice_metric_basic_metric_with_field'
last_value: '#/components/schemas/timeslice_metric_basic_metric_with_field'
cardinality: '#/components/schemas/timeslice_metric_basic_metric_with_field'
propertyName: aggregation
indicator_properties_timeslice_metric_params_metric:
description: |
An object defining the metrics, equation, and threshold to determine if it's a good slice or not
Expand Down

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

3 changes: 3 additions & 0 deletions internal/clients/kibana/slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ func responseIndicatorToCreateSloRequestIndicator(s slo.SloResponseIndicator) (s
case *slo.IndicatorPropertiesHistogram:
ret.IndicatorPropertiesHistogram = ind

case *slo.IndicatorPropertiesTimesliceMetric:
ret.IndicatorPropertiesTimesliceMetric = ind

default:
return ret, fmt.Errorf("unknown indicator type: %T", ind)
}
Expand Down
Loading
Loading