Missing dst_replicaset in request_total proxy metric
What is the issue?
We are missing the dst_replicaset label in our outbound request_count Prometheus metric. Based on this doc, we couldn't find if there's any additional config required for the rs label. The following labels show up currently: dst_deployment, dst_namespace, dst_pod, dst_pod_template_hash, dst_service and dst_serviceaccount.
How can it be reproduced?
In our current setup, we access the metrics by port forwarding the prometheus-operated service and filtering the metrics by request_total{direction="outbound"} to locate the concerned metrics. We are also running the linkerd-cni. Our prometheus scrape file:
# additional scrape configurations for our existing Prometheus instance and sets the URL for an external prometheus for linkerd-viz. This follows the recommended steps here(https://linkerd.io/2.13/tasks/external-prometheus/) laid out by linkerd.
- job_name: "linkerd-proxy"
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels:
- __meta_kubernetes_pod_container_name
- __meta_kubernetes_pod_container_port_name
- __meta_kubernetes_pod_label_linkerd_io_control_plane_ns
action: keep
regex: ^linkerd-proxy;linkerd-admin;linkerd$
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: pod
# special case k8s' "job" label, to not interfere with prometheus' "job"
# label
# __meta_kubernetes_pod_label_linkerd_io_proxy_job=foo =>
# k8s_job=foo
- source_labels: [__meta_kubernetes_pod_label_linkerd_io_proxy_job]
action: replace
target_label: k8s_job
# drop __meta_kubernetes_pod_label_linkerd_io_proxy_job
- action: labeldrop
regex: __meta_kubernetes_pod_label_linkerd_io_proxy_job
# __meta_kubernetes_pod_label_linkerd_io_proxy_deployment=foo =>
# deployment=foo
- action: labelmap
regex: __meta_kubernetes_pod_label_linkerd_io_proxy_(.+)
# drop all labels that we just made copies of in the previous labelmap
- action: labeldrop
regex: __meta_kubernetes_pod_label_linkerd_io_proxy_(.+)
# __meta_kubernetes_pod_label_linkerd_io_foo=bar =>
# foo=bar
- action: labelmap
regex: __meta_kubernetes_pod_label_linkerd_io_(.+)
# Copy all pod labels to tmp labels
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
replacement: __tmp_pod_label_$1
# Take `linkerd_io_` prefixed labels and copy them without the prefix
- action: labelmap
regex: __tmp_pod_label_linkerd_io_(.+)
replacement: __tmp_pod_label_$1
# Drop the `linkerd_io_` originals
- action: labeldrop
regex: __tmp_pod_label_linkerd_io_(.+)
# Copy tmp labels into real labels
- action: labelmap
regex: __tmp_pod_label_(.+)
metric_relabel_configs:
# Only keep the metric we plan to use for autoscaling
- action: keep
regex: request_total
source_labels: [__name__]
Logs, error output, etc
N/A (happy to provide more info if prompted, I am not sure what to provide here since there's no error logs)
output of linkerd check -o short
➜ ~ linkerd check -o short
linkerd-identity
----------------
‼ issuer cert is valid for at least 60 days
issuer certificate will expire on 2023-11-29T16:36:22Z
see https://linkerd.io/2.14/checks/#l5d-identity-issuer-cert-not-expiring-soon for hints
linkerd-webhooks-and-apisvc-tls
-------------------------------
‼ proxy-injector cert is valid for at least 60 days
certificate will expire on 2023-11-28T16:31:27Z
see https://linkerd.io/2.14/checks/#l5d-proxy-injector-webhook-cert-not-expiring-soon for hints
‼ sp-validator cert is valid for at least 60 days
certificate will expire on 2023-11-28T16:31:29Z
see https://linkerd.io/2.14/checks/#l5d-sp-validator-webhook-cert-not-expiring-soon for hints
‼ policy-validator cert is valid for at least 60 days
certificate will expire on 2023-11-28T16:31:27Z
see https://linkerd.io/2.14/checks/#l5d-policy-validator-webhook-cert-not-expiring-soon for hints
linkerd-viz
-----------
‼ tap API server cert is valid for at least 60 days
certificate will expire on 2023-11-28T16:31:30Z
see https://linkerd.io/2.14/checks/#l5d-tap-cert-not-expiring-soon for hints
Status check results are √
Environment
k8s server version: v1.25.15-eks-4f4795d cluster: EKS host OS: Amazon Linux 2 linkerd server version: stable-2.14.5
Possible solution
No response
Additional context
No response
Would you like to work on fixing this bug?
no
Hi @apoorva11029, thanks for raising this! When we compute metric labels, we tend to only extract the top-most parent for a given resource. On the outbound side, for example, we'd look at a Pod, determine its parent (i.e. a ReplicaSet) and continue to trace it up until we find the root (commonly a Deployment), and that's the label we'll use. Is there a specific need or usecase here for you to have dst_replicaset or are you concerned that it's not showing up?
A more in-depth explanation 👇🏻
You can see a snippet of the code if you want to see how it all works (this function will be generally called whenever we need to compute parent labels).
All that is to say: I wouldn't expect to see dst_replicaset on your metrics, unless you only have a replicaset (or unless that's the highest level k8s primitive). Here are two examples:
- If you use a Deployment, you'll see
dst_deployment - If you use an Argo rollout (or something similar), I'd expect to see
dst_replicaset(since we have no notion of what a rollout is, as an owner, see the code linked above).
Thanks @mateiidavid for explaining and pointing to the right code- this makes a lot of sense (just wasn't obvious from the docs) We are looking at migrating to rollouts and needed the label there. This info will help us proceed for now!