-
Notifications
You must be signed in to change notification settings - Fork 1
/
appuio_cloud_persistent_storage.promql
71 lines (71 loc) · 2.1 KB
/
appuio_cloud_persistent_storage.promql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Sum values over one hour.
sum_over_time(
# Add the final product label by joining the base product with the cluster ID, the tenant, and the namespace.
label_join(
# Add the category label by joining the cluster ID and the namespace.
label_join(
# Add the base product identifier.
label_replace(
clamp_min(
sum by(cluster_id, tenant_id, namespace, storageclass)(
# Get the PersistentVolume size
kube_persistentvolume_capacity_bytes
*
# Join the PersistentVolumeClaim to get the namespace
on (cluster_id,persistentvolume)
group_left(namespace, name)
label_replace(
kube_persistentvolume_claim_ref,
"namespace",
"$1",
"claim_namespace",
"(.+)(-.*)?"
)
*
# Join the PersistentVolume info to get StorageClass
on (cluster_id,persistentvolume)
group_left(storageclass)
# Do not differantiate between regular and encrypted storage class versions.
min by (cluster_id, persistentvolume, storageclass) (
label_replace(
kube_persistentvolume_info,
"storageclass",
"$1",
"storageclass",
"([^-]+)-encrypted"
)
)
*
# Join the namespace label to get the tenant
on(cluster_id,namespace)
group_left(tenant_id)
label_replace(
kube_namespace_labels{label_appuio_io_organization=~".+"},
"tenant_id",
"$1",
"label_appuio_io_organization", "(.*)"
)
),
1024 * 1024 * 1024
),
"product",
"appuio_cloud_persistent_storage",
"product",
".*"
),
"category",
":",
"cluster_id",
"namespace"
),
"product",
":",
"product",
"cluster_id",
"tenant_id",
"namespace",
"storageclass"
)[59m:1m]
)
# Convert to GiB
/ 1024 / 1024 / 1024