Skip to content

Commit

Permalink
[COST-4866] add csi_driver and csi_volume_handle to storage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
maskarb committed Apr 18, 2024
1 parent 87f86f7 commit 0f2f340
Show file tree
Hide file tree
Showing 5 changed files with 526 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/collector/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
"cost:persistentvolumeclaim_capacity_bytes": "kubelet_volume_stats_capacity_bytes * on(persistentvolumeclaim, namespace) group_left(volumename) max by(namespace, persistentvolumeclaim, volumename) (kube_persistentvolumeclaim_info{volumename != ''})",
"cost:persistentvolumeclaim_request_bytes": "kube_persistentvolumeclaim_resource_requests_storage_bytes * on(persistentvolumeclaim, namespace) group_left(volumename) max by(namespace, persistentvolumeclaim, volumename) (kube_persistentvolumeclaim_info{volumename != ''})",
"cost:persistentvolumeclaim_usage_bytes": "kubelet_volume_stats_used_bytes * on(persistentvolumeclaim, namespace) group_left(volumename) max by(namespace, persistentvolumeclaim, volumename) (kube_persistentvolumeclaim_info{volumename != ''})",
"cost:persistentvolume_labels": "kube_persistentvolume_labels * on(persistentvolume, namespace) group_left(storageclass) max by(namespace, persistentvolume, storageclass) (kube_persistentvolume_info)",
"cost:persistentvolume_labels": "kube_persistentvolume_labels * on(persistentvolume, namespace) group_left(storageclass, csi_driver, csi_volume_handle) max by(namespace, persistentvolume, storageclass, csi_driver, csi_volume_handle) (kube_persistentvolume_info)",
"cost:persistentvolumeclaim_labels": "kube_persistentvolumeclaim_labels * on(persistentvolumeclaim, namespace) group_left(volumename) max by(namespace, persistentvolumeclaim, volumename) (kube_persistentvolumeclaim_info{volumename != ''})",

