| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465 |
- 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`
- 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"
- },
- )
- }
|