Skip to content

Conversation

@sukangpunch
Copy link

관련 이슈

작업 내용

  1. 로그 파일 매칭 수정

    • 단일 폴더, 단일 매칭 방식에서 info, warn, error, api_perf 폴더를 매칭하도록 수정
  2. 각 로그 파일 매칭에 맞게 소스도 정의

    • 각 매칭 파일마다 소스를 정의
  3. 각 소스에 맞게 프로세서를 정의

특이 사항

리뷰 요구사항 (선택)

현재 관리하는 로그 폴더(info, warn, error, api_perf) 별로
파일 매칭 - 소스 - 프로세스 를 각각 구현하였는데

  1. 로그 파일이 많아질 가능성이 있기에 동적 처리 및 중복 제거를 해야한다.
  2. 로그 파일이 더 늘어나거나 줄어들 가능성이 낮아서 현 방식이 오히려 가독성이 좋아보인다.

두 생각이 들었고 2번으로 처리 했는데 의견을 여쭙고 싶습니다.
+

추가로 라벨링 방식이

  1. {service="backend", env="production", level="info", log_type="application"}
  2. {service="backend", env="production", level="warn", log_type="application"}
  3. {service="backend", env="production", level="error", log_type="application"}
  4. {service="backend", env="production", level="info", log_type="performance"}

다음과 같이 발생하게 되는데 해당 방식 그대로 가도 괜찮을지 궁금합니다

- 변경된 로깅 방식에 맞춰 파일 수정

- info, warn, error, api_perf 폴더 기반 소스, 프로세서 정의
@coderabbitai
Copy link

coderabbitai bot commented Jan 12, 2026

Walkthrough

설정 파일 config/side-infra/config.alloy.tftpl이 로그 처리 방식을 단일 경로에서 다중 경로 구조로 재설계되었습니다. 새로운 파일 매치 블록들이 정보, 경고, 오류, API 성능 로그를 각각 정의하고, 각 레벨에 대응하는 별도의 Loki 소스 항목을 추가합니다. 각 레벨별로 서비스, 환경, 로그 레벨, 로그 타입을 포함한 정적 레이블을 주입하는 프로세스 정의가 신규로 도입되어 레벨별 라벨링 및 라우팅을 가능하게 합니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive PR 제목이 너무 일반적이고 구체적인 변경사항을 명확히 나타내지 못하고 있습니다. 제목을 구체적으로 변경하여 로그 레벨별 분리 설정 내용을 명확히 드러내세요. 예: 'refactor: 로그 레벨별 파일 매칭 및 소스 분리 설정'
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed PR 설명이 템플릿 구조를 따르고 있으며, 작업 내용, 관련 이슈, 특이 사항 및 리뷰 요청사항을 포함하고 있습니다.
Linked Issues check ✅ Passed PR에서 구현한 변경사항(info, warn, error, api_perf 폴더별 파일 매칭, 소스, 프로세서 정의)이 이슈 #15의 요구사항을 충족합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #15의 config.alloy.tftpl 파일 수정 범위 내에 있으며, 로그 레벨별 분리 설정에 관련된 변경만 포함되어 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @config/side-infra/config.alloy.tftpl:
- Line 70: The template currently uses sys.env("ALLOY_ENV") which returns an
empty string if unset; update each occurrence of sys.env("ALLOY_ENV") (including
the instances used for the env label) to wrap it with
coalesce(sys.env("ALLOY_ENV"), "unknown") so the env label defaults to "unknown"
when the ALLOY_ENV variable is not set; apply this change to all occurrences
mentioned in the review.
🧹 Nitpick comments (1)
config/side-infra/config.alloy.tftpl (1)

10-39: local.file_matchlevel/log_type 레이블과 loki.processstatic_labels 중복 확인 필요

local.file_match 블록에서 levellog_type을 타겟 레이블로 정의하고 있는데, 동일한 레이블이 loki.process 블록의 stage.static_labels에서도 다시 정의되고 있습니다 (lines 71-72, 84-85, 97-98, 110-111).

