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: ...@@ -12,11 +12,19 @@ spec:
resourceValues: [1, 2, 3, 4, 5] resourceValues: [1, 2, 3, 4, 5]
slos: slos:
- sloType: "lag trend" - sloType: "lag trend"
threshold: 2000
prometheusUrl: "http://prometheus-operated:9090" prometheusUrl: "http://prometheus-operated:9090"
externalSloUrl: "http://localhost:80/evaluate-slope"
offset: 0 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: execution:
strategy: "LinearSearch" strategy: "LinearSearch"
duration: 300 # in seconds duration: 300 # in seconds
......
...@@ -62,11 +62,9 @@ class BenchmarkExecution : KubernetesResource { ...@@ -62,11 +62,9 @@ class BenchmarkExecution : KubernetesResource {
@RegisterForReflection @RegisterForReflection
class Slo : KubernetesResource { class Slo : KubernetesResource {
lateinit var sloType: String lateinit var sloType: String
var threshold by Delegates.notNull<Int>()
lateinit var prometheusUrl: String lateinit var prometheusUrl: String
lateinit var externalSloUrl: String
var offset by Delegates.notNull<Int>() var offset by Delegates.notNull<Int>()
var warmup by Delegates.notNull<Int>() lateinit var properties: MutableMap<String, String>
} }
/** /**
......
...@@ -64,9 +64,8 @@ class AnalysisExecutor( ...@@ -64,9 +64,8 @@ class AnalysisExecutor(
val sloChecker = SloCheckerFactory().create( val sloChecker = SloCheckerFactory().create(
sloType = slo.sloType, sloType = slo.sloType,
externalSlopeURL = slo.externalSloUrl, properties = slo.properties,
threshold = slo.threshold, load = load
warmup = slo.warmup
) )
result = sloChecker.evaluate(prometheusData) result = sloChecker.evaluate(prometheusData)
......
package theodolite.evaluation package theodolite.evaluation
import theodolite.util.LoadDimension
/** /**
* Factory used to potentially create different [SloChecker]s. * Factory used to potentially create different [SloChecker]s.
* Supports: lag type. * Supports: lag type.
...@@ -20,16 +22,28 @@ class SloCheckerFactory { ...@@ -20,16 +22,28 @@ class SloCheckerFactory {
*/ */
fun create( fun create(
sloType: String, sloType: String,
externalSlopeURL: String, properties: MutableMap<String, String>,
threshold: Int, load: LoadDimension
warmup: Int
): SloChecker { ): SloChecker {
return when (sloType) { return when (sloType) {
"lag trend" -> ExternalSloChecker( "lag trend" -> ExternalSloChecker(
externalSlopeURL = externalSlopeURL, externalSlopeURL = properties["externalSloUrl"] ?: throw IllegalArgumentException("externalSloUrl expected"),
threshold = threshold, threshold = properties["threshold"]?.toInt() ?: throw IllegalArgumentException("threshold expected"),
warmup = warmup 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.") 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