| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467 |
- 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(NewPVActiveMinutesMetricCollector())
- memStore.Register(NewLocalStorageUsedActiveMinutesMetricCollector())
- memStore.Register(NewLocalStorageUsedAverageMetricCollector())
- memStore.Register(NewLocalStorageUsedMaxMetricCollector())
- memStore.Register(NewLocalStorageBytesMetricCollector())
- memStore.Register(NewLocalStorageActiveMinutesMetricCollector())
- 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(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(NewNodeCPUPricePerHourMetricCollector())
- memStore.Register(NewNodeRAMPricePerGiBHourMetricCollector())
- memStore.Register(NewNodeGPUPricePerHourMetricCollector())
- memStore.Register(NewNodeIsSpotMetricCollector())
- memStore.Register(NewPodPVCAllocationMetricCollector())
- memStore.Register(NewPVCBytesRequestedMetricCollector())
- memStore.Register(NewPVBytesMetricCollector())
- memStore.Register(NewPVInfoMetricCollector())
- 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(NewNamespaceUptimeMetricCollector())
- memStore.Register(NewNamespaceLabelsMetricCollector())
- memStore.Register(NewNamespaceAnnotationsMetricCollector())
- memStore.Register(NewPodLabelsMetricCollector())
- memStore.Register(NewPodAnnotationsMetricCollector())
- memStore.Register(NewServiceLabelsMetricCollector())
- memStore.Register(NewDeploymentLabelsMetricCollector())
- memStore.Register(NewStatefulSetLabelsMetricCollector())
- memStore.Register(NewDaemonSetLabelsMetricCollector())
- memStore.Register(NewJobLabelsMetricCollector())
- memStore.Register(NewPodsWithReplicaSetOwnerMetricCollector())
- memStore.Register(NewReplicaSetsWithoutOwnersMetricCollector())
- memStore.Register(NewReplicaSetsWithRolloutMetricCollector())
- 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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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,
- )
- }
- // avg(
- // kube_persistentvolumeclaim_info{
- // volumename != "",
- // <some_custom_filter>
- // }
- // ) 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] != ""
- },
- )
- }
- // avg(
- // kube_persistentvolume_capacity_bytes{
- // <some_custom_filter>
- // }
- // ) by (cluster_id, persistentvolume)[0:10m]
- func NewPVActiveMinutesMetricCollector() *metric.MetricCollector {
- return metric.NewMetricCollector(
- metric.PVActiveMinutesID,
- metric.KubePersistentVolumeCapacityBytes,
- []string{
- source.PVLabel,
- source.UIDLabel,
- },
- aggregator.Uptime,
- nil,
- )
- }
- // sum_over_time(
- //
- // sum(
- // container_fs_usage_bytes{
- // device=~"/dev/(nvme|sda).*",
- // id="/",
- // <some_custom_filter>
- // }
- // ) by (instance, device, cluster_id)[%s:%dm]
- //
- // ) / 1024 / 1024 / 1024 * %f * %f`
- // NewLocalStorageUsedActiveMinutesMetricCollector does not have an associated query end point but is used in the results
- // of QueryLocalStorageUsedCost
- func NewLocalStorageUsedActiveMinutesMetricCollector() *metric.MetricCollector {
- return metric.NewMetricCollector(
- metric.LocalStorageUsedActiveMinutesID,
- metric.ContainerFSUsageBytes,
- []string{
- source.InstanceLabel,
- source.DeviceLabel,
- source.UIDLabel,
- },
- 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="/",
- // <some_custom_filter>
- // }[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,
- source.UIDLabel,
- },
- 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="/",
- // <some_custom_filter>
- // }[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,
- source.UIDLabel,
- },
- 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="/",
- // <some_custom_filter>
- // }
- // ) 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
- )
- }
- // count(
- //
- // kube_node_labels{
- // <some_custom_filter>
- // }
- //
- // ) 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,
- )
- }
- // avg(
- //
- // avg_over_time(
- // kube_node_status_capacity_cpu_cores{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[1h]
- // )
- func NewNodeLabelsMetricCollector() *metric.MetricCollector {
- return metric.NewMetricCollector(
- metric.NodeLabelsID,
- metric.KubeNodeLabels,
- []string{
- source.NodeLabel,
- source.UIDLabel,
- },
- aggregator.Info,
- nil,
- )
- }
- // avg(
- // kube_node_labels{
- // <some_custom_filter>
- // }
- // ) 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{
- // <some_custom_filter>
- // }[%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",
- // <some_custom_filter>
- // }[%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",
- // <some_custom_filter>
- // }[%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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }
- // ) 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,
- )
- }
- // avg(
- // cluster_info{
- // <some_custom_filter>
- // }
- // ) 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{
- // <some_custom_filter>
- // }
- // ) 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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // } != 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,
- )
- }
- // avg(
- // avg_over_time(
- // container_memory_allocation_bytes{
- // container!="",
- // container!="POD",
- // node!="",
- // <some_custom_filter>
- // }[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!="",
- // <some_custom_filter>
- // }[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!="",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[%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!="",
- // <some_custom_filter>
- // }[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!="",
- // <some_custom_filter>
- // }[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!="",
- // <some_custom_filter>
- // }[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] != ""
- },
- )
- }
- // avg(
- // rate(
- // container_cpu_usage_seconds_total{
- // container!="",
- // container_name!="POD",
- // container!="POD",
- // <some_custom_filter>
- // }[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!="",
- // <some_custom_filter>
- // }[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!="",
- // <some_custom_filter>
- // }[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.UIDLabel,
- 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.UIDLabel,
- 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!="",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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!="",
- // <some_custom_filter>
- // }[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.UIDLabel,
- source.ContainerLabel,
- source.DeviceLabel,
- source.ModelNameLabel,
- source.UUIDLabel,
- },
- aggregator.Info,
- func(labels map[string]string) bool {
- return labels[source.ContainerLabel] != ""
- },
- )
- }
- // avg(
- // avg_over_time(
- // node_cpu_hourly_cost{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[1h]
- // )
- // ) by (cluster_id, storageclass, persistentvolume, provider_id)
- func NewPVInfoMetricCollector() *metric.MetricCollector {
- return metric.NewMetricCollector(
- metric.PVInfoID,
- metric.KubecostPVInfo,
- []string{
- source.PVLabel,
- source.StorageClassLabel,
- source.ProviderIDLabel,
- source.UIDLabel,
- },
- aggregator.AverageOverTime,
- nil,
- )
- }
- // sum(
- // increase(
- // kubecost_pod_network_egress_bytes_total{
- // internet="false",
- // same_zone="false",
- // same_region="true",
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[%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",
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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!="",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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!="",
- // <some_custom_filter>
- // }[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] != ""
- },
- )
- }
- // avg(
- // namespace_info{
- // <some_custom_filter>
- // }
- // ) 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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[1h]
- // )
- func NewPodAnnotationsMetricCollector() *metric.MetricCollector {
- return metric.NewMetricCollector(
- metric.PodAnnotationsID,
- metric.KubePodAnnotations,
- []string{
- source.NamespaceLabel,
- source.PodLabel,
- source.UIDLabel,
- },
- aggregator.Info,
- nil,
- )
- }
- // avg_over_time(
- // service_selector_labels{
- // <some_custom_filter>
- // }[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{
- // <some_custom_filter>
- // }[1h]
- // )
- func NewDeploymentLabelsMetricCollector() *metric.MetricCollector {
- return metric.NewMetricCollector(
- metric.DeploymentLabelsID,
- metric.DeploymentMatchLabels,
- []string{
- source.NamespaceLabel,
- source.DeploymentLabel,
- source.UIDLabel,
- },
- aggregator.Info,
- nil,
- )
- }
- // avg_over_time(
- // statefulSet_match_labels{
- // <some_custom_filter>
- // }[1h]
- // )
- func NewStatefulSetLabelsMetricCollector() *metric.MetricCollector {
- return metric.NewMetricCollector(
- metric.StatefulSetLabelsID,
- metric.StatefulSetMatchLabels,
- []string{
- source.NamespaceLabel,
- source.StatefulSetLabel,
- source.UIDLabel,
- },
- aggregator.Info,
- nil,
- )
- }
- // sum(
- // avg_over_time(
- // kube_pod_owner{
- // owner_kind="DaemonSet",
- // <some_custom_filter>
- // }[1h]
- // )
- // ) by (pod, owner_name, namespace, cluster_id)
- func NewDaemonSetLabelsMetricCollector() *metric.MetricCollector {
- return metric.NewMetricCollector(
- metric.DaemonSetLabelsID,
- 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",
- // <some_custom_filter>
- // }[1h]
- // )
- // ) by (pod, owner_name, namespace, cluster_id)
- func NewJobLabelsMetricCollector() *metric.MetricCollector {
- return metric.NewMetricCollector(
- metric.JobLabelsID,
- 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",
- // <some_custom_filter>
- // }[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="<none>",
- // owner_name="<none>",
- // <some_custom_filter>
- // }[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] == "<none>" && labels[source.OwnerNameLabel] == "<none>"
- },
- )
- }
- // sum(
- // avg_over_time(
- // kube_replicaset_owner{
- // owner_kind="Rollout",
- // <some_custom_filter>
- // }[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"
- },
- )
- }
- // avg(
- // resourcequota_info{
- // <some_custom_filter>
- // }
- // ) 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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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",
- // <some_custom_filter>
- // }[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"
- },
- )
- }
|