From 9e85ce0046283488f971b80e5cdfd0c5ccc76d88 Mon Sep 17 00:00:00 2001 From: Jiacai Liu Date: Thu, 11 May 2023 15:22:14 +0800 Subject: [PATCH] fix: new multiple write requests when tag names are different in prom write (#888) --- proxy/src/http/prom.rs | 3 ++- proxy/src/influxdb/types.rs | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/proxy/src/http/prom.rs b/proxy/src/http/prom.rs index 64a958c19a..a27e0010c9 100644 --- a/proxy/src/http/prom.rs +++ b/proxy/src/http/prom.rs @@ -407,7 +407,8 @@ fn convert_write_request(req: WriteRequest) -> Result> { .unzip(); req_by_metric - .entry(metric.to_string()) + // fields with same tag names will be grouped together + .entry((metric.clone(), tag_names.clone())) .or_insert_with(|| WriteTableRequest { table: metric, tag_names, diff --git a/proxy/src/influxdb/types.rs b/proxy/src/influxdb/types.rs index c55213e8a7..2280e4a11d 100644 --- a/proxy/src/influxdb/types.rs +++ b/proxy/src/influxdb/types.rs @@ -491,12 +491,16 @@ pub(crate) fn convert_write_request(req: WriteRequest) -> Result>(); let req_for_one_measurement = req_by_measurement - .entry(line.series.measurement.to_string()) + // fields with same tag names will be grouped together + .entry((line.series.measurement.to_string(), tag_names.clone())) .or_insert_with(|| WriteTableRequest { table: line.series.measurement.to_string(), - tag_names: tag_set.iter().map(|(tagk, _)| tagk.to_string()).collect(), + tag_names, field_names: line .field_set .iter()