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

K8s: annotate the events originating from kubernetes with pod metadata #2630

Closed
MOZGIII opened this issue May 18, 2020 · 4 comments · Fixed by #2653
Closed

K8s: annotate the events originating from kubernetes with pod metadata #2630

MOZGIII opened this issue May 18, 2020 · 4 comments · Fixed by #2653
Assignees
Labels
type: task Generic non-code related tasks

Comments

@MOZGIII
Copy link
Contributor

MOZGIII commented May 18, 2020

Annotate the events originating from the k8s with pod metadata, such as:

  • pod namespace
  • pod name
  • pod uid
  • container name
  • pod labels
  • etc...

Part of #2222.

Focus os in-source implementation, but if possible, implement generically, so the implementation can be reused within a transform that annotates the metadata.

@MOZGIII MOZGIII self-assigned this May 18, 2020
@MOZGIII MOZGIII added the type: task Generic non-code related tasks label May 18, 2020
@rrichardson
Copy link
Contributor

Fantastic work. I have this running in our stage k8s cluster.

I am wondering what the final shape of the pod labelling will take. I am targetting Loki, so I'd like to be able to specify labels by which the events will be indexed. Unfortunately, I don't think that there is a standard way to group pods by their deployment without using labels, which means there is no standard kubernetes naming convention.

This means that I'd need to be able to inform the kubernetes_logs source about what pod metadata I want turned into what event-fields. Is this part of the design?

@MOZGIII
Copy link
Contributor Author

MOZGIII commented Jul 10, 2020

kubernetes_logs passes all the labels as an key-value map field. We'll probably have to make loki sink work with map fields to allow passing pod labels as loki labels.

See also: #2710 (for others checking this out)

@rrichardson
Copy link
Contributor

I just noticed that the labels follow the same convention as all of the other event fields in loki, so this actually works:

mydomain_service = "{{ kubernetes.pod_labels.service.mydomain.com }}"

@MOZGIII
Copy link
Contributor Author

MOZGIII commented Jul 10, 2020

Oh, yeah! If you want just one, known upfront, label - just specifying it will work.
Anothe example would be k8s_pod_label_app = "{{ kubernetes.pod_labels.app.kubernetes.io/name }}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task Generic non-code related tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants