diff --git a/receiver/prometheusreceiver/internal/transaction.go b/receiver/prometheusreceiver/internal/transaction.go index 0719e931e28..7f4aad0b88c 100644 --- a/receiver/prometheusreceiver/internal/transaction.go +++ b/receiver/prometheusreceiver/internal/transaction.go @@ -36,8 +36,10 @@ import ( ) const ( - portAttr = "port" - schemeAttr = "scheme" + portAttr = "port" + schemeAttr = "scheme" + jobAttr = "job" + instanceAttr = "instance" transport = "http" dataformat = "prometheus" @@ -227,8 +229,10 @@ func createNodeAndResource(job, instance, scheme string) (*commonpb.Node, *resou } resource := &resourcepb.Resource{ Labels: map[string]string{ - portAttr: port, - schemeAttr: scheme, + jobAttr: job, + instanceAttr: instance, + portAttr: port, + schemeAttr: scheme, }, } return node, resource diff --git a/receiver/prometheusreceiver/metrics_receiver_test.go b/receiver/prometheusreceiver/metrics_receiver_test.go index cabdb3852e1..11759ab8a9e 100644 --- a/receiver/prometheusreceiver/metrics_receiver_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_test.go @@ -155,8 +155,10 @@ func setupMockPrometheus(tds ...*testData) (*mockPrometheus, *promcfg.Config, er } t.resource = &resourcepb.Resource{ Labels: map[string]string{ - "scheme": "http", - "port": port, + "instance": u.Host, + "job": t.name, + "scheme": "http", + "port": port, }, } }