"cost:pod_limit_cpu_cores": "sum by (pod, namespace, node) (kube_pod_container_resource_limits{pod!='', namespace!='', node!='', resource='cpu'} * on(pod, namespace) group_left max by (pod, namespace) (kube_pod_status_phase{phase='Running'}))",
Expand Down Expand Up @@ -154,7 +154,7 @@ var (
query{
Name: "persistentvolume-labels",
QueryString: QueryMap["cost:persistentvolume_labels"],
MetricKey: staticFields{"storageclass": "storageclass", "persistentvolume": "persistentvolume"},
MetricKey: staticFields{"storageclass": "storageclass", "persistentvolume": "persistentvolume", "csi_driver": "csi_driver", "csi_volume_handle": "csi_volume_handle"},
MetricKeyRegex: regexFields{"persistentvolume_labels": "label_*"},
RowKey: []model.LabelName{"persistentvolume"},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
report_period_start,report_period_end,interval_start,interval_end,namespace,pod,node,persistentvolumeclaim,persistentvolume,storageclass,persistentvolumeclaim_capacity_bytes,persistentvolumeclaim_capacity_byte_seconds,volume_request_storage_byte_seconds,persistentvolumeclaim_usage_byte_seconds,persistentvolume_labels,persistentvolumeclaim_labels
2020-11-01 00:00:00 +0000 UTC,2020-12-01 00:00:00 +0000 UTC,2020-11-06 18:00:00 +0000 UTC,2020-11-06 18:59:59 +0000 UTC,openshift-metering,hive-metastore-0,ip-10-0-150-20.us-east-2.compute.internal,hive-metastore-db-data,pvc-025604dc-93ff-4801-ac06-316243ccd45a,gp2,5217320960.000000,18782355456000.000000,19327352832000.000000,94858444800.000000,label_failure_domain_beta_kubernetes_io_region:us-east-2|label_failure_domain_beta_kubernetes_io_zone:us-east-2a,label_app:hive-metastore|label_metering_openshift_io_ns_prune:openshift-metering|label_metering_openshift_io_prune:hive-metastore-pvc
report_period_start,report_period_end,interval_start,interval_end,namespace,pod,node,persistentvolumeclaim,persistentvolume,storageclass,csi_driver,csi_volume_handle,persistentvolumeclaim_capacity_bytes,persistentvolumeclaim_capacity_byte_seconds,volume_request_storage_byte_seconds,persistentvolumeclaim_usage_byte_seconds,persistentvolume_labels,persistentvolumeclaim_labels
2020-11-01 00:00:00 +0000 UTC,2020-12-01 00:00:00 +0000 UTC,2020-11-06 18:00:00 +0000 UTC,2020-11-06 18:59:59 +0000 UTC,openshift-metering,hive-metastore-0,ip-10-0-150-20.us-east-2.compute.internal,hive-metastore-db-data,pvc-025604dc-93ff-4801-ac06-316243ccd45a,gp3-csi,ebs.csi.aws.com,vol-03b179b2d1e4ccdef,5217320960.000000,18782355456000.000000,19327352832000.000000,94858444800.000000,label_failure_domain_beta_kubernetes_io_region:us-east-2|label_failure_domain_beta_kubernetes_io_zone:us-east-2a,label_app:hive-metastore|label_metering_openshift_io_ns_prune:openshift-metering|label_metering_openshift_io_prune:hive-metastore-pvc
2020-11-01 00:00:00 +0000 UTC,2020-12-01 00:00:00 +0000 UTC,2020-11-06 18:00:00 +0000 UTC,2020-11-06 18:59:59 +0000 UTC,costmanagement-metrics-operator,costmanagement-metrics-operator-c75b4c7fb-z9ngg,,,pvc-92857cf9-1002-41d9-9b65-51cdac980594,gp2,,,,,,,label_topology_kubernetes_io_region:us-east-2|label_topology_kubernetes_io_zone:us-east-2b,
258 changes: 258 additions & 0 deletions internal/collector/test_files/test_data/persistentvolume-labels
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,264 @@
"pod": "kube-state-metrics-b88767d9b-6sbjt",
"prometheus": "openshift-monitoring/k8s",
"service": "kube-state-metrics",
"storageclass": "gp3-csi",
"csi_driver": "ebs.csi.aws.com",
"csi_volume_handle": "vol-03b179b2d1e4ccdef"
},
"values": [
[
1604685600,
"1"
],
[
1604685660,
"1"
],
[
1604685720,
"1"
],
[
1604685780,
"1"
],
[
1604685840,
"1"
],
[
1604685900,
"1"
],
[
1604685960,
"1"
],
[
1604686020,
"1"
],
[
1604686080,
"1"
],
[
1604686140,
"1"
],
[
1604686200,
"1"
],
[
1604686260,
"1"
],
[
1604686320,
"1"
],
[
1604686380,
"1"
],
[
1604686440,
"1"
],
[
1604686500,
"1"
],
[
1604686560,
"1"
],
[
1604686620,
"1"
],
[
1604686680,
"1"
],
[
1604686740,
"1"
],
[
1604686800,
"1"
],
[
1604686860,
"1"
],
[
1604686920,
"1"
],
[
1604686980,
"1"
],
[
1604687040,
"1"
],
[
1604687100,
"1"
],
[
1604687160,
"1"
],
[
1604687220,
"1"
],
[
1604687280,
"1"
],
[
1604687340,
"1"
],
[
1604687400,
"1"
],
[
1604687460,
"1"
],
[
1604687520,
"1"
],
[
1604687580,
"1"
],
[
1604687640,
"1"
],
[
1604687700,
"1"
],
[
1604687760,
"1"
],
[
1604687820,
"1"
],
[
1604687880,
"1"
],
[
1604687940,
"1"
],
[
1604688000,
"1"
],
[
1604688060,
"1"
],
[
1604688120,
"1"
],
[
1604688180,
"1"
],
[
1604688240,
"1"
],
[
1604688300,
"1"
],
[
1604688360,
"1"
],
[
1604688420,
"1"
],
[
1604688480,
"1"
],
[
1604688540,
"1"
],
[
1604688600,
"1"
],
[
1604688660,
"1"
],
[
1604688720,
"1"
],
[
1604688780,
"1"
],
[
1604688840,
"1"
],
[
1604688900,
"1"
],
[
1604688960,
"1"
],
[
1604689020,
"1"
],
[
1604689080,
"1"
],
[
1604689140,
"1"
]
]
},
{
"metric": {
"container": "kube-rbac-proxy-main",
"endpoint": "https-main",
"job": "kube-state-metrics",
"label_topology_kubernetes_io_region": "us-east-2",
"label_topology_kubernetes_io_zone": "us-east-2b",
"namespace": "openshift-monitoring",
"persistentvolume": "pvc-92857cf9-1002-41d9-9b65-51cdac980594",
"prometheus": "openshift-monitoring/k8s",
"service": "kube-state-metrics",
"storageclass": "gp2"
},
"values": [
Expand Down
Loading

0 comments on commit 0f2f340

Please sign in to comment.