두 곳 중 한 곳에서만 레이블을 정의하는 것이 명확합니다:

  • file_match의 레이블을 활용하려면 process에서 static_labels로 재정의할 필요 없음
  • static_labels로 일관되게 관리하려면 file_match에서 level/log_type 제거 가능

현재 구조에서 의도한 동작이 맞는지 확인해 주세요.

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4760dc2 and 9b4a099.

📒 Files selected for processing (1)
  • config/side-infra/config.alloy.tftpl
🔇 Additional comments (2)
config/side-infra/config.alloy.tftpl (2)

41-61: LGTM!

각 소스가 올바른 file_match 타겟을 참조하고 해당 프로세서로 정확하게 포워딩하고 있습니다.


63-114: 설계 선택에 대한 피드백

PR 설명에서 요청하신 부분에 대해:

  1. 명시적 폴더별 정의 선택: 현재 4개의 로그 타입으로는 명시적 정의가 가독성과 유지보수 측면에서 적절합니다. 다만 로그 타입이 크게 늘어난다면 반복 코드가 증가하므로, 그 시점에 동적 처리로 리팩토링을 고려하면 됩니다.

  2. 라벨링 방식 (service, env, level, log_type): Loki 쿼리 시 일반적으로 사용되는 라벨 구조로, {service="backend", env="prod", level="error"} 형태의 쿼리가 직관적입니다. log_type으로 applicationperformance를 구분하는 것도 적절합니다.

stage.static_labels {
values = {
service = "backend",
env = sys.env("ALLOY_ENV"),
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Grafana Alloy sys.env function behavior undefined environment variable

💡 Result:

Short answer: sys.env returns an empty string ("") when the named environment variable does not exist — not null or an error. Use coalesce or test for "" to provide a default. [1][2]

Examples:

  • sys.env("DOES_NOT_EXIST") => "" . [1]
  • coalesce(sys.env("DOES_NOT_EXIST"), "default") => "default". [2]

Note: if you see errors like "component 'sys.env' does not exist or is out of scope", that usually means the expression was used in a context where functions/stdlib aren’t available or referenced incorrectly — check placement/scope in your config. [3]

Sources: Grafana Alloy docs for sys.env and coalesce; community forum thread. [1][2][3]


🏁 Script executed:

# Search for the config file and examine the context around lines 70, 83, 96, 109
find . -name "config.alloy.tftpl" -o -name "*.alloy" | head -20

Repository: solid-connection/solid-connection-infra

Length of output: 121


🏁 Script executed:

# Examine the config file around the mentioned lines
cat -n ./config/side-infra/config.alloy.tftpl | sed -n '50,120p'

Repository: solid-connection/solid-connection-infra

Length of output: 2099


배포 환경에서 ALLOY_ENV 환경 변수 설정 확인

sys.env("ALLOY_ENV")가 설정되지 않은 경우 빈 문자열을 반환하므로, 로그의 env 레이블이 비어있게 됩니다. 배포 환경에서 ALLOY_ENV 환경 변수가 항상 설정되어 있는지 확인하세요. 필요시 coalesce(sys.env("ALLOY_ENV"), "unknown")를 사용하여 기본값을 설정할 수 있습니다.

또한 적용됨: 83-83, 96-96, 109-109

🤖 Prompt for AI Agents
In @config/side-infra/config.alloy.tftpl at line 70, The template currently uses
sys.env("ALLOY_ENV") which returns an empty string if unset; update each
occurrence of sys.env("ALLOY_ENV") (including the instances used for the env
label) to wrap it with coalesce(sys.env("ALLOY_ENV"), "unknown") so the env
label defaults to "unknown" when the ALLOY_ENV variable is not set; apply this
change to all occurrences mentioned in the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: 바뀐 로깅 방식에 맞게 confg.alloy 파일 수정

2 participants