Skip to content

Commit 6adffd2

Browse files
authored
metrics: Add target_ip and target_port labels (#1238)
The `target_addr` label encodes both the IP address and port in a single string. This makes certain grouping operations cumbersome. In order to support more flexible queries, this change adds `target_ip` and `target_port` labels in addition to the existing `target_addr` label. This should have a negligible impact on prometheus, since it doesn't actually increase timeseries cardinality.
1 parent 1627f35 commit 6adffd2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

linkerd/app/core/src/transport/labels.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,13 @@ impl<'t> FmtLabels for TlsConnect<'t> {
177177

178178
impl FmtLabels for TargetAddr {
179179
fn fmt_labels(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
180-
write!(f, "target_addr=\"{}\"", self.0)
180+
write!(
181+
f,
182+
"target_addr=\"{}\",target_ip=\"{}\",target_port=\"{}\"",
183+
self.0,
184+
self.0.ip(),
185+
self.0.port()
186+
)
181187
}
182188
}
183189

@@ -210,8 +216,10 @@ mod tests {
210216
);
211217
assert_eq!(
212218
labels.to_string(),
213-
"direction=\"inbound\",peer=\"src\",target_addr=\"192.0.2.4:40000\",tls=\"true\",\
214-
client_id=\"foo.id.example.com\",srv_name=\"testserver\",saz_name=\"testauthz\""
219+
"direction=\"inbound\",peer=\"src\",\
220+
target_addr=\"192.0.2.4:40000\",target_ip=\"192.0.2.4\",target_port=\"40000\",\
221+
tls=\"true\",client_id=\"foo.id.example.com\",\
222+
srv_name=\"testserver\",saz_name=\"testauthz\""
215223
);
216224
}
217225
}

0 commit comments

Comments
 (0)