diff --git a/receiver/awscontainerinsightreceiver/internal/gpu/dcgmscraper.go b/receiver/awscontainerinsightreceiver/internal/gpu/dcgmscraper.go index db7bdc184425..475c5bc996e2 100644 --- a/receiver/awscontainerinsightreceiver/internal/gpu/dcgmscraper.go +++ b/receiver/awscontainerinsightreceiver/internal/gpu/dcgmscraper.go @@ -56,6 +56,7 @@ type DcgmScraperOpts struct { type hostInfoProvider interface { GetClusterName() string GetInstanceID() string + GetInstanceType() string } func NewDcgmScraper(opts DcgmScraperOpts) (*DcgmScraper, error) { @@ -170,6 +171,13 @@ func getMetricRelabelConfig(hostInfoProvider hostInfoProvider) []*relabel.Config Replacement: hostInfoProvider.GetInstanceID(), Action: relabel.Replace, }, + { + SourceLabels: model.LabelNames{"namespace"}, + TargetLabel: ci.InstanceType, + Regex: relabel.MustNewRegexp(".*"), + Replacement: hostInfoProvider.GetInstanceType(), + Action: relabel.Replace, + }, { SourceLabels: model.LabelNames{"pod"}, TargetLabel: ci.AttributeFullPodName, diff --git a/receiver/awscontainerinsightreceiver/internal/gpu/dcgmscraper_test.go b/receiver/awscontainerinsightreceiver/internal/gpu/dcgmscraper_test.go index 7d59f1be53a6..060fb94b12df 100644 --- a/receiver/awscontainerinsightreceiver/internal/gpu/dcgmscraper_test.go +++ b/receiver/awscontainerinsightreceiver/internal/gpu/dcgmscraper_test.go @@ -35,8 +35,9 @@ DCGM_FI_DEV_GPU_UTIL{gpu="0",UUID="uuid",device="nvidia0",modelName="NVIDIA A10G ` const ( - dummyInstanceID = "i-0000000000" - dummyClusterName = "cluster-name" + dummyInstanceID = "i-0000000000" + dummyClusterName = "cluster-name" + dummyInstanceType = "instance-type" ) type mockHostInfoProvider struct { @@ -50,6 +51,10 @@ func (m mockHostInfoProvider) GetInstanceID() string { return dummyInstanceID } +func (m mockHostInfoProvider) GetInstanceType() string { + return dummyInstanceType +} + type mockDecorator struct { } @@ -151,6 +156,7 @@ func TestNewDcgmScraperEndToEnd(t *testing.T) { ci.AttributeK8sNamespace: "kube-system", ci.ClusterNameKey: dummyClusterName, ci.InstanceID: dummyInstanceID, + ci.InstanceType: dummyInstanceType, ci.AttributeFullPodName: "fullname-hash", ci.AttributeK8sPodName: "fullname-hash", ci.AttributeContainerName: "main", @@ -164,6 +170,7 @@ func TestNewDcgmScraperEndToEnd(t *testing.T) { ci.AttributeK8sNamespace: "kube-system", ci.ClusterNameKey: dummyClusterName, ci.InstanceID: dummyInstanceID, + ci.InstanceType: dummyInstanceType, ci.AttributeFullPodName: "fullname-hash", ci.AttributeK8sPodName: "fullname-hash", ci.AttributeContainerName: "main",