Skip to content
Snippets Groups Projects
Commit cd70579e authored by Björn Vonheiden's avatar Björn Vonheiden
Browse files

Use the properties of the slo checker and add lag trend percent

Specific slo checker should be defined with a propertie map to be more generic.
Further add a lag trend percent slo, which use a percentage of the defined load
to compute the allowed threshold.
parent a9035af8
No related branches found
No related tags found
1 merge request!172Use the properties of the slo checker and add lag trend percent
......@@ -12,11 +12,19 @@ spec:
resourceValues: [1, 2, 3, 4, 5]
slos:
- sloType: "lag trend"
threshold: 2000
prometheusUrl: "http://prometheus-operated:9090"
externalSloUrl: "http://localhost:80/evaluate-slope"
offset: 0
warmup: 60 # in seconds
properties:
threshold: 2000
externalSloUrl: "http://localhost:80/evaluate-slope"
warmup: 60 # in seconds
# - sloType: "lag trend percent"
# prometheusUrl: "http://localhost:9090"
# offset: 0
# properties:
# percent: 5
# externalSloUrl: "http://localhost:80/evaluate-slope"
# warmup: 60 # in seconds
execution:
strategy: "LinearSearch"
duration: 300 # in seconds
......
......@@ -62,11 +62,9 @@ class BenchmarkExecution : KubernetesResource {
@RegisterForReflection
class Slo : KubernetesResource {
lateinit var sloType: String
var threshold by Delegates.notNull<Int>()
lateinit var prometheusUrl: String
lateinit var externalSloUrl: String
var offset by Delegates.notNull<Int>()
var warmup by Delegates.notNull<Int>()
lateinit var properties: MutableMap<String, String>
}
/**
......
......@@ -64,9 +64,8 @@ class AnalysisExecutor(
val sloChecker = SloCheckerFactory().create(
sloType = slo.sloType,
externalSlopeURL = slo.externalSloUrl,
threshold = slo.threshold,
warmup = slo.warmup
properties = slo.properties,
load = load
)
result = sloChecker.evaluate(prometheusData)
......
package theodolite.evaluation
import theodolite.util.LoadDimension
/**
* Factory used to potentially create different [SloChecker]s.
* Supports: lag type.
......@@ -20,16 +22,28 @@ class SloCheckerFactory {
*/
fun create(
sloType: String,
externalSlopeURL: String,
threshold: Int,
warmup: Int
properties: MutableMap<String, String>,
load: LoadDimension
): SloChecker {
return when (sloType) {
"lag trend" -> ExternalSloChecker(
externalSlopeURL = externalSlopeURL,
threshold = threshold,
warmup = warmup
externalSlopeURL = properties["externalSloUrl"] ?: throw IllegalArgumentException("externalSloUrl expected"),
threshold = properties["threshold"]?.toInt() ?: throw IllegalArgumentException("threshold expected"),
warmup = properties["warmup"]?.toInt() ?: throw IllegalArgumentException("warmup expected")
)
"lag trend percent" -> {
var thresholdPercent = properties["percent"]?.toInt() ?: throw IllegalArgumentException("percent for threshold expected")
if (thresholdPercent < 0 || thresholdPercent > 100) {
throw IllegalArgumentException("Threshold percent need to be an Int in the range between 0 and 100 (inclusive)")
}
var threshold = (load.get() / 100.0 * thresholdPercent).toInt()
ExternalSloChecker(
externalSlopeURL = properties["externalSloUrl"] ?: throw IllegalArgumentException("externalSloUrl expected"),
threshold = threshold,
warmup = properties["warmup"]?.toInt() ?: throw IllegalArgumentException("warmup expected")
)
}
else -> throw IllegalArgumentException("Slotype $sloType not found.")
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment