The Provider treats the literal value of 0 as nil, and therefore doesn't pass it through to the Kibana API, resulting in a status code 400.
To Reproduce
Apply this Terraform with TF_LOG="DEBUG":
resource "elasticstack_kibana_slo" "xp_upjet_ext_api_duration" {
name = "[Crossplane] Managed Resource External API Request Duration"
description = "Measures in seconds how long it takes a Cloud SDK call to complete. This measures the time it takes for Crossplane Provider pods to complete external API requests, for example, the provider-aws-ec2 talks to AWS' EC2 API."
slo_id = "xp_upjet_ext_api_duration"
histogram_custom_indicator {
index = "metrics-*:metrics-*"
good {
field = "prometheus.upjet_resource_ext_api_duration.histogram"
aggregation = "range"
from = 0
# 10s
to = 10
}
total {
field = "prometheus.upjet_resource_ext_api_duration.histogram"
aggregation = "range"
from = 0
to = 999999
}
filter = "prometheus.upjet_resource_ext_api_duration.histogram: *"
timestamp_field = "@timestamp"
}
time_window {
duration = "30d"
type = "rolling"
}
budgeting_method = "occurrences"
objective {
target = 0.99
}
group_by = "orchestrator.cluster.name"
tags = ["crossplane", "infra-mki"]
}
Note the 400 status code:
"statusCode": 400,
"error": "Bad Request",
"message": "Invalid value undefined supplied to :
<TRUNCATED>
{ field: string, aggregation: \"range\", from: number, to: number }/from: number"
Describe the bug
The Provider treats the literal value of
0
asnil
, and therefore doesn't pass it through to the Kibana API, resulting in a status code 400.To Reproduce Apply this Terraform with
TF_LOG="DEBUG"
:Note the 400 status code:
I'm 99% sure the problem rests with this function: https://github.com/elastic/terraform-provider-elasticstack/blob/559478b04ae32152f4ed628d1868bb9964915c7e/internal/kibana/slo.go#L452-L458
Which is used when reading the schema here: https://github.com/elastic/terraform-provider-elasticstack/blob/559478b04ae32152f4ed628d1868bb9964915c7e/internal/kibana/slo.go#L529-L539
Expected behavior We should be able to specify a
range
starting from0
.Debug output
Screenshots
Versions (please complete the following information):
Additional context Add any other context about the problem here.