Skip to content

Commit

Permalink
fix: new multiple write requests when tag names are different in prom…
Browse files Browse the repository at this point in the history
… write (#888)
  • Loading branch information
jiacai2050 authored May 11, 2023
1 parent b27a72f commit 9e85ce0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion proxy/src/http/prom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ fn convert_write_request(req: WriteRequest) -> Result<Vec<WriteTableRequest>> {
.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,
Expand Down
10 changes: 7 additions & 3 deletions proxy/src/influxdb/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,16 @@ pub(crate) fn convert_write_request(req: WriteRequest) -> Result<Vec<WriteTableR
tag_set.sort_unstable_by(|a, b| a.0.cmp(&b.0));
// sort by field key
line.field_set.sort_unstable_by(|a, b| a.0.cmp(&b.0));

let tag_names = tag_set
.iter()
.map(|(tagk, _)| tagk.to_string())
.collect::<Vec<_>>();
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()
Expand Down

0 comments on commit 9e85ce0

Please sign in to comment.