From 1dfb596c1f782117ac616847e3c2e1673e4d4e34 Mon Sep 17 00:00:00 2001 From: Naman-B-Parlecha Date: Sun, 22 Mar 2026 17:09:18 +0530 Subject: [PATCH 1/4] fix(receiver/prometheusremotewrite): count target_info samples in PRW 2.0 response stats Signed-off-by: Naman-B-Parlecha --- .../prometheusremotewritereceiver/receiver.go | 3 ++ .../receiver_test.go | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/receiver/prometheusremotewritereceiver/receiver.go b/receiver/prometheusremotewritereceiver/receiver.go index bc34be2f5f77a..a99807ba30378 100644 --- a/receiver/prometheusremotewritereceiver/receiver.go +++ b/receiver/prometheusremotewritereceiver/receiver.go @@ -342,6 +342,9 @@ func (prw *prometheusRemoteWriteReceiver) translateV2(_ context.Context, req *wr snapshot := pmetric.NewResourceMetrics() attrs.CopyTo(snapshot.Resource().Attributes()) prw.rmCache.Add(hashed, snapshot) + // target_info is not stored as a metric but PRW requires the response + // to report all received samples, including target_info, to avoid a stats mismat + stats.Samples += len(ts.Samples) continue } diff --git a/receiver/prometheusremotewritereceiver/receiver_test.go b/receiver/prometheusremotewritereceiver/receiver_test.go index c2c075c79ae60..7fcd441fbd173 100644 --- a/receiver/prometheusremotewritereceiver/receiver_test.go +++ b/receiver/prometheusremotewritereceiver/receiver_test.go @@ -2255,6 +2255,48 @@ func TestTranslateV2(t *testing.T) { Confirmed: true, }, }, + { + name: "service with only target_info metric", + request: &writev2.Request{ + Symbols: []string{ + "", + "job", "production/service_a", // 1, 2 + "instance", "host1", // 3, 4 + "machine_type", "n1-standard-1", // 5, 6 + "cloud_provider", "gcp", // 7, 8 + "region", "us-central1", // 9, 10 + "datacenter", "sdc", // 11, 12 + "__name__", "target_info", // 13, 14 + }, + Timeseries: []writev2.TimeSeries{ + { + // target_info metric + Metadata: writev2.Metadata{Type: writev2.Metadata_METRIC_TYPE_GAUGE}, + LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, + Samples: []writev2.Sample{{Value: 1, Timestamp: 1}}, + }, + }, + }, + expectedMetrics: func() pmetric.Metrics { + metrics := pmetric.NewMetrics() + rm := metrics.ResourceMetrics().AppendEmpty() + attrs := rm.Resource().Attributes() + attrs.PutStr("service.namespace", "production") + attrs.PutStr("service.name", "service_a") + attrs.PutStr("service.instance.id", "host1") + attrs.PutStr("machine_type", "n1-standard-1") + attrs.PutStr("cloud_provider", "gcp") + attrs.PutStr("region", "us-central1") + attrs.PutStr("datacenter", "sdc") + return metrics + }(), + expectedStats: remote.WriteResponseStats{ + Confirmed: true, + Samples: 1, + Histograms: 0, + Exemplars: 0, + }, + }, } { t.Run(tc.name, func(t *testing.T) { // since we are using the rmCache to store values across requests, we need to clear it after each test, otherwise it will affect the next test From b286ecc50a4b8825502fb7127cb44471aa99f169 Mon Sep 17 00:00:00 2001 From: NamanParlecha Date: Tue, 24 Mar 2026 02:25:47 +0530 Subject: [PATCH 2/4] Update receiver/prometheusremotewritereceiver/receiver.go Co-authored-by: David Ashpole --- receiver/prometheusremotewritereceiver/receiver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receiver/prometheusremotewritereceiver/receiver.go b/receiver/prometheusremotewritereceiver/receiver.go index a99807ba30378..6165b45077fae 100644 --- a/receiver/prometheusremotewritereceiver/receiver.go +++ b/receiver/prometheusremotewritereceiver/receiver.go @@ -343,7 +343,7 @@ func (prw *prometheusRemoteWriteReceiver) translateV2(_ context.Context, req *wr attrs.CopyTo(snapshot.Resource().Attributes()) prw.rmCache.Add(hashed, snapshot) // target_info is not stored as a metric but PRW requires the response - // to report all received samples, including target_info, to avoid a stats mismat + // to report all received samples, including target_info, to avoid a stats mismatch stats.Samples += len(ts.Samples) continue } From d66bdb9a713b843fef4ee5cd57287067c1f2567a Mon Sep 17 00:00:00 2001 From: Naman-B-Parlecha Date: Mon, 30 Mar 2026 23:31:10 +0530 Subject: [PATCH 3/4] chore: add changelog Signed-off-by: Naman-B-Parlecha --- .chloggen/47108.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .chloggen/47108.yaml diff --git a/.chloggen/47108.yaml b/.chloggen/47108.yaml new file mode 100644 index 0000000000000..d5c68b246e9e7 --- /dev/null +++ b/.chloggen/47108.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog) +component: receiver/prometheusremotewrite + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Count target_info samples in PRW response stats + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [47108] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] From 95d8002bc3547a6cb084f34d490cbf6b9cb76472 Mon Sep 17 00:00:00 2001 From: NamanParlecha Date: Tue, 31 Mar 2026 00:45:10 +0530 Subject: [PATCH 4/4] Update .chloggen/47108.yaml Co-authored-by: Yang Song --- .chloggen/47108.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chloggen/47108.yaml b/.chloggen/47108.yaml index d5c68b246e9e7..3f12789ad2f99 100644 --- a/.chloggen/47108.yaml +++ b/.chloggen/47108.yaml @@ -4,7 +4,7 @@ change_type: bug_fix # The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog) -component: receiver/prometheusremotewrite +component: receiver/prometheus_remote_write # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). note: Count target_info samples in PRW response stats