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

Add ability to set Loki labels from Pod labels #626

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

petewall
Copy link
Collaborator

@petewall petewall commented Jul 8, 2024

Chose to set app_kubernetes_io_name from the Pod label app.kubernetes.io/name, because it's the most clear what is happening.

@petewall petewall self-assigned this Jul 8, 2024
@petewall petewall linked an issue Jul 8, 2024 that may be closed by this pull request
@petewall petewall requested review from a team, skl, nevermind89x and jewbetcha and removed request for a team July 9, 2024 14:47
Signed-off-by: Pete Wall <pete.wall@grafana.com>
Signed-off-by: Pete Wall <pete.wall@grafana.com>
@petewall petewall force-pushed the feat/better-logs-service-name branch from d6a3cf0 to 094e3f6 Compare July 9, 2024 14:47
@@ -400,6 +400,7 @@ The Prometheus and Loki services may be hosted on the same cluster, or remotely
| logs.pod_logs.extraRelabelingRules | string | `""` | Rule blocks to be added to the discovery.relabel component for pod logs. These relabeling rules are applied pre-scrape against the targets from service discovery. Before the scrape, any remaining target labels that start with `__` (i.e. `__meta_kubernetes*`) are dropped. ([docs](https://grafana.com/docs/alloy/latest/reference/components/discovery.relabel/#rule-block)) |
| logs.pod_logs.extraStageBlocks | string | `""` | Stage blocks to be added to the loki.process component for pod logs. ([docs](https://grafana.com/docs/alloy/latest/reference/components/loki.process/#blocks)) This value is templated so that you can refer to other values from this file. |
| logs.pod_logs.gatherMethod | string | `"volumes"` | Controls the behavior of gathering pod logs. When set to `volumes`, Grafana Alloy will use HostPath volume mounts on the cluster nodes to access the pod log files directly. When set to `api`, Grafana Alloy will access pod logs via the API server. This method may be preferable if your cluster prevents DaemonSets, HostPath volume mounts, or for other reasons. |
| logs.pod_logs.labels | object | `{"app_kubernetes_io_name":"app.kubernetes.io/name"}` | Loki labels that will be set from the Kubernetes Pod labels. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This differs from setting static/custom labels in the logs - so I wonder if it's worth stating as part of the value name that this is specifically for k8s label "copying"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make the instructions a bit clearer, too.

Signed-off-by: Pete Wall <pete.wall@grafana.com>
@petewall petewall merged commit 4f82747 into main Jul 9, 2024
15 of 16 checks passed
@petewall petewall deleted the feat/better-logs-service-name branch July 9, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong Loki service_name label value for Kubernetes pod logs
3 participants