Skip to content
Snippets Groups Projects
Commit 2ace35cb authored by Lorenz Boguhn's avatar Lorenz Boguhn
Browse files

Made slo configurable + renaming of SLO to slo

parent c4bc3ce7
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!96Handle shutdown,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
...@@ -14,7 +14,7 @@ logger = logging.getLogger("Api") ...@@ -14,7 +14,7 @@ logger = logging.getLogger("Api")
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
def execute(results, threshold): def execute(results, threshold, warmup):
d = [] d = []
for result in results: for result in results:
group = result['metric']['group'] group = result['metric']['group']
...@@ -26,7 +26,7 @@ def execute(results, threshold): ...@@ -26,7 +26,7 @@ def execute(results, threshold):
logger.info(df) logger.info(df)
try: try:
trend_slope = trend_slope_computer.compute(df, 0) trend_slope = trend_slope_computer.compute(df, warmup)
except Exception as e: except Exception as e:
err_msg = 'Computing trend slope failed' err_msg = 'Computing trend slope failed'
logger.exception(err_msg) logger.exception(err_msg)
...@@ -41,4 +41,4 @@ def execute(results, threshold): ...@@ -41,4 +41,4 @@ def execute(results, threshold):
async def evaluate_slope(request: Request): async def evaluate_slope(request: Request):
data = json.loads(await request.body()) data = json.loads(await request.body())
logger.info("Request received") logger.info("Request received")
return execute(data['total_lag'], data['threshold']) return execute(data['total_lag'], data['threshold'],data['warmup'])
...@@ -22,6 +22,10 @@ class BenchmarkExecution { ...@@ -22,6 +22,10 @@ class BenchmarkExecution {
class Slo { class Slo {
lateinit var sloType: String lateinit var sloType: String
var threshold by Delegates.notNull<Int>() 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>()
} }
class LoadDefinition { class LoadDefinition {
......
...@@ -2,6 +2,6 @@ package theodolite.evaluation ...@@ -2,6 +2,6 @@ package theodolite.evaluation
import java.time.Instant import java.time.Instant
interface SLOChecker { interface SloChecker {
fun evaluate(start: Instant, end: Instant): Boolean fun evaluate(start: Instant, end: Instant): Boolean
} }
...@@ -6,17 +6,25 @@ import java.net.ConnectException ...@@ -6,17 +6,25 @@ import java.net.ConnectException
import java.time.Duration import java.time.Duration
import java.time.Instant import java.time.Instant
class SLOCheckerImpl(private val prometheusURL: String, private val threshold: Int, private val offset: Duration) : class SloCheckerImpl(
SLOChecker { private val prometheusURL: String,
private val query: String,
private val externalSlopeURL: String,
private val threshold: Int,
private val offset: Duration,
private val warmup: Int
) :
SloChecker {
override fun evaluate(start: Instant, end: Instant): Boolean { override fun evaluate(start: Instant, end: Instant): Boolean {
var counter = 0 var counter = 0
val metricFetcher = MetricFetcher(prometheusURL = prometheusURL, offset = offset) val metricFetcher = MetricFetcher(prometheusURL = prometheusURL, offset = offset)
val fetchedData = metricFetcher.fetchMetric(start, end, "sum by(group)(kafka_consumergroup_group_lag >= 0)") val fetchedData = metricFetcher.fetchMetric(start, end, query)
val data = Gson().toJson(mapOf("total_lag" to fetchedData.data?.result, "threshold" to threshold)) val data =
Gson().toJson(mapOf("total_lag" to fetchedData.data?.result, "threshold" to threshold, "warmup" to warmup))
while (counter < 2) { while (counter < 2) {
val result = post("http://127.0.0.1:8000/evaluate-slope", data = data, timeout = 60.0) val result = post(externalSlopeURL, data = data, timeout = 60.0)
if (result.statusCode != 200) { if (result.statusCode != 200) {
counter++ counter++
} else { } else {
......
...@@ -2,6 +2,7 @@ package theodolite.execution ...@@ -2,6 +2,7 @@ package theodolite.execution
import mu.KotlinLogging import mu.KotlinLogging
import theodolite.benchmark.Benchmark import theodolite.benchmark.Benchmark
import theodolite.benchmark.BenchmarkExecution
import theodolite.util.ConfigurationOverride import theodolite.util.ConfigurationOverride
import theodolite.util.LoadDimension import theodolite.util.LoadDimension
import theodolite.util.Resource import theodolite.util.Resource
...@@ -22,7 +23,8 @@ abstract class BenchmarkExecutor( ...@@ -22,7 +23,8 @@ abstract class BenchmarkExecutor(
val benchmark: Benchmark, val benchmark: Benchmark,
val results: Results, val results: Results,
val executionDuration: Duration, val executionDuration: Duration,
configurationOverrides: List<ConfigurationOverride> configurationOverrides: List<ConfigurationOverride>,
val slo: BenchmarkExecution.Slo
) { ) {
/** /**
......
...@@ -2,7 +2,8 @@ package theodolite.execution ...@@ -2,7 +2,8 @@ package theodolite.execution
import mu.KotlinLogging import mu.KotlinLogging
import theodolite.benchmark.Benchmark import theodolite.benchmark.Benchmark
import theodolite.evaluation.SLOCheckerImpl import theodolite.benchmark.BenchmarkExecution
import theodolite.evaluation.SloCheckerImpl
import theodolite.util.ConfigurationOverride import theodolite.util.ConfigurationOverride
import theodolite.util.LoadDimension import theodolite.util.LoadDimension
import theodolite.util.Resource import theodolite.util.Resource
...@@ -16,8 +17,9 @@ class BenchmarkExecutorImpl( ...@@ -16,8 +17,9 @@ class BenchmarkExecutorImpl(
benchmark: Benchmark, benchmark: Benchmark,
results: Results, results: Results,
executionDuration: Duration, executionDuration: Duration,
private val configurationOverrides: List<ConfigurationOverride> private val configurationOverrides: List<ConfigurationOverride>,
) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides) { slo: BenchmarkExecution.Slo
) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo) {
//TODO ADD SHUTDOWN HOOK HERE //TODO ADD SHUTDOWN HOOK HERE
override fun runExperiment(load: LoadDimension, res: Resource): Boolean { override fun runExperiment(load: LoadDimension, res: Resource): Boolean {
val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides)
...@@ -28,7 +30,14 @@ class BenchmarkExecutorImpl( ...@@ -28,7 +30,14 @@ class BenchmarkExecutorImpl(
var result = false var result = false
try { try {
result = SLOCheckerImpl("http://localhost:32656", 100, offset = Duration.ofSeconds(0)) result = SloCheckerImpl(
slo.prometheusUrl,
"sum by(group)(kafka_consumergroup_group_lag >= 0)",
slo.externalSloUrl,
slo.threshold,
Duration.ofHours(slo.offset.toLong()),
slo.warmup
)
.evaluate( .evaluate(
Instant.now().minus(executionDuration), Instant.now().minus(executionDuration),
Instant.now() Instant.now()
......
...@@ -20,7 +20,14 @@ class TheodoliteExecutor( ...@@ -20,7 +20,14 @@ class TheodoliteExecutor(
val strategyFactory = StrategyFactory() val strategyFactory = StrategyFactory()
val executionDuration = Duration.ofSeconds(config.execution.duration) val executionDuration = Duration.ofSeconds(config.execution.duration)
val executor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, config.configOverrides) val executor =
BenchmarkExecutorImpl(
kubernetesBenchmark,
results,
executionDuration,
config.configOverrides,
config.slos[0]
)
return Config( return Config(
loads = config.load.loadValues.map { load -> LoadDimension(load, config.load.loadType) }, loads = config.load.loadValues.map { load -> LoadDimension(load, config.load.loadType) },
......
...@@ -11,6 +11,10 @@ resources: ...@@ -11,6 +11,10 @@ resources:
slos: slos:
- sloType: "slo type" - sloType: "slo type"
threshold: 1000 threshold: 1000
prometheusUrl: "http://localhost:32656"
externalSloUrl: "http://127.0.0.1:8000/evaluate-slope"
offset: 0
warmup: 0
execution: execution:
strategy: "LinearSearch" strategy: "LinearSearch"
duration: 60 duration: 60
......
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