Skip to content

Commit b336ff5

Browse files
committed
Fix Alloy errors on k8s deployments
1 parent dec7bb7 commit b336ff5

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

deployments/kubernetes/base/alloy/alloy.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ metadata:
55
name: grafana-alloy
66
---
77
apiVersion: rbac.authorization.k8s.io/v1
8-
kind: RoleBinding
8+
kind: ClusterRoleBinding
99
metadata:
1010
name: grafana-alloy
1111
roleRef:
1212
apiGroup: rbac.authorization.k8s.io
1313
kind: ClusterRole
1414
name: view
1515
subjects:
16-
- kind: ServiceAccount
17-
name: grafana-alloy
16+
- kind: ServiceAccount
17+
name: grafana-alloy
18+
namespace: quickpizza
1819
---
1920
apiVersion: apps/v1
2021
kind: Deployment
2122
metadata:
2223
name: grafana-alloy
23-
labels: &alloyLabels
24-
# application name: groups all related resources
24+
labels: &alloyLabels # application name: groups all related resources
2525
app.k8s.io/name: grafana-alloy
2626
# component type: defines the role of this deployment
2727
app.kubernetes.io/component: service
@@ -77,4 +77,4 @@ spec:
7777
targetPort: grpc
7878
- port: 4318
7979
name: http
80-
targetPort: http
80+
targetPort: http

deployments/kubernetes/cloud/config/config.alloy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ loki.source.kubernetes "application_pods" {
8282
}
8383

8484
discovery.relabel "application_pods_profiles" {
85+
86+
// Drop database pods - they don't expose pprof endpoints
87+
rule {
88+
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_component"]
89+
regex = "database"
90+
action = "drop"
91+
}
8592
// https://grafana.com/docs/pyroscope/latest/view-and-analyze-profile-data/line-by-line/
8693
rule {
8794
target_label = "service_repository"

deployments/terraform/alloy.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ resource "kubernetes_service_account_v1" "alloy" {
1818

1919
// Grant the "view" ClusterRole to kubernetes_service_account_v1
2020
// This allows Alloy (`service_account_name`) to discover application pods and scrape metrics.
21-
resource "kubernetes_role_binding_v1" "alloy" {
21+
resource "kubernetes_cluster_role_binding_v1" "alloy" {
2222
metadata {
2323
name = "alloy"
24-
namespace = kubernetes_namespace_v1.quickpizza.id
2524
}
2625
role_ref {
2726
api_group = "rbac.authorization.k8s.io"

deployments/terraform/alloy/config.alloy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ loki.source.kubernetes "application_pods" {
9595
}
9696

9797
discovery.relabel "application_pods_profiles" {
98+
99+
// Drop database pods - they don't expose pprof endpoints
100+
rule {
101+
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_component"]
102+
regex = "database"
103+
action = "drop"
104+
}
98105
// https://grafana.com/docs/pyroscope/latest/view-and-analyze-profile-data/line-by-line/
99106
rule {
100107
target_label = "service_repository"

0 commit comments

Comments
 (0)