Skip to content
Snippets Groups Projects
Commit 07125382 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

minor code changes in evaluation related parts

parent f2e26bd0
No related branches found
No related tags found
1 merge request!180Make the analysis of experiments more flexible
......@@ -60,9 +60,6 @@ spec:
prometheusUrl:
description: Connection string for Promehteus.
type: string
query:
description: The prometheus query string
type: string
offset:
description: Hours by which the start and end timestamp will be shifted (for different timezones).
type: integer
......
......@@ -68,9 +68,6 @@ spec:
prometheusUrl:
description: Connection string for Promehteus.
type: string
query:
description: The prometheus query string
type: string
offset:
description: Hours by which the start and end timestamp will be shifted (for different timezones).
type: integer
......
......@@ -63,7 +63,6 @@ class BenchmarkExecution : KubernetesResource {
class Slo : KubernetesResource {
lateinit var sloType: String
lateinit var prometheusUrl: String
lateinit var query: String
var offset by Delegates.notNull<Int>()
lateinit var properties: MutableMap<String, String>
}
......
......@@ -12,7 +12,6 @@ import java.util.*
import java.util.regex.Pattern
private val logger = KotlinLogging.logger {}
private val RECORD_LAG_QUERY = "sum by(group)(kafka_consumergroup_group_lag >= 0)"
/**
* Contains the analysis. Fetches a metric from Prometheus, documents it, and evaluates it.
......
......@@ -43,25 +43,25 @@ class SloCheckerFactory {
properties: MutableMap<String, String>,
load: LoadDimension
): SloChecker {
return when (sloType) {
"lag trend" -> ExternalSloChecker(
return when (sloType.toLowerCase()) {
SloTypes.LAG_TREND.value, SloTypes.DROPPED_RECORDS.value -> ExternalSloChecker(
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" -> {
SloTypes.LAG_TREND_PERCENTAGE.value, SloTypes.DROPPED_RECORDS_PERCENTAGE.value -> {
if (!properties["loadType"].equals("NumSensors")) {
throw IllegalArgumentException("Percent Threshold is only allowed with load type NumSensors")
}
var thresholdPercent =
val thresholdPercent =
properties["percent"]?.toDouble()
?: throw IllegalArgumentException("percent for threshold expected")
if (thresholdPercent < 0.0 || thresholdPercent > 1.0) {
throw IllegalArgumentException("Threshold percent need to be an Double in the range between 0.0 and 1.0 (inclusive)")
}
// cast to int, as rounding is not really necessary
var threshold = (load.get() * thresholdPercent).toInt()
val threshold = (load.get() * thresholdPercent).toInt()
ExternalSloChecker(
externalSlopeURL = properties["externalSloUrl"]
......
package theodolite.evaluation
import theodolite.util.InvalidPatcherConfigurationException
import theodolite.util.TheodoliteConfig
import javax.inject.Inject
class SloConfigHandler {
import javax.enterprise.context.ApplicationScoped
@ApplicationScoped
class SloConfigHandler() {
companion object {
@Inject
lateinit var config: TheodoliteConfig
fun getQueryString(sloType: String): String {
return when (sloType){
"Lag Trend" -> config.PROM_RECORD_LAG_QUERY
"Dropped Records" -> config.PROM_DROPPED_RECORDS_QUERY
return when (sloType.toLowerCase()) {
SloTypes.LAG_TREND.value, SloTypes.LAG_TREND_PERCENTAGE.value -> "sum by(group)(kafka_consumergroup_group_lag >= 0)"
SloTypes.DROPPED_RECORDS.value, SloTypes.DROPPED_RECORDS_PERCENTAGE.value -> "sum by(job) (kafka_streams_stream_task_metrics_dropped_records_total>=0)"
else -> throw InvalidPatcherConfigurationException("Could not find Prometheus query string for slo type $sloType")
}
}
......
package theodolite.evaluation
enum class SloTypes(val value: String) {
LAG_TREND("lag trend"),
LAG_TREND_PERCENTAGE("lag trend percentage"),
DROPPED_RECORDS("dropped records"),
DROPPED_RECORDS_PERCENTAGE("dropped records percentage")
}
\ No newline at end of file
......@@ -6,4 +6,4 @@ quarkus.native.additional-build-args=\
--report-unsupported-elements-at-runtime
prom.record.lag.query="sum by(group)(kafka_consumergroup_group_lag >= 0)"
prom.dropped.records.query="todo"
prom.dropped.records.query="sum by(job) (kafka_streams_stream_task_metrics_dropped_records_total>=0)"
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