package collector import ( "github.com/opencost/opencost/core/pkg/source" "github.com/opencost/opencost/modules/collector-source/pkg/metric" "github.com/opencost/opencost/modules/collector-source/pkg/metric/aggregator" ) // NewOpenCostMetricStore creates a new MetricStore which has registered all MetricCollector instances required // for OpenCost func NewOpenCostMetricStore() metric.MetricStore { memStore := metric.NewInMemoryMetricStore() // Register all the metrics memStore.Register(NewPVPricePerGiBHourMetricCollector()) memStore.Register(NewPVUsedAverageMetricCollector()) memStore.Register(NewPVUsedMaxMetricCollector()) memStore.Register(NewPVCInfoMetricCollector()) memStore.Register(NewPVCBytesUsedAverageMetricCollector()) memStore.Register(NewPVCBytesUsedMaxMetricCollector()) memStore.Register(NewPVCUptimeMetricCollector()) memStore.Register(NewPVInfoMetricCollector()) memStore.Register(NewKMPVInfoMetricCollector()) memStore.Register(NewPVUptimeMetricCollector()) memStore.Register(NewPVActiveMinutesMetricCollector()) memStore.Register(NewPVBytesMetricCollector()) memStore.Register(NewLocalStorageUsedActiveMinutesMetricCollector()) memStore.Register(NewLocalStorageUsedAverageMetricCollector()) memStore.Register(NewLocalStorageUsedMaxMetricCollector()) memStore.Register(NewLocalStorageBytesMetricCollector()) memStore.Register(NewLocalStorageActiveMinutesMetricCollector()) memStore.Register(NewKMLocalStorageUsedAverageMetricCollector()) memStore.Register(NewKMLocalStorageUsedMaxMetricCollector()) memStore.Register(NewKMLocalStorageBytesMetricCollector()) memStore.Register(NewKMPVCInfoMetricCollector()) memStore.Register(NewNodeInfoMetricCollector()) memStore.Register(NewNodeUptimeMetricCollector()) memStore.Register(NewNodeResourceCapacitiesMetricCollector()) memStore.Register(NewNodeResourcesAllocatableMetricCollector()) memStore.Register(NewNodeCPUCoresCapacityMetricCollector()) memStore.Register(NewNodeCPUCoresAllocatableMetricCollector()) memStore.Register(NewNodeRAMBytesCapacityMetricCollector()) memStore.Register(NewNodeRAMBytesAllocatableMetricCollector()) memStore.Register(NewNodeGPUCountMetricCollector()) memStore.Register(NewNodeLabelsMetricCollector()) memStore.Register(NewNodeActiveMinutesMetricCollector()) memStore.Register(NewNodeCPUModeTotalMetricCollector()) memStore.Register(NewNodeRAMSystemUsageAverageMetricCollector()) memStore.Register(NewNodeRAMUserUsageAverageMetricCollector()) memStore.Register(NewLBPricePerHourMetricCollector()) memStore.Register(NewLBActiveMinutesMetricCollector()) memStore.Register(NewClusterInfoMetricCollector()) memStore.Register(NewClusterUptimeMetricCollector()) memStore.Register(NewClusterManagementDurationMetricCollector()) memStore.Register(NewClusterManagementPricePerHourMetricCollector()) memStore.Register(NewPodActiveMinutesMetricCollector()) memStore.Register(NewRAMBytesAllocatedMetricCollector()) memStore.Register(NewRAMRequestsMetricCollector()) memStore.Register(NewRAMLimitsMetricCollector()) memStore.Register(NewRAMUsageAverageMetricCollector()) memStore.Register(NewRAMUsageMaxMetricCollector()) memStore.Register(NewCPUCoresAllocatedMetricCollector()) memStore.Register(NewCPURequestsMetricCollector()) memStore.Register(NewCPULimitsMetricCollector()) memStore.Register(NewCPUUsageAverageMetricCollector()) memStore.Register(NewCPUUsageMaxMetricCollector()) memStore.Register(NewGPUsRequestedMetricCollector()) memStore.Register(NewGPUsUsageAverageMetricCollector()) memStore.Register(NewGPUsUsageMaxMetricCollector()) memStore.Register(NewGPUsAllocatedMetricCollector()) memStore.Register(NewIsGPUSharedMetricCollector()) memStore.Register(NewGPUInfoMetricCollector()) memStore.Register(NewDCGMInfoMetricCollector()) memStore.Register(NewDCGMUptimeMetricCollector()) memStore.Register(NewDCGMContainerUsageAvgMetricCollector()) memStore.Register(NewDCGMContainerUsageMaxMetricCollector()) memStore.Register(NewNodeCPUPricePerHourMetricCollector()) memStore.Register(NewNodeRAMPricePerGiBHourMetricCollector()) memStore.Register(NewNodeGPUPricePerHourMetricCollector()) memStore.Register(NewNodeIsSpotMetricCollector()) memStore.Register(NewPodPVCAllocationMetricCollector()) memStore.Register(NewPVCBytesRequestedMetricCollector()) memStore.Register(NewNetZoneGiBMetricCollector()) memStore.Register(NewNetZonePricePerGiBMetricCollector()) memStore.Register(NewNetRegionGiBMetricCollector()) memStore.Register(NewNetRegionPricePerGiBMetricCollector()) memStore.Register(NewNetInternetGiBMetricCollector()) memStore.Register(NewNetInternetPricePerGiBMetricCollector()) memStore.Register(NewNetInternetServiceGiBMetricCollector()) memStore.Register(NewNetNatGatewayGiBMetricCollector()) memStore.Register(NewNetNatGatewayPricePerGiBMetricCollector()) memStore.Register(NewNetReceiveBytesMetricCollector()) memStore.Register(NewNetZoneIngressGiBMetricCollector()) memStore.Register(NewNetRegionIngressGiBMetricCollector()) memStore.Register(NewNetInternetIngressGiBMetricCollector()) memStore.Register(NewNetInternetServiceIngressGiBMetricCollector()) memStore.Register(NewNetNatGatewayIngressPricePerGiBMetricCollector()) memStore.Register(NewNetNatGatewayIngressGiBMetricCollector()) memStore.Register(NewNetTransferBytesMetricCollector()) memStore.Register(NewNamespaceInfoMetricCollector()) memStore.Register(NewNamespaceUptimeMetricCollector()) memStore.Register(NewNamespaceLabelsMetricCollector()) memStore.Register(NewNamespaceAnnotationsMetricCollector()) memStore.Register(NewPodLabelsMetricCollector()) memStore.Register(NewPodAnnotationsMetricCollector()) memStore.Register(NewServiceInfoMetricCollector()) memStore.Register(NewServiceUptimeMetricCollector()) memStore.Register(NewServiceLabelsMetricCollector()) memStore.Register(NewDeploymentInfoMetricCollector()) memStore.Register(NewDeploymentUptimeMetricCollector()) memStore.Register(NewDeploymentLabelsMetricCollector()) memStore.Register(NewDeploymentAnnotationsMetricCollector()) memStore.Register(NewDeploymentMatchLabelsMetricCollector()) memStore.Register(NewStatefulSetInfoMetricCollector()) memStore.Register(NewStatefulSetUptimeMetricCollector()) memStore.Register(NewStatefulSetLabelsMetricCollector()) memStore.Register(NewStatefulSetAnnotationsMetricCollector()) memStore.Register(NewStatefulSetMatchLabelsMetricCollector()) memStore.Register(NewDaemonSetInfoMetricCollector()) memStore.Register(NewDaemonSetUptimeMetricCollector()) memStore.Register(NewDaemonSetLabelsMetricCollector()) memStore.Register(NewDaemonSetAnnotationsMetricCollector()) memStore.Register(NewJobInfoMetricCollector()) memStore.Register(NewJobUptimeMetricCollector()) memStore.Register(NewJobLabelsMetricCollector()) memStore.Register(NewJobAnnotationsMetricCollector()) memStore.Register(NewCronJobInfoMetricCollector()) memStore.Register(NewCronJobUptimeMetricCollector()) memStore.Register(NewCronJobLabelsMetricCollector()) memStore.Register(NewCronJobAnnotationsMetricCollector()) memStore.Register(NewReplicaSetInfoMetricCollector()) memStore.Register(NewReplicaSetUptimeMetricCollector()) memStore.Register(NewReplicaSetLabelsMetricCollector()) memStore.Register(NewReplicaSetAnnotationsMetricCollector()) memStore.Register(NewReplicaSetOwnerMetricCollector()) memStore.Register(NewPodsWithDaemonSetOwnerMetricCollector()) memStore.Register(NewPodsWithJobOwnerMetricCollector()) memStore.Register(NewPodsWithReplicaSetOwnerMetricCollector()) memStore.Register(NewPodInfoMetricCollector()) memStore.Register(NewPodUptimeMetricCollector()) memStore.Register(NewPodOwnerMetricCollector()) memStore.Register(NewPodPVCVolumeMetricCollector()) memStore.Register(NewPodNetworkEgressBytesMetricCollector()) memStore.Register(NewPodNetworkIngressBytesMetricCollector()) memStore.Register(NewContainerUptimeMetricCollector()) memStore.Register(NewContainerResourceRequestsMetricCollector()) memStore.Register(NewContainerResourceLimitsMetricCollector()) memStore.Register(NewReplicaSetsWithoutOwnersMetricCollector()) memStore.Register(NewReplicaSetsWithRolloutMetricCollector()) memStore.Register(NewResourceQuotaInfoMetricCollector()) memStore.Register(NewResourceQuotaUptimeMetricCollector()) memStore.Register(NewResourceQuotaSpecCPURequestAverageMetricCollector()) memStore.Register(NewResourceQuotaSpecCPURequestMaxMetricCollector()) memStore.Register(NewResourceQuotaSpecRAMRequestAverageMetricCollector()) memStore.Register(NewResourceQuotaSpecRAMRequestMaxMetricCollector()) memStore.Register(NewResourceQuotaSpecCPULimitAverageMetricCollector()) memStore.Register(NewResourceQuotaSpecCPULimitMaxMetricCollector()) memStore.Register(NewResourceQuotaSpecRAMLimitAverageMetricCollector()) memStore.Register(NewResourceQuotaSpecRAMLimitMaxMetricCollector()) memStore.Register(NewResourceQuotaStatusUsedCPURequestAverageMetricCollector()) memStore.Register(NewResourceQuotaStatusUsedCPURequestMaxMetricCollector()) memStore.Register(NewResourceQuotaStatusUsedRAMRequestAverageMetricCollector()) memStore.Register(NewResourceQuotaStatusUsedRAMRequestMaxMetricCollector()) memStore.Register(NewResourceQuotaStatusUsedCPULimitAverageMetricCollector()) memStore.Register(NewResourceQuotaStatusUsedCPULimitMaxMetricCollector()) memStore.Register(NewResourceQuotaStatusUsedRAMLimitAverageMetricCollector()) memStore.Register(NewResourceQuotaStatusUsedRAMLimitMaxMetricCollector()) return memStore } // avg( // avg_over_time( // pv_hourly_cost{ // // }[1h] // ) // ) by (cluster_id, persistentvolume, volumename, provider_id) func NewPVPricePerGiBHourMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVPricePerGiBHourID, metric.PVHourlyCost, []string{ source.VolumeNameLabel, source.PVLabel, source.ProviderIDLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // kubelet_volume_stats_used_bytes{ // // }[1h] // ) // ) by (cluster_id, persistentvolumeclaim, namespace) func NewPVUsedAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVUsedAverageID, metric.KubeletVolumeStatsUsedBytes, []string{ source.NamespaceLabel, source.PVCLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // max( // max_over_time( // kubelet_volume_stats_used_bytes{ // // }[1h] // ) // ) by (cluster_id, persistentvolumeclaim, namespace) func NewPVUsedMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVUsedMaxID, metric.KubeletVolumeStatsUsedBytes, []string{ source.NamespaceLabel, source.PVCLabel, source.UIDLabel, }, aggregator.MaxOverTime, nil, ) } func NewPVCBytesUsedAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVCBytesUsedAverageID, metric.KubeletVolumeStatsUsedBytes, []string{ source.PVCUIDLabel, }, aggregator.AverageOverTime, nil, ) } func NewPVCBytesUsedMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVCBytesUsedMaxID, metric.KubeletVolumeStatsUsedBytes, []string{ source.PVCUIDLabel, }, aggregator.MaxOverTime, nil, ) } // avg( // kube_persistentvolumeclaim_info{ // volumename != "", // // } // ) by (persistentvolumeclaim, storageclass, volumename, namespace, cluster_id)[0:10m] func NewPVCInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVCInfoID, metric.KubePersistentVolumeClaimInfo, []string{ source.NamespaceLabel, source.VolumeNameLabel, source.PVCLabel, source.StorageClassLabel, source.UIDLabel, }, aggregator.Uptime, func(labels map[string]string) bool { return labels[source.VolumeNameLabel] != "" }, ) } func NewPVCUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVCUptimeID, metric.KubePersistentVolumeClaimInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } // avg( // kube_persistentvolume_capacity_bytes{ // // } // ) by (cluster_id, persistentvolume)[0:10m] func NewPVActiveMinutesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVActiveMinutesID, metric.KubePersistentVolumeCapacityBytes, []string{ source.UIDLabel, source.PVLabel, }, aggregator.Uptime, nil, ) } func NewKMPVInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.KMPVInfoID, metric.KubecostPVInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewPVUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVUptimeID, metric.KubecostPVInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } // sum_over_time( // // sum( // container_fs_usage_bytes{ // device=~"/dev/(nvme|sda).*", // id="/", // // } // ) by (instance, device, cluster_id)[%s:%dm] // // ) / 1024 / 1024 / 1024 * %f * %f` func NewLocalStorageUsedActiveMinutesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.LocalStorageUsedActiveMinutesID, metric.ContainerFSUsageBytes, []string{ source.InstanceLabel, source.DeviceLabel, }, aggregator.Uptime, nil, // filter not required here because only container root file system is being scraped ) } // avg( // sum( // avg_over_time( // container_fs_usage_bytes{ // device=~"/dev/(nvme|sda).*", // id="/", // // }[1h] // ) // ) by (instance, device, cluster_id, job) // ) by (instance, device, cluster_id) func NewLocalStorageUsedAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.LocalStorageUsedAverageID, metric.ContainerFSUsageBytes, []string{ source.InstanceLabel, source.DeviceLabel, }, aggregator.AverageOverTime, nil, // filter not required here because only container root file system is being scraped ) } // max( // // sum( // max_over_time( // container_fs_usage_bytes{ // device=~"/dev/(nvme|sda).*", // id="/", // // }[1h] // ) // ) by (instance, device, cluster_id, job) // // ) by (instance, device, cluster_id) func NewLocalStorageUsedMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.LocalStorageUsedMaxID, metric.ContainerFSUsageBytes, []string{ source.InstanceLabel, source.DeviceLabel, }, aggregator.MaxOverTime, nil, // filter not required here because only container root file system is being scraped ) } // avg_over_time( // // sum( // container_fs_limit_bytes{ // device=~"/dev/(nvme|sda).*", // id="/", // // } // ) by (instance, device, cluster_id)[%s:%dm] // // ) func NewLocalStorageBytesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.LocalStorageBytesID, metric.NodeFSCapacityBytes, []string{ source.InstanceLabel, source.DeviceLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, // filter not required here because only node root file system is being scraped ) } func NewKMLocalStorageUsedAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.KMLocalStorageUsedAverageID, metric.ContainerFSUsageBytes, []string{ source.NodeUIDLabel, }, aggregator.AverageOverTime, nil, ) } func NewKMLocalStorageUsedMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.KMLocalStorageUsedMaxID, metric.ContainerFSUsageBytes, []string{ source.NodeUIDLabel, }, aggregator.MaxOverTime, nil, ) } func NewKMLocalStorageBytesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.KMLocalStorageBytesID, metric.NodeFSCapacityBytes, []string{ source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } func NewKMPVCInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.KMPVCInfoID, metric.KubePersistentVolumeClaimInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } // count( // // kube_node_labels{ // // } // // ) by (cluster_id, node, instance, provider_id)[%s:%dm] func NewLocalStorageActiveMinutesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.LocalStorageActiveMinutesID, metric.KubeNodeLabels, []string{ source.NodeLabel, source.ProviderIDLabel, source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewNodeInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeInfoID, metric.NodeInfo, []string{ source.NodeLabel, source.UIDLabel, source.ProviderIDLabel, source.InstanceTypeLabel, }, aggregator.Info, nil, ) } func NewNodeUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeUptimeID, metric.NodeInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewNodeResourceCapacitiesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeResourceCapacitiesID, metric.NodeResourceCapacities, []string{ source.UIDLabel, source.ResourceLabel, source.UnitLabel, }, aggregator.AverageOverTime, nil, ) } func NewNodeResourcesAllocatableMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeResourcesAllocatableID, metric.NodeResourcesAllocatable, []string{ source.UIDLabel, source.ResourceLabel, source.UnitLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // // avg_over_time( // kube_node_status_capacity_cpu_cores{ // // }[1h] // ) // // ) by (cluster_id, node) func NewNodeCPUCoresCapacityMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeCPUCoresCapacityID, metric.KubeNodeStatusCapacityCPUCores, []string{ source.NodeLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // kube_node_status_allocatable_cpu_cores{ // // }[1h] // ) // ) by (cluster_id, node) func NewNodeCPUCoresAllocatableMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeCPUCoresAllocatableID, metric.KubeNodeStatusAllocatableCPUCores, []string{ source.NodeLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // kube_node_status_capacity_memory_bytes{ // // }[1h] // ) // ) by (cluster_id, node) func NewNodeRAMBytesCapacityMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeRAMBytesCapacityID, metric.KubeNodeStatusCapacityMemoryBytes, []string{ source.NodeLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // kube_node_status_allocatable_memory_bytes{ // // }[1h] // ) // ) by (cluster_id, node) func NewNodeRAMBytesAllocatableMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeRAMBytesAllocatableID, metric.KubeNodeStatusAllocatableMemoryBytes, []string{ source.NodeLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // node_gpu_count{ // // }[1h] // ) // ) by (cluster_id, node, provider_id) func NewNodeGPUCountMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeGPUCountID, metric.NodeGPUCount, []string{ source.NodeLabel, source.ProviderIDLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg_over_time( // kube_node_labels{ // // }[1h] // ) func NewNodeLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeLabelsID, metric.KubeNodeLabels, []string{ source.NodeLabel, source.UIDLabel, }, aggregator.Info, nil, ) } // avg( // kube_node_labels{ // // } // ) by (node, cluster_id, provider_id)[%s:%dm] func NewNodeActiveMinutesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeActiveMinutesID, metric.KubeNodeLabels, []string{ source.NodeLabel, source.ProviderIDLabel, source.UIDLabel, }, aggregator.Uptime, nil, ) } // sum( // rate( // node_cpu_seconds_total{ // // }[%s:%dm] // ) // ) by (kubernetes_node, cluster_id, mode) func NewNodeCPUModeTotalMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeCPUModeTotalID, metric.NodeCPUSecondsTotal, []string{ source.KubernetesNodeLabel, source.ModeLabel, source.UIDLabel, }, aggregator.Rate, nil, ) } // avg( // avg_over_time( // container_memory_working_set_bytes{ // container_name!="POD", // container_name!="", // namespace="kube-system", // // }[%s:%dm] // ) // ) by (instance, cluster_id) func NewNodeRAMSystemUsageAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeRAMSystemUsageAverageID, metric.ContainerMemoryWorkingSetBytes, []string{ source.InstanceLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" && labels[source.NamespaceLabel] == "kube-system" }, ) } // avg( // avg_over_time( // container_memory_working_set_bytes{ // container_name!="POD", // container_name!="", // namespace!="kube-system", // // }[%s:%dm] // ) // ) by (instance, cluster_id) func NewNodeRAMUserUsageAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeRAMUserUsageAverageID, metric.ContainerMemoryWorkingSetBytes, []string{ source.InstanceLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" && labels[source.NamespaceLabel] != "kube-system" }, ) } // avg( // avg_over_time( // kubecost_load_balancer_cost{ // // }[1h] // ) // ) by (namespace, service_name, ingress_ip, cluster_id) func NewLBPricePerHourMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.LBPricePerHourID, metric.KubecostLoadBalancerCost, []string{ source.NamespaceLabel, source.ServiceNameLabel, source.IngressIPLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // kubecost_load_balancer_cost{ // // } // ) by (namespace, service_name, cluster_id, ingress_ip)[%s:%dm] func NewLBActiveMinutesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.LBActiveMinutesID, metric.KubecostLoadBalancerCost, []string{ source.NamespaceLabel, source.ServiceNameLabel, source.IngressIPLabel, source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewClusterInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ClusterInfoID, metric.ClusterInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } // avg( // cluster_info{ // // } // ) by (uid)[%s:%dm] func NewClusterUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ClusterUptimeID, metric.ClusterInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } // avg( // kubecost_cluster_management_cost{ // // } // ) by (cluster_id, provisioner_name)[%s:%dm] func NewClusterManagementDurationMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ClusterManagementDurationID, metric.KubecostClusterManagementCost, []string{ source.ProvisionerNameLabel, source.UIDLabel, }, aggregator.Uptime, nil, ) } // avg( // avg_over_time( // kubecost_cluster_management_cost{ // // }[1h] // ) // ) by (cluster_id, provisioner_name) func NewClusterManagementPricePerHourMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ClusterManagementPricePerHourID, metric.KubecostClusterManagementCost, []string{ source.ProvisionerNameLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // kube_pod_container_status_running{ // // } != 0 // ) by (pod, namespace, uid, cluster_id)[%s:%s] func NewPodActiveMinutesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodActiveMinutesID, metric.KubePodContainerStatusRunning, []string{ source.UIDLabel, source.NamespaceLabel, source.PodLabel, }, aggregator.Uptime, nil, ) } func NewPodInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodInfoID, metric.PodInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewPodUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodUptimeID, metric.PodInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewPodOwnerMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodOwnerID, metric.KubePodOwner, []string{ source.UIDLabel, source.OwnerUIDLabel, source.OwnerKindLabel, }, aggregator.Info, nil, ) } func NewPodPVCVolumeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodPVCVolumeID, metric.PodPVCVolume, []string{ source.UIDLabel, source.PVCUIDLabel, source.PodVolumeNameLabel, }, aggregator.Info, nil, ) } func NewPodNetworkEgressBytesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodNetworkEgressBytesID, metric.KubecostPodNetworkEgressBytesTotal, []string{ source.UIDLabel, source.ServiceLabel, source.InternetLabel, source.SameRegionLabel, source.SameZoneLabel, source.NatGatewayLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.UIDLabel] != "" }, ) } func NewPodNetworkIngressBytesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodNetworkIngressBytesID, metric.KubecostPodNetworkIngressBytesTotal, []string{ source.UIDLabel, source.NatGatewayLabel, source.ServiceLabel, source.SameZoneLabel, source.SameRegionLabel, source.InternetLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.UIDLabel] != "" }, ) } func NewContainerUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ContainerUptimeID, metric.KubePodContainerStatusRunning, []string{ source.UIDLabel, source.ContainerLabel, }, aggregator.Uptime, nil, ) } // avg( // avg_over_time( // container_memory_allocation_bytes{ // container!="", // container!="POD", // node!="", // // }[1h] // ) // ) by (container, pod, namespace, node, cluster_id, provider_id) func NewRAMBytesAllocatedMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.RAMBytesAllocatedID, metric.ContainerMemoryAllocationBytes, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" && labels[source.NodeLabel] != "" }, ) } // avg( // avg_over_time( // kube_pod_container_resource_requests{ // resource="memory", // unit="byte", // container!="", // container!="POD", // node!="", // // }[1h] // ) //) by (container, pod, namespace, node, cluster_id) func NewRAMRequestsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.RAMRequestsID, metric.KubePodContainerResourceRequests, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" && labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" && labels[source.NodeLabel] != "" }, ) } // avg( // avg_over_time( // kube_pod_container_resource_limits{ // resource="memory", // unit="byte", // container!="", // container!="POD", // node!="", // // }[1h] // ) //) by (container, pod, namespace, node, cluster_id) func NewRAMLimitsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.RAMLimitsID, metric.KubePodContainerResourceLimits, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" && labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" && labels[source.NodeLabel] != "" }, ) } // avg( // avg_over_time( // container_memory_working_set_bytes{ // container!="", // container!="POD", // // }[1h] // ) // ) by (container, pod, namespace, instance, cluster_id) func NewRAMUsageAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.RAMUsageAverageID, metric.ContainerMemoryWorkingSetBytes, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" }, ) } // max( // max_over_time( // container_memory_working_set_bytes{ // container!="", // container_name!="POD", // container!="POD", // // }[%s] // ) // ) by (container_name, container, pod_name, pod, namespace, node, instance, %s) func NewRAMUsageMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.RAMUsageMaxID, metric.ContainerMemoryWorkingSetBytes, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" && labels[source.ContainerLabel] != "POD" && labels[source.NodeLabel] != "" }, ) } // avg( // avg_over_time( // container_cpu_allocation{ // container!="", // container!="POD", // node!="", // // }[1h] // ) // ) by (container, pod, namespace, node, cluster_id) func NewCPUCoresAllocatedMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.CPUCoresAllocatedID, metric.ContainerCPUAllocation, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" && labels[source.NodeLabel] != "" }, ) } // avg( // avg_over_time( // kube_pod_container_resource_requests{ // resource="cpu", // unit="core", // container!="", // container!="POD", // node!="", // // }[1h] // ) // ) by (container, pod, namespace, node, cluster_id) func NewCPURequestsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.CPURequestsID, metric.KubePodContainerResourceRequests, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" && labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" && labels[source.NodeLabel] != "" }, ) } // avg( // avg_over_time( // kube_pod_container_resource_limits{ // resource="cpu", // unit="core", // container!="", // container!="POD", // node!="", // // }[1h] // ) // ) by (container, pod, namespace, node, cluster_id) func NewCPULimitsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.CPULimitsID, metric.KubePodContainerResourceLimits, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" && labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" && labels[source.NodeLabel] != "" }, ) } func NewContainerResourceRequestsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ContainerResourceRequestsID, metric.KubePodContainerResourceRequests, []string{ source.UIDLabel, source.ContainerLabel, source.ResourceLabel, source.UnitLabel, }, aggregator.AverageOverTime, nil, ) } func NewContainerResourceLimitsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ContainerResourceLimitsID, metric.KubePodContainerResourceLimits, []string{ source.UIDLabel, source.ContainerLabel, source.ResourceLabel, source.UnitLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // rate( // container_cpu_usage_seconds_total{ // container!="", // container_name!="POD", // container!="POD", // // }[1h] // ) // ) by (container_name, container, pod_name, pod, namespace, node, instance, cluster_id) func NewCPUUsageAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.CPUUsageAverageID, metric.ContainerCPUUsageSecondsTotal, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.Rate, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" && labels[source.ContainerLabel] != "POD" }, ) } // max( // // max_over_time( // irate( // container_cpu_usage_seconds_total{ // container!="POD", // container!="", // // }[1h] // )[%s:%s] // ) // // ) by (container, pod_name, pod, namespace, node, instance, cluster_id) func NewCPUUsageMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.CPUUsageMaxID, metric.ContainerCPUUsageSecondsTotal, []string{ source.NodeLabel, source.InstanceLabel, source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.IRateMax, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" && labels[source.ContainerLabel] != "POD" }, ) } // avg( // avg_over_time( // kube_pod_container_resource_requests{ // resource="nvidia_com_gpu", // container!="", // container!="POD", // node!="", // // }[1h] // ) // ) by (container, pod, namespace, node, cluster_id) func NewGPUsRequestedMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.GPUsRequestedID, metric.KubePodContainerResourceRequests, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "nvidia_com_gpu" && labels[source.ContainerLabel] != "POD" && labels[source.ContainerLabel] != "" && labels[source.NodeLabel] != "" }, ) } // avg( // avg_over_time( // DCGM_FI_PROF_GR_ENGINE_ACTIVE{ // container!="" // }[1h] // ) // ) by (container, pod, namespace, cluster_id) func NewGPUsUsageAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.GPUsUsageAverageID, metric.DCGMFIPROFGRENGINEACTIVE, []string{ source.NamespaceLabel, source.PodLabel, source.PodUIDLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" }, ) } // max( // max_over_time( // DCGM_FI_PROF_GR_ENGINE_ACTIVE{ // container!="" // }[1h] // ) // ) by (container, pod, namespace, cluster_id) func NewGPUsUsageMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.GPUsUsageMaxID, metric.DCGMFIPROFGRENGINEACTIVE, []string{ source.NamespaceLabel, source.PodLabel, source.PodUIDLabel, source.ContainerLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" }, ) } // avg( // avg_over_time( // container_gpu_allocation{ // container!="", // container!="POD", // node!="", // // }[1h] // ) // ) by (container, pod, namespace, node, cluster_id) func NewGPUsAllocatedMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.GPUsAllocatedID, metric.ContainerGPUAllocation, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" && labels[source.ContainerLabel] != "POD" && labels[source.NodeLabel] != "" }, ) } // avg( // avg_over_time( // kube_pod_container_resource_requests{ // container!="", // node != "", // pod != "", // container!= "", // unit = "integer", // // }[1h] // ) // ) by (container, pod, namespace, node, resource, cluster_id) func NewIsGPUSharedMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.IsGPUSharedID, metric.KubePodContainerResourceRequests, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.ContainerLabel, source.ResourceLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" && labels[source.NodeLabel] != "" && labels[source.PodLabel] != "" && labels[source.UnitLabel] == "integer" }, ) } // avg( // avg_over_time( // DCGM_FI_DEV_DEC_UTIL{ // container!="", // // }[1h] // ) // ) by (container, pod, namespace, device, modelName, UUID, cluster_id) func NewGPUInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.GPUInfoID, metric.DCGMFIDEVDECUTIL, []string{ source.NamespaceLabel, source.PodLabel, source.PodUIDLabel, source.ContainerLabel, source.DeviceLabel, source.ModelNameLabel, source.UUIDLabel, }, aggregator.Info, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" }, ) } func NewDCGMInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DCGMInfoID, metric.DCGMFIDEVDECUTIL, []string{ source.UUIDLabel, }, aggregator.Info, nil, ) } func NewDCGMUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DCGMUptimeID, metric.DCGMFIDEVDECUTIL, []string{ source.UUIDLabel, }, aggregator.Uptime, nil, ) } func NewDCGMContainerUsageAvgMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DCGMContainerUsageAvgID, metric.DCGMFIPROFGRENGINEACTIVE, []string{ source.UUIDLabel, source.PodUIDLabel, source.ContainerLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" }, ) } func NewDCGMContainerUsageMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DCGMContainerUsageMaxID, metric.DCGMFIPROFGRENGINEACTIVE, []string{ source.UUIDLabel, source.PodUIDLabel, source.ContainerLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ContainerLabel] != "" }, ) } // avg( // avg_over_time( // node_cpu_hourly_cost{ // // }[1h] // ) // ) by (node, cluster_id, instance_type, provider_id) func NewNodeCPUPricePerHourMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeCPUPricePerHourID, metric.NodeCPUHourlyCost, []string{ source.NodeLabel, source.InstanceTypeLabel, source.ProviderIDLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // node_ram_hourly_cost{ // // }[1h] // ) // ) by (node, cluster_id, instance_type, provider_id) func NewNodeRAMPricePerGiBHourMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeRAMPricePerGiBHourID, metric.NodeRAMHourlyCost, []string{ source.NodeLabel, source.InstanceTypeLabel, source.ProviderIDLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // node_gpu_hourly_cost{ // // }[1h] // ) // ) by (node, cluster_id, instance_type, provider_id) func NewNodeGPUPricePerHourMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeGPUPricePerHourID, metric.NodeGPUHourlyCost, []string{ source.NodeLabel, source.InstanceTypeLabel, source.ProviderIDLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg_over_time( // kubecost_node_is_spot{ // // }[1h] // ) func NewNodeIsSpotMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NodeIsSpotID, metric.KubecostNodeIsSpot, []string{ source.NodeLabel, source.ProviderIDLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // pod_pvc_allocation{ // // }[1h] // ) // ) by (persistentvolume, persistentvolumeclaim, pod, namespace, cluster_id) func NewPodPVCAllocationMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodPVCAllocationID, metric.PodPVCAllocation, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.PVLabel, source.PVCLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // kube_persistentvolumeclaim_resource_requests_storage_bytes{ // // }[1h] // ) // ) by (persistentvolumeclaim, namespace, cluster_id) func NewPVCBytesRequestedMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVCBytesRequestedID, metric.KubePersistentVolumeClaimResourceRequestsStorageBytes, []string{ source.NamespaceLabel, source.PVCLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // kube_persistentvolume_capacity_bytes{ // // }[1h] // ) // ) by (persistentvolume, cluster_id) func NewPVBytesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVBytesID, metric.KubePersistentVolumeCapacityBytes, []string{ source.PVLabel, source.UIDLabel, }, aggregator.AverageOverTime, nil, ) } // avg( // avg_over_time( // kubecost_pv_info{ // // }[1h] // ) // ) by (cluster_id, storageclass, persistentvolume, provider_id) func NewPVInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PVInfoID, metric.KubecostPVInfo, []string{ source.UIDLabel, source.PVLabel, source.StorageClassLabel, source.ProviderIDLabel, }, aggregator.AverageOverTime, nil, ) } // sum( // increase( // kubecost_pod_network_egress_bytes_total{ // internet="false", // same_zone="false", // same_region="true", // // }[1h] // ) // ) by (pod_name, namespace, cluster_id) / 1024 / 1024 / 1024 // func NewNetZoneGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetZoneGiBID, metric.KubecostPodNetworkEgressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.InternetLabel] == "false" && labels[source.SameZoneLabel] == "false" && labels[source.SameRegionLabel] == "true" }, ) } // avg( // avg_over_time( // kubecost_network_zone_egress_cost{ // // }[1h] // ) // ) by (cluster_id) // func NewNetZonePricePerGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetZonePricePerGiBID, metric.KubecostNetworkZoneEgressCost, []string{}, aggregator.AverageOverTime, nil, ) } // sum( // increase( // kubecost_pod_network_egress_bytes_total{ // internet="false", // same_zone="false", // same_region="false", // // }[1h] // ) // ) by (pod_name, namespace, cluster_id) / 1024 / 1024 / 1024 func NewNetRegionGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetRegionGiBID, metric.KubecostPodNetworkEgressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.InternetLabel] == "false" && labels[source.SameZoneLabel] == "false" && labels[source.SameRegionLabel] == "false" }, ) } // avg( // avg_over_time( // kubecost_network_region_egress_cost{ // // }[1h] // ) // ) by (cluster_id) func NewNetRegionPricePerGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetRegionPricePerGiBID, metric.KubecostNetworkRegionEgressCost, []string{}, aggregator.AverageOverTime, nil, ) } // sum( // increase( // kubecost_pod_network_egress_bytes_total{ // internet="true", // // }[1h] // ) // ) by (pod_name, namespace, cluster_id) / 1024 / 1024 / 1024 func NewNetInternetGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetInternetGiBID, metric.KubecostPodNetworkEgressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.InternetLabel] == "true" }, ) } // avg( // avg_over_time( // kubecost_network_internet_egress_cost{ // // }[1h] // ) // ) by (cluster_id) func NewNetInternetPricePerGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetInternetPricePerGiBID, metric.KubecostNetworkInternetEgressCost, []string{}, aggregator.AverageOverTime, nil, ) } // sum( // increase( // kubecost_pod_network_egress_bytes_total{ // internet="true", // // }[%s] // ) // ) by (pod_name, namespace, service, %s) / 1024 / 1024 / 1024 func NewNetInternetServiceGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetInternetServiceGiBID, metric.KubecostPodNetworkEgressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.ServiceLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.InternetLabel] == "true" }, ) } // sum( // increase( // kubecost_pod_network_egress_bytes_total{ // nat_gateway="true", // // }[1h] // ) // ) by (pod_name, namespace, uid, cluster_id) / 1024 / 1024 / 1024 func NewNetNatGatewayGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetNatGatewayGiBID, metric.KubecostPodNetworkEgressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { natLabel, labelExists := labels[source.NatGatewayLabel] return labelExists && natLabel == "true" }, ) } // avg( // avg_over_time( // kubecost_network_nat_gateway_egress_cost{ // // }[1h] // ) // ) by (cluster_id) func NewNetNatGatewayPricePerGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetNatGatewayPricePerGiBID, metric.KubecostNetworkNatGatewayEgressCost, []string{}, aggregator.AverageOverTime, nil, ) } // sum( // increase( // container_network_receive_bytes_total{ // pod!="", // // }[1h] // ) // ) by (pod_name, pod, namespace, cluster_id) func NewNetReceiveBytesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetReceiveBytesID, metric.ContainerNetworkReceiveBytesTotal, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.PodLabel] != "" }, ) } // sum( // increase( // kubecost_pod_network_ingress_bytes_total{ // internet="false", // same_zone="false", // same_region="true", // // }[1h] // ) // ) by (pod_name, namespace, cluster_id) / 1024 / 1024 / 1024 func NewNetZoneIngressGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetZoneIngressGiBID, metric.KubecostPodNetworkIngressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.InternetLabel] == "false" && labels[source.SameZoneLabel] == "false" && labels[source.SameRegionLabel] == "true" }, ) } // sum( // increase( // kubecost_pod_network_ingress_bytes_total{ // internet="false", // same_zone="false", // same_region="false", // // }[1h] // ) // ) by (pod_name, namespace, cluster_id) / 1024 / 1024 / 1024 func NewNetRegionIngressGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetRegionIngressGiBID, metric.KubecostPodNetworkIngressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.InternetLabel] == "false" && labels[source.SameZoneLabel] == "false" && labels[source.SameRegionLabel] == "false" }, ) } // sum( // increase( // kubecost_pod_network_ingress_bytes_total{ // internet="true", // // }[1h] // ) // ) by (pod_name, namespace, cluster_id) / 1024 / 1024 / 1024 func NewNetInternetIngressGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetInternetIngressGiBID, metric.KubecostPodNetworkIngressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.InternetLabel] == "true" }, ) } // `sum( // increase( // kubecost_pod_network_ingress_bytes_total{ // internet="true", // // }[1h] // ) // ) by (pod_name, namespace, service, cluster_id) / 1024 / 1024 / 1024 func NewNetInternetServiceIngressGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetInternetServiceIngressGiBID, metric.KubecostPodNetworkIngressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.ServiceLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.InternetLabel] == "true" }, ) } // avg( // avg_over_time( // kubecost_network_nat_gateway_ingress_cost{ // // }[1h] // ) // ) by (cluster_id) func NewNetNatGatewayIngressPricePerGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetNatGatewayIngressPricePerGiBID, metric.KubecostNetworkNatGatewayIngressCost, []string{}, aggregator.AverageOverTime, nil, ) } // sum( // increase( // kubecost_pod_network_ingress_bytes_total{ // nat_gateway="true", // // }[1h] // ) // ) by (pod_name, namespace, uid, cluster_id) / 1024 / 1024 / 1024 func NewNetNatGatewayIngressGiBMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetNatGatewayIngressGiBID, metric.KubecostPodNetworkIngressBytesTotal, []string{ source.NamespaceLabel, source.PodNameLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { natLabel, labelExists := labels[source.NatGatewayLabel] return labelExists && natLabel == "true" }, ) } // sum( // increase( // container_network_transmit_bytes_total{ // pod!="", // // }[1h] // ) // ) by (pod_name, pod, namespace, cluster_id) func NewNetTransferBytesMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NetTransferBytesID, metric.ContainerNetworkTransmitBytesTotal, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, }, aggregator.Increase, func(labels map[string]string) bool { return labels[source.PodLabel] != "" }, ) } func NewNamespaceInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NamespaceInfoID, metric.NamespaceInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } // avg( // namespace_info{ // // } // ) by (uid)[%s:%dm] func NewNamespaceUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NamespaceUptimeID, metric.NamespaceInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } // avg_over_time( // kube_namespace_labels{ // // }[1h] // ) func NewNamespaceLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NamespaceLabelsID, metric.KubeNamespaceLabels, []string{ source.NamespaceLabel, source.UIDLabel, }, aggregator.Info, nil, ) } // avg_over_time( // kube_namespace_annotations{ // // }[1h] // ) func NewNamespaceAnnotationsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.NamespaceAnnotationsID, metric.KubeNamespaceAnnotations, []string{ source.NamespaceLabel, source.UIDLabel, }, aggregator.Info, nil, ) } // avg_over_time( // kube_pod_labels{ // // }[1h] // ) func NewPodLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodLabelsID, metric.KubePodLabels, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, }, aggregator.Info, nil, ) } // avg_over_time( // kube_pod_annotations{ // // }[1h] // ) func NewPodAnnotationsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodAnnotationsID, metric.KubePodAnnotations, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, }, aggregator.Info, nil, ) } func NewServiceInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ServiceInfoID, metric.ServiceInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewServiceUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ServiceUptimeID, metric.ServiceInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } // avg_over_time( // service_selector_labels{ // // }[1h] // ) func NewServiceLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ServiceLabelsID, metric.ServiceSelectorLabels, []string{ source.NamespaceLabel, source.ServiceLabel, source.UIDLabel, }, aggregator.Info, nil, ) } // avg_over_time( // deployment_match_labels{ // // }[1h] // ) func NewDeploymentInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DeploymentInfoID, metric.DeploymentInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewDeploymentUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DeploymentUptimeID, metric.DeploymentInfo, []string{ source.UIDLabel, source.NamespaceUIDLabel, source.DeploymentLabel, }, aggregator.Uptime, nil, ) } func NewDeploymentLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DeploymentLabelsID, metric.DeploymentLabels, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewDeploymentAnnotationsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DeploymentAnnotationsID, metric.DeploymentAnnotations, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewDeploymentMatchLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DeploymentMatchLabelsID, metric.DeploymentMatchLabels, []string{ source.NamespaceLabel, source.DeploymentLabel, source.UIDLabel, }, aggregator.Info, nil, ) } func NewStatefulSetInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.StatefulSetInfoID, metric.StatefulSetInfo, []string{ source.UIDLabel, source.NamespaceUIDLabel, source.StatefulSetLabel, }, aggregator.Info, nil, ) } func NewStatefulSetUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.StatefulSetUptimeID, metric.StatefulSetInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewStatefulSetLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.StatefulSetLabelsID, metric.StatefulSetLabels, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewStatefulSetAnnotationsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.StatefulSetAnnotationsID, metric.StatefulSetAnnotations, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } // avg_over_time( // statefulSet_match_labels{ // // }[1h] // ) func NewStatefulSetMatchLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.StatefulSetMatchLabelsID, metric.StatefulSetMatchLabels, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewDaemonSetInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DaemonSetInfoID, metric.DaemonSetInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewDaemonSetUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DaemonSetUptimeID, metric.DaemonSetInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewDaemonSetLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DaemonSetLabelsID, metric.DaemonSetLabels, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewDaemonSetAnnotationsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.DaemonSetAnnotationsID, metric.DaemonSetAnnotations, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewJobInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.JobInfoID, metric.JobInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } func NewJobUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.JobUptimeID, metric.JobInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewJobLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.JobLabelsID, metric.JobLabels, []string{ source.NamespaceLabel, source.JobLabel, source.UIDLabel, }, aggregator.Info, nil, ) } func NewJobAnnotationsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.JobAnnotationsID, metric.JobAnnotations, []string{ source.NamespaceLabel, source.JobLabel, source.UIDLabel, }, aggregator.Info, nil, ) } func NewCronJobInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.CronJobInfoID, metric.CronJobInfo, []string{ source.UIDLabel, source.NamespaceUIDLabel, source.CronJobLabel, }, aggregator.Info, nil, ) } func NewCronJobUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.CronJobUptimeID, metric.CronJobInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewCronJobLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.CronJobLabelsID, metric.CronJobLabels, []string{ source.NamespaceLabel, source.CronJobLabel, source.UIDLabel, }, aggregator.Info, nil, ) } func NewCronJobAnnotationsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.CronJobAnnotationsID, metric.CronJobAnnotations, []string{ source.NamespaceLabel, source.CronJobLabel, source.UIDLabel, }, aggregator.Info, nil, ) } func NewReplicaSetInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ReplicaSetInfoID, metric.ReplicaSetInfo, []string{ source.UIDLabel, source.NamespaceUIDLabel, source.ReplicaSetLabel, }, aggregator.Info, nil, ) } func NewReplicaSetUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ReplicaSetUptimeID, metric.ReplicaSetInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewReplicaSetLabelsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ReplicaSetLabelsID, metric.ReplicaSetLabels, []string{ source.NamespaceLabel, source.ReplicaSetLabel, source.UIDLabel, }, aggregator.Info, nil, ) } func NewReplicaSetAnnotationsMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ReplicaSetAnnotationsID, metric.ReplicaSetAnnotations, []string{ source.NamespaceLabel, source.ReplicaSetLabel, source.UIDLabel, }, aggregator.Info, nil, ) } func NewReplicaSetOwnerMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ReplicaSetOwnerID, metric.KubeReplicasetOwner, []string{ source.UIDLabel, source.OwnerUIDLabel, source.OwnerKindLabel, }, aggregator.Info, nil, ) } // sum( // avg_over_time( // kube_pod_owner{ // owner_kind="DaemonSet", // // }[1h] // ) // ) by (pod, owner_name, namespace, cluster_id) func NewPodsWithDaemonSetOwnerMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodsWithDaemonSetOwnerID, metric.KubePodOwner, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.OwnerNameLabel, }, aggregator.Info, func(labels map[string]string) bool { return labels[source.OwnerKindLabel] == "DaemonSet" }, ) } // sum( // avg_over_time( // kube_pod_owner{ // owner_kind="Job", // // }[1h] // ) // ) by (pod, owner_name, namespace, cluster_id) func NewPodsWithJobOwnerMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodsWithJobOwnerID, metric.KubePodOwner, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.OwnerNameLabel, }, aggregator.Info, func(labels map[string]string) bool { return labels[source.OwnerKindLabel] == "Job" }, ) } // sum( // avg_over_time( // kube_pod_owner{ // owner_kind="ReplicaSet", // // }[1h] // ) // ) by (pod, owner_name, namespace, cluster_id) func NewPodsWithReplicaSetOwnerMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.PodsWithReplicaSetOwnerID, metric.KubePodOwner, []string{ source.NamespaceLabel, source.PodLabel, source.UIDLabel, source.OwnerNameLabel, }, aggregator.Info, func(labels map[string]string) bool { return labels[source.OwnerKindLabel] == "ReplicaSet" }, ) } // sum( // avg_over_time( // kube_replicaset_owner{ // owner_kind="", // owner_name="", // // }[1h] // ) // ) by (replicaset, namespace, cluster_id) func NewReplicaSetsWithoutOwnersMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ReplicaSetsWithoutOwnersID, metric.KubeReplicasetOwner, []string{ source.NamespaceLabel, source.ReplicaSetLabel, source.UIDLabel, }, aggregator.Info, func(labels map[string]string) bool { return labels[source.OwnerKindLabel] == "" && labels[source.OwnerNameLabel] == "" }, ) } // sum( // avg_over_time( // kube_replicaset_owner{ // owner_kind="Rollout", // // }[1h] // ) // ) by (replicaset, namespace, owner_kind, owner_name, cluster_id) func NewReplicaSetsWithRolloutMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ReplicaSetsWithRolloutID, metric.KubeReplicasetOwner, []string{ source.NamespaceLabel, source.ReplicaSetLabel, source.UIDLabel, source.OwnerNameLabel, source.OwnerKindLabel, }, aggregator.Info, func(labels map[string]string) bool { return labels[source.OwnerKindLabel] == "Rollout" }, ) } func NewResourceQuotaInfoMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaInfoID, metric.ResourceQuotaInfo, []string{ source.UIDLabel, }, aggregator.Info, nil, ) } // avg( // resourcequota_info{ // // } // ) by (uid)[%s:%dm] func NewResourceQuotaUptimeMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaUptimeID, metric.ResourceQuotaInfo, []string{ source.UIDLabel, }, aggregator.Uptime, nil, ) } func NewResourceQuotaSpecCPURequestAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaSpecCPURequestAverageID, metric.KubeResourceQuotaSpecResourceRequests, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" }, ) } // max( // max_over_time( // resourcequota_spec_resource_requests{ // resource="cpu", // unit="core", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaSpecCPURequestMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaSpecCPURequestMaxID, metric.KubeResourceQuotaSpecResourceRequests, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" }, ) } // avg( // avg_over_time( // resourcequota_spec_resource_requests{ // resource="memory", // unit="byte", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaSpecRAMRequestAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaSpecRAMRequestAverageID, metric.KubeResourceQuotaSpecResourceRequests, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" }, ) } // max( // max_over_time( // resourcequota_spec_resource_requests{ // resource="memory", // unit="byte", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaSpecRAMRequestMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaSpecRAMRequestMaxID, metric.KubeResourceQuotaSpecResourceRequests, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" }, ) } // avg( // avg_over_time( // resourcequota_spec_resource_limits{ // resource="cpu", // unit="core", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaSpecCPULimitAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaSpecCPULimitAverageID, metric.KubeResourceQuotaSpecResourceLimits, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" }, ) } // max( // max_over_time( // resourcequota_spec_resource_limits{ // resource="cpu", // unit="core", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaSpecCPULimitMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaSpecCPULimitMaxID, metric.KubeResourceQuotaSpecResourceLimits, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" }, ) } // avg( // avg_over_time( // resourcequota_spec_resource_limits{ // resource="memory", // unit="byte", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaSpecRAMLimitAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaSpecRAMLimitAverageID, metric.KubeResourceQuotaSpecResourceLimits, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" }, ) } // max( // max_over_time( // resourcequota_spec_resource_limits{ // resource="memory", // unit="byte", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaSpecRAMLimitMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaSpecRAMLimitMaxID, metric.KubeResourceQuotaSpecResourceLimits, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" }, ) } // avg( // avg_over_time( // resourcequota_status_used_resource_requests{ // resource="cpu", // unit="core", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaStatusUsedCPURequestAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaStatusUsedCPURequestAverageID, metric.KubeResourceQuotaStatusUsedResourceRequests, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" }, ) } // max( // max_over_time( // resourcequota_status_used_resource_requests{ // resource="cpu", // unit="core", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaStatusUsedCPURequestMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaStatusUsedCPURequestMaxID, metric.KubeResourceQuotaStatusUsedResourceRequests, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" }, ) } // avg( // avg_over_time( // resourcequota_status_used_resource_requests{ // resource="memory", // unit="byte", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaStatusUsedRAMRequestAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaStatusUsedRAMRequestAverageID, metric.KubeResourceQuotaStatusUsedResourceRequests, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" }, ) } // max( // max_over_time( // resourcequota_status_used_resource_requests{ // resource="memory", // unit="byte", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaStatusUsedRAMRequestMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaStatusUsedRAMRequestMaxID, metric.KubeResourceQuotaStatusUsedResourceRequests, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" }, ) } // avg( // avg_over_time( // resourcequota_status_used_resource_limits{ // resource="cpu", // unit="core", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaStatusUsedCPULimitAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaStatusUsedCPULimitAverageID, metric.KubeResourceQuotaStatusUsedResourceLimits, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" }, ) } // max( // max_over_time( // resourcequota_status_used_resource_limits{ // resource="cpu", // unit="core", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaStatusUsedCPULimitMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaStatusUsedCPULimitMaxID, metric.KubeResourceQuotaStatusUsedResourceLimits, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "cpu" && labels[source.UnitLabel] == "core" }, ) } // avg( // avg_over_time( // resourcequota_status_used_resource_limits{ // resource="memory", // unit="byte", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaStatusUsedRAMLimitAverageMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaStatusUsedRAMLimitAverageID, metric.KubeResourceQuotaStatusUsedResourceLimits, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.AverageOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" }, ) } // max( // max_over_time( // resourcequota_status_used_resource_limits{ // resource="memory", // unit="byte", // // }[1h] // ) //) by (resourcequota, namespace, uid, cluster_id) func NewResourceQuotaStatusUsedRAMLimitMaxMetricCollector() *metric.MetricCollector { return metric.NewMetricCollector( metric.ResourceQuotaStatusUsedRAMLimitMaxID, metric.KubeResourceQuotaStatusUsedResourceLimits, []string{ source.NamespaceLabel, source.ResourceQuotaLabel, source.UIDLabel, }, aggregator.MaxOverTime, func(labels map[string]string) bool { return labels[source.ResourceLabel] == "memory" && labels[source.UnitLabel] == "byte" }, ) }