add cpu_scale rules
This commit is contained in:
parent
849710db8e
commit
e2cf4d213a
12
cpu_scale
Executable file
12
cpu_scale
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
s6-svc -t /run/s6/services/kapacitor-scale
|
||||
s6-svc -t /run/s6/services/kapacitor
|
||||
sleep 2
|
||||
set -eux
|
||||
|
||||
kapacitor define \
|
||||
-name cpu_scale \
|
||||
-type stream \
|
||||
-tick /data/cpu_scale.tick \
|
||||
-dbrp metrics.default
|
||||
kapacitor reload cpu_scale
|
45
cpu_scale.tick
Normal file
45
cpu_scale.tick
Normal file
@ -0,0 +1,45 @@
|
||||
var cpu_percentile = stream
|
||||
|from()
|
||||
.measurement('docker_cpu')
|
||||
.where(lambda: "cont_image" =~ /sharelatex-web/ AND "cpu" == 'cpu-total')
|
||||
|window()
|
||||
.period(10s)
|
||||
.every(1s)
|
||||
|percentile('usage_percent', 95.0)
|
||||
|log()
|
||||
|
||||
var scale_out = cpu_percentile
|
||||
@scale()
|
||||
.simulate(FALSE)
|
||||
.debug(TRUE)
|
||||
.id('1s33') // web service
|
||||
.when('percentile > 90')
|
||||
.by('current + 2')
|
||||
.min_instances(1)
|
||||
.max_instances(6)
|
||||
.cooldown('10s')
|
||||
|
||||
var scale_in = cpu_percentile
|
||||
@scale()
|
||||
.simulate(FALSE)
|
||||
.debug(TRUE)
|
||||
.id('1s33') // web service
|
||||
.when('percentile < 30')
|
||||
.by('current - 2')
|
||||
.min_instances(1)
|
||||
.max_instances(6)
|
||||
.cooldown('10s')
|
||||
|
||||
scale_out
|
||||
|influxDBOut()
|
||||
.database('metrics')
|
||||
.measurement('autoscaling')
|
||||
.flushInterval(1d)
|
||||
.buffer(1)
|
||||
|
||||
scale_in
|
||||
|influxDBOut()
|
||||
.database('metrics')
|
||||
.measurement('autoscaling')
|
||||
.flushInterval(1d)
|
||||
.buffer(1)
|
Loading…
Reference in New Issue
Block a user