Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation or examples could demonstrate TargetLabels FromPod #875

Open
strideynet opened this issue Feb 27, 2024 · 1 comment
Open
Labels
help wanted Extra attention is needed

Comments

@strideynet
Copy link

None of the examples or documentation beyond the API reference demonstrate how to scrape the pod labels as metric labels. This makes it harder than necessary to get going.

For my future reference, and the reference of anyone else:

spec:
  endpoints:
  - interval: 1m
    port: my-port
  selector:
    matchLabels:
      app.kubernetes.io/name: my-app
  targetLabels:
    fromPod:
    - from: foo
    - from: foo/bar
      to: foo_bar
    metadata:
    - pod
    - container

Specify from as the name of the pod label you wish to have added to the metric labels. You may also need to specify to to provide the name the label should be on the metric - this is necessary if the pod label is not compatible with the metric labels (e.g contains characters such as /)

@bwplotka
Copy link
Collaborator

bwplotka commented Apr 8, 2024

Thanks! Some of it is explained in field comment (e.g. readable via kubectl explain), but that nuance when to is useful and what remap means can be improved. Thanks, we will add more context to the commentary plus examples.

kubectl explain podmonitoring.spec.targetLabels.fromPod
GROUP:      monitoring.googleapis.com
KIND:       PodMonitoring
VERSION:    v1

FIELD: fromPod <[]Object>

DESCRIPTION:
    Labels to transfer from the Kubernetes Pod to Prometheus target labels.
    Mappings are applied in order.
    LabelMapping specifies how to transfer a label from a Kubernetes resource
    onto a Prometheus target.
    
FIELDS:
  from	<string> -required-
    Kubernetes resource label to remap.

  to	<string>
    Remapped Prometheus target label.
    Defaults to the same name as `From`.

@bwplotka bwplotka added the help wanted Extra attention is needed label Apr 8, 2024
@pintohutch pintohutch removed their assignment May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants