-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from appuio/add/appuio-managed-kubernetes
Add vCPU query for APPUiO Managed Kubernetes
- Loading branch information
Showing
4 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Calculates vCPUs for app nodes of a cluster | ||
# Structure of resulting product label "query:cluster:tenant::class" | ||
|
||
# Max values over one hour. | ||
max_over_time( | ||
# Add the final product label by joining the base product with the cluster ID, the tenant, and the service class. | ||
label_join( | ||
label_join( | ||
label_replace( | ||
# Add the base product identifier. | ||
label_replace( | ||
sum by (cluster_id, vshn_service_level, tenant_id) (min without(prometheus_replica) (node_cpu_info)), | ||
"product", | ||
"appuio_managed_kubernetes_vcpu", | ||
"", | ||
".*" | ||
), | ||
"class", | ||
"$1", | ||
"vshn_service_level", | ||
"(.*)" | ||
), | ||
"product", | ||
":", | ||
"product", | ||
"cluster_id", | ||
"tenant_id", | ||
"place_holder", | ||
"class" | ||
), | ||
"category", | ||
":", | ||
"tenant_id", | ||
"cluster_id" | ||
)[59m:1m] | ||
) |
48 changes: 48 additions & 0 deletions
48
pkg/db/seeds/promtest/appuio_managed_kubernetes_vcpu.jsonnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
local c = import 'common.libsonnet'; | ||
|
||
local query = importstr '../appuio_managed_kubernetes_vcpu.promql'; | ||
|
||
local commonLabels = { | ||
cluster_id: 'c-managed-kubernetes', | ||
tenant_id: 't-managed-kubernetes', | ||
vshn_service_level: 'standard', | ||
}; | ||
|
||
local baseSeries = { | ||
appNodeCPUInfoLabel0: c.series('node_cpu_info', commonLabels { | ||
instance: 'app-test', | ||
cpu: '0', | ||
}, '1x120'), | ||
appNodeCPUInfoLabel1: c.series('node_cpu_info', commonLabels { | ||
instance: 'app-test', | ||
cpu: '1', | ||
}, '1x120'), | ||
appNodeCPUInfoLabel2: c.series('node_cpu_info', commonLabels { | ||
instance: 'app-test2', | ||
cpu: '0', | ||
}, '1x120'), | ||
}; | ||
|
||
local baseCalculatedLabels = commonLabels { | ||
class: super.vshn_service_level, | ||
category: super.tenant_id + ':' + super.cluster_id, | ||
}; | ||
|
||
{ | ||
tests: [ | ||
c.test( | ||
'two app CPUs and one storage CPU', | ||
baseSeries, | ||
query, | ||
[ | ||
{ | ||
labels: c.formatLabels(baseCalculatedLabels { | ||
product: 'appuio_managed_kubernetes_vcpu:c-managed-kubernetes:t-managed-kubernetes::standard', | ||
}), | ||
value: 3, | ||
}, | ||
] | ||
), | ||
|
||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters