Skip to content

Commit 28009dc

Browse files
feat: remove high cardinality metric labels
This MR removes these labels from the fmtLabel implementation of Outbound/InboundEndpointMetrics These metrics will be removed: target_addr, dst_pod, dst_pod_template_hash, dst_zone, authority They are all metrics with high cardinality This MR also reduces the number of buckets for response_latency_bucket_ms metric. It will use another approach for the larger buckets: instead of deleting buckets in a roll, it will buckets alternately
1 parent d76dda3 commit 28009dc

File tree

13 files changed

+41
-236
lines changed

13 files changed

+41
-236
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ env:
4949
CARGO_INCREMENTAL: 0
5050
CARGO_NET_RETRY: 10
5151
RUSTFLAGS: "-D warnings -A deprecated --cfg tokio_unstable"
52-
RUSTUP_MAX_RETRIES: 10
52+
RUSTUP_MAX_RETRIES: 11
5353

5454
concurrency:
5555
group: ${{ github.workflow }}-${{ inputs.ref || github.head_ref }}
@@ -69,7 +69,7 @@ jobs:
6969
shopt -s extglob
7070
if [[ "$GITHUB_EVENT_NAME" == pull_request ]]; then
7171
echo version="0.0.0-test.${GITHUB_SHA:0:7}"
72-
echo archs='["amd64"]'
72+
echo archs='["amd64", "arm64"]'
7373
exit 0
7474
fi >> "$GITHUB_OUTPUT"
7575
if ! [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+)?(\+[0-9A-Za-z-]+)?$ ]]; then

linkerd/app/admin/src/stack.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ impl Param<metrics::EndpointLabels> for Permitted {
269269
fn param(&self) -> metrics::EndpointLabels {
270270
metrics::InboundEndpointLabels {
271271
tls: self.http.tcp.tls.clone(),
272-
authority: None,
273-
target_addr: self.http.tcp.addr.into(),
274272
policy: self.permit.labels.clone(),
275273
}
276274
.into()

linkerd/app/core/src/metrics.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use linkerd_proxy_server_policy as policy;
1818
use prometheus_client::encoding::EncodeLabelValue;
1919
use std::{
2020
fmt::{self, Write},
21-
net::SocketAddr,
2221
sync::Arc,
2322
time::Duration,
2423
};
@@ -66,8 +65,6 @@ pub enum EndpointLabels {
6665
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
6766
pub struct InboundEndpointLabels {
6867
pub tls: tls::ConditionalServerTls,
69-
pub authority: Option<http::uri::Authority>,
70-
pub target_addr: SocketAddr,
7168
pub policy: RouteAuthzLabels,
7269
}
7370

@@ -99,10 +96,8 @@ pub struct RouteAuthzLabels {
9996
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
10097
pub struct OutboundEndpointLabels {
10198
pub server_id: tls::ConditionalClientTls,
102-
pub authority: Option<http::uri::Authority>,
10399
pub labels: Option<String>,
104100
pub zone_locality: OutboundZoneLocality,
105-
pub target_addr: SocketAddr,
106101
}
107102

108103
#[derive(Debug, Copy, Clone, Default, Hash, Eq, PartialEq, EncodeLabelValue)]
@@ -163,6 +158,23 @@ where
163158
Some(out)
164159
}
165160

161+
pub fn prefix_outbound_endpoint_labels<'i, I>(prefix: &str, mut labels_iter: I) -> Option<String>
162+
where
163+
I: Iterator<Item = (&'i String, &'i String)>,
164+
{
165+
let (k0, v0) = labels_iter.next()?;
166+
let mut out = format!("{}_{}=\"{}\"", prefix, k0, v0);
167+
168+
for (k, v) in labels_iter {
169+
if k == "pod" || k == "pod_template_hash" || k == "zone" {
170+
continue;
171+
}
172+
173+
write!(out, ",{}_{}=\"{}\"", prefix, k, v).expect("label concat must succeed");
174+
}
175+
Some(out)
176+
}
177+
166178
// === impl Metrics ===
167179

168180
impl Metrics {
@@ -317,16 +329,7 @@ impl FmtLabels for EndpointLabels {
317329

318330
impl FmtLabels for InboundEndpointLabels {
319331
fn fmt_labels(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
320-
if let Some(a) = self.authority.as_ref() {
321-
Authority(a).fmt_labels(f)?;
322-
write!(f, ",")?;
323-
}
324-
325-
(
326-
(TargetAddr(self.target_addr), TlsAccept::from(&self.tls)),
327-
&self.policy,
328-
)
329-
.fmt_labels(f)?;
332+
((TlsAccept::from(&self.tls)), &self.policy).fmt_labels(f)?;
330333

331334
Ok(())
332335
}
@@ -391,14 +394,8 @@ impl svc::Param<OutboundZoneLocality> for OutboundEndpointLabels {
391394

392395
impl FmtLabels for OutboundEndpointLabels {
393396
fn fmt_labels(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
394-
if let Some(a) = self.authority.as_ref() {
395-
Authority(a).fmt_labels(f)?;
396-
write!(f, ",")?;
397-
}
398-
399-
let ta = TargetAddr(self.target_addr);
400397
let tls = TlsConnect::from(&self.server_id);
401-
(ta, tls).fmt_labels(f)?;
398+
tls.fmt_labels(f)?;
402399

403400
if let Some(labels) = self.labels.as_ref() {
404401
write!(f, ",{}", labels)?;

linkerd/app/inbound/src/http/router.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@ impl Param<metrics::EndpointLabels> for Logical {
391391
fn param(&self) -> metrics::EndpointLabels {
392392
metrics::InboundEndpointLabels {
393393
tls: self.tls.clone(),
394-
authority: self.logical.as_ref().map(|d| d.as_http_authority()),
395-
target_addr: self.addr.into(),
396394
policy: self.permit.labels.clone(),
397395
}
398396
.into()

linkerd/app/inbound/src/http/tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,6 @@ async fn grpc_response_class() {
522522
.get_response_total(
523523
&metrics::EndpointLabels::Inbound(metrics::InboundEndpointLabels {
524524
tls: Target::meshed_h2().1,
525-
authority: Some("foo.svc.cluster.local:5550".parse().unwrap()),
526-
target_addr: "127.0.0.1:80".parse().unwrap(),
527525
policy: metrics::RouteAuthzLabels {
528526
route: metrics::RouteLabels {
529527
server: metrics::ServerLabel(Arc::new(policy::Meta::Resource {

linkerd/app/integration/src/tests/discovery.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,15 +454,12 @@ mod http2 {
454454
// Simulate the first server falling over without discovery
455455
// knowing about it...
456456
tracing::info!(%alpha.addr, "Stopping");
457-
let alpha_addr = alpha.addr;
458457
alpha.join().await;
459458

460459
// Wait until the proxy has seen the `alpha` disconnect...
461460
metrics::metric("tcp_close_total")
462461
.label("peer", "dst")
463462
.label("direction", "outbound")
464-
.label("target_addr", alpha_addr.to_string())
465-
.value(1u64)
466463
.assert_in(&metrics)
467464
.await;
468465
tracing::info!("Connection closed");

0 commit comments

Comments
 (0)