Skip to content

fix(loki): promote OTel log.file.name to stream label - #81

Merged
developowl merged 1 commit into
mainfrom
fix/loki-otlp-log-file-name-index
Jun 25, 2026
Merged

developowl merged 1 commit into
mainfrom
fix/loki-otlp-log-file-name-index

Conversation

@developowl

Copy link
Copy Markdown
Collaborator

Summary

apps/log-server/values.yaml 의 loki.limits_config 에 otlp_config.log_attributes 매핑 추가. OTel log.file.name 을 stream label로 promote 하여 host-log alert rule 들이 발화 가능하게 함.

Why

PR #78 검증 중 host-log alert rule 들이 매칭 0 임을 확인:

Loki 쿼리 결과
{k8s_cluster_name="pc1", log_file_name="syslog"} (stream selector) 0 streams
{k8s_cluster_name="pc1"} | log_file_name="syslog" (line filter) 정상 hit

→ log.file.name 이 stream label이 아닌 structured_metadata 로 들어오고 있음. PR #78의 alert rule 들 (HighErrorLogRate, OOMKillDetected, FilesystemPressureLogDetected, HostSyslogSilent) 과 ai-analyzer 의 logql_context_query 가 모두 stream selector 가정으로 작성되어 있어 영구 silent.

#30 closed 댓글 (6/4) 에서는 log_file_name=syslog 가 stream label 로 동작했다고 보고했는데, 이후 33dcf9b (Loki S3 마이그레이션) 시 chart upgrade가 동반되며 OTLP attribute promotion 기본 정책이 strict 해진 듯.

What

loki:
  limits_config:
    otlp_config:
      log_attributes:
        - action: index_label
          attributes:
            - log.file.name
  • log.file.name (filelog receiver 자동 부여) → log_file_name stream label 로 promote
  • 기존 alert rule / ai-analyzer 쿼리 변경 불필요
  • 카디널리티: 노드당 파일 종류 (현재 syslog 한 개) 수준 → 안전

Validation

  • helm template apps/log-server 정상 렌더
  • ArgoCD sync 후 Loki 재기동 → {k8s_cluster_name="pc1", log_file_name="syslog"} 가 stream 반환
  • PR fix(log-alerts): AI 분석용 Loki 컨텍스트 쿼리 전달 #78 alert rule들이 host syslog 트래픽 따라 정상 발화/silent 판정
  • ai-analyzer webhook 재검증 — Case 1 (annotation path) 의 loki_lines > 0 확인

Notes

  • Loki 차트는 이 옵션을 appVersion >= 3.x 부터 지원 (현재 7.1.0 / Loki 3.6.8)
  • 추후 다른 filelog 경로 (journald, openstack 서비스 로그) 확장 시 같은 attribute로 자동 분류

Related: #30, PR #78, PR #80

🤖 Generated with Claude Code

#30 (filelog/host) 후속 — 호스트 syslog 가 Loki 에 들어오고 있지만
`{log_file_name="syslog"}` stream selector 가 매칭되지 않아 host-log
alert rule (`HighErrorLogRate`, `OOMKillDetected`,
`FilesystemPressureLogDetected`, `HostSyslogSilent`) 이 영구 silent
상태로 발화 불가. 같은 이유로 ai-analyzer 의 `logql_context_query`
도 0 line 반환.

원인: Loki 3.x 의 OTLP receiver 가 record-level attribute (filelog
operator 가 부여하는 `log.file.name` 등) 를 기본적으로
structured_metadata 로 처리. line filter (`| log_file_name="syslog"`)
로는 매칭되지만 stream selector 로는 미반환. #30 closed 시점에는 stream
label 이었던 것으로 보아 그 사이 chart upgrade (S3 마이그레이션
33dcf9b 동반) 로 기본 정책이 strict 해진 듯.

Fix: limits_config.otlp_config.log_attributes 에 index_label 매핑 추가.
`log.file.name` 을 stream label 로 promote 하면 기존 alert rule / ai-analyzer
쿼리 모두 변경 없이 동작. 카디널리티는 노드당 파일 종류 수준으로 안전.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@developowl
developowl merged commit b35fffd into main Jun 25, 2026
1 check passed
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.

1 participant