Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions k8s-helm/releases/monitoring-alloy/templates/podlogs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{{- if .Values.podLogs.enabled }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "podlogs.yaml" -type f

Repository: PinHouse/PinHouse_CLOUD

Length of output: 126


🏁 Script executed:

fd "podlogs.yaml" -type f

Repository: PinHouse/PinHouse_CLOUD

Length of output: 237


🏁 Script executed:

git ls-files | grep -i podlog

Repository: PinHouse/PinHouse_CLOUD

Length of output: 124


🏁 Script executed:

cat -n ./k8s-helm/releases/monitoring-alloy/templates/podlogs.yaml

Repository: PinHouse/PinHouse_CLOUD

Length of output: 2826


🏁 Script executed:

# Check for CRD guard patterns in the entire templates directory
rg "Capabilities.APIVersions" ./k8s-helm/releases/monitoring-alloy/templates/ -A 2 -B 2

Repository: PinHouse/PinHouse_CLOUD

Length of output: 49


🏁 Script executed:

# Check other template files for comparison
ls -la ./k8s-helm/releases/monitoring-alloy/templates/

Repository: PinHouse/PinHouse_CLOUD

Length of output: 239


🏁 Script executed:

# Check if there's any documentation about CRD prerequisites
rg "PodLogs\|monitoring.grafana.com" ./k8s-helm/ --type md -i -A 3 -B 3

Repository: PinHouse/PinHouse_CLOUD

Length of output: 49


🏁 Script executed:

# Check values.yaml for podLogs section
find ./k8s-helm -name "values.yaml" -type f | xargs grep -l "podLogs" 2>/dev/null

Repository: PinHouse/PinHouse_CLOUD

Length of output: 115


🏁 Script executed:

cat -n ./k8s-helm/releases/monitoring-alloy/values.yaml | grep -A 10 -B 2 "podLogs"

Repository: PinHouse/PinHouse_CLOUD

Length of output: 226


🏁 Script executed:

# Check if there's a README or CHANGELOG mentioning CRD requirements
find ./k8s-helm -name "README*" -o -name "CHANGELOG*" -o -name "*.md" | head -20

Repository: PinHouse/PinHouse_CLOUD

Length of output: 49


🏁 Script executed:

# Check the Chart.yaml for any documentation references
cat ./k8s-helm/releases/monitoring-alloy/Chart.yaml

Repository: PinHouse/PinHouse_CLOUD

Length of output: 364


이 템플릿을 배포하려면 클러스터에 monitoring.grafana.com/v1alpha2 CRD가 필수입니다.

현재 1번 줄에서 .Values.podLogs.enabled 값만으로 조건을 판단하고 있습니다. 대상 클러스터에 PodLogs CRD가 설치되어 있지 않으면 Helm 설치/업그레이드가 실패합니다. .Capabilities.APIVersions.Has 같은 가드를 추가하거나, Chart.yaml이나 README에서 필수 전제 조건으로 명시해야 합니다.

🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@k8s-helm/releases/monitoring-alloy/templates/podlogs.yaml` at line 1, The
template currently only checks .Values.podLogs.enabled which will fail if the
cluster lacks the monitoring.grafana.com/v1alpha2 CRD; update the podlogs.yaml
template to guard resource creation by checking the API presence (use
.Capabilities.APIVersions.Has "monitoring.grafana.com/v1alpha2") in the same
conditional that references .Values.podLogs.enabled, or alternatively document
this CRD as a required precondition in Chart.yaml and README; ensure you
reference .Values.podLogs.enabled and .Capabilities.APIVersions.Has in the same
if/else flow so the template never renders CRD objects on clusters that do not
support them.


apiVersion: monitoring.grafana.com/v1alpha2

kind: PodLogs

# 메타데이터
metadata:
name: {{ .Release.Name }}-pods
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/name: monitoring-alloy
app.kubernetes.io/component: podlogs

# 스펙. 현재는 모드 파드 수집 진행함.
spec:
namespaceSelector: {}
selector: {}

# 라벨링
relabelings:
# 네임스페이스는 가장 기본적인 조회 축이라 그대로 보존합니다.
- sourceLabels:
- __meta_kubernetes_namespace
targetLabel: namespace

# Pod 이름을 그대로 라벨로 남겨 개별 인스턴스 추적에 사용합니다.
- sourceLabels:
- __meta_kubernetes_pod_name
targetLabel: pod

# 컨테이너 이름은 service fallback과 세부 필터링에 함께 사용합니다.
- sourceLabels:
- __meta_kubernetes_pod_container_name
targetLabel: container

# 장애 분석 시 노드 기준 조회가 가능하도록 노드 이름을 남깁니다.
- sourceLabels:
- __meta_kubernetes_pod_node_name
targetLabel: node

# service 추출 규칙: 우선순위가 낮은 것부터 높은 순서로 덮어씁니다.

# 1. 기본값: 컨테이너 이름
- sourceLabels:
- __meta_kubernetes_pod_container_name
targetLabel: service
# 2. Pod controller가 ReplicaSet이면 Deployment 이름 추출
- sourceLabels:
- __meta_kubernetes_pod_controller_kind
- __meta_kubernetes_pod_controller_name
separator: /
regex: ReplicaSet/(.+)-[a-z0-9]{8,10}$
replacement: $1
targetLabel: service

# 3. app 라벨이 있으면 우선 사용
- sourceLabels:
- __meta_kubernetes_pod_label_app
regex: (.+)
targetLabel: service

# 4. 표준 app.kubernetes.io/name 라벨이 있으면 최우선
- sourceLabels:
- __meta_kubernetes_pod_label_app_kubernetes_io_name
regex: (.+)
targetLabel: service

# Logs Drilldown이 우선 참조하는 service_name 라벨도 함께 맞춥니다.
- sourceLabels:
- service
targetLabel: service_name

# 서비스 네임스페이스는 워크로드 네임스페이스와 동일하게 둡니다.
- sourceLabels:
- __meta_kubernetes_namespace
targetLabel: service_namespace

# job은 namespace/service 형식으로 설정합니다.
- sourceLabels:
- __meta_kubernetes_namespace
- service
separator: /
targetLabel: job

{{- end }}
89 changes: 19 additions & 70 deletions k8s-helm/releases/monitoring-alloy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ global:

alloy:
fullnameOverride: monitoring-alloy
crds:
# PodLogs 같은 Alloy CRD를 릴리스와 함께 명시적으로 설치합니다.
create: true

alloy:
# DaemonSet 여러 인스턴스 간에 scrape 대상을 나눠 가져가도록 클러스터링을 활성화합니다.
clustering:
enabled: true

enableReporting: false
# node_filter가 공식 예시처럼 NODE_NAME 환경변수를 사용할 수 있게 맞춥니다.
extraEnv:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName

extraPorts:
- name: otlp-grpc
port: 4317
Expand Down Expand Up @@ -113,7 +123,7 @@ alloy:
// ========================================
// 각 Alloy Pod는 자신이 올라간 노드의 Pod 로그만 읽도록 범위를 제한합니다.
loki.source.podlogs "pods" {
forward_to = [loki.relabel.pod_logs.receiver]
forward_to = [loki.process.pod_logs.receiver]

node_filter {
enabled = true
Expand All @@ -127,75 +137,6 @@ alloy:
stage.cri {}
}

// Kubernetes 메타데이터를 Loki 조회용 라벨로 정리합니다.
loki.relabel "pod_logs" {
forward_to = [loki.process.pod_logs.receiver]

// 네임스페이스는 가장 기본적인 조회 축이라 그대로 보존합니다.
rule {
source_labels = ["__meta_kubernetes_namespace"]
target_label = "namespace"
}

// Pod 이름을 그대로 라벨로 남겨 개별 인스턴스 추적에 사용합니다.
rule {
source_labels = ["__meta_kubernetes_pod_name"]
target_label = "pod"
}

// 컨테이너 이름은 service fallback과 세부 필터링에 함께 사용합니다.
rule {
source_labels = ["__meta_kubernetes_pod_container_name"]
target_label = "container"
}

// 장애 분석 시 노드 기준 조회가 가능하도록 노드 이름을 남깁니다.
rule {
source_labels = ["__meta_kubernetes_pod_node_name"]
target_label = "node"
}

// service 추출 규칙: 우선순위가 낮은 것부터 높은 순서로 덮어씁니다.

// 1. 기본값: 컨테이너 이름
rule {
source_labels = ["__meta_kubernetes_pod_container_name"]
target_label = "service"
}

// 2. Pod controller가 ReplicaSet이면 Deployment 이름 추출
// ReplicaSet 이름 형식: <deployment-name>-<pod-template-hash>
// pod-template-hash는 마지막 하이픈 뒤의 8-10자리 영숫자
rule {
source_labels = ["__meta_kubernetes_pod_controller_kind", "__meta_kubernetes_pod_controller_name"]
separator = "/"
regex = "ReplicaSet/(.+)-[a-z0-9]{8,10}$"
replacement = "$1"
target_label = "service"
}

// 3. app 라벨이 있으면 우선 사용
rule {
source_labels = ["__meta_kubernetes_pod_label_app"]
regex = "(.+)"
target_label = "service"
}

// 4. 표준 app.kubernetes.io/name 라벨이 있으면 최우선
rule {
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"]
regex = "(.+)"
target_label = "service"
}

// job은 namespace/service 형식으로 설정합니다.
rule {
source_labels = ["__meta_kubernetes_namespace", "service"]
separator = "/"
target_label = "job"
}
}

// 공통 외부 라벨을 함께 붙여 Loki로 전송합니다.
loki.write "default" {
external_labels = {
Expand All @@ -221,3 +162,11 @@ alloy:

serviceMonitor:
enabled: true

# ========================================
# PodLogs 수집 설정
# ========================================

podLogs:
# Alloy loki.source.podlogs가 읽을 PodLogs CR을 함께 배포합니다.
enabled: true
24 changes: 24 additions & 0 deletions k8s-helm/releases/monitoring-tempo/values-prod-gitops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,27 @@ tempo:
limits:
cpu: 500m
memory: 512Mi

overrides:
defaults:
metrics_generator:
# RED 메트릭 생성을 위해 span-metrics processor를 명시적으로 활성화합니다.
processors:
- span-metrics

metricsGenerator:
# 트레이스에서 RED 메트릭(Rate, Error, Duration)을 자동 생성합니다.
enabled: true
replicas: 1
resources:
requests:
cpu: 200m
memory: 256Mi
limits:
cpu: 500m
memory: 1Gi
config:
# Prometheus로 메트릭을 전송합니다.
storage:
remote_write:
- url: http://monitoring-core-kube-prome-prometheus.monitoring.svc.cluster.local:9090/api/v1/write
Comment thread
coderabbitai[bot] marked this conversation as resolved.
3 changes: 2 additions & 1 deletion k8s-helm/releases/monitoring-tempo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ tempo:
replicas: 1

metricsGenerator:
enabled: false
enabled: true
replicas: 1

gateway:
enabled: false
Expand Down