Amazon Q Developer で Ops できるかな

Amazon Q Developer による運用上の問題の調査と修正 (プレビュー中)

ALB 5xxを調査してみた
[peg-prod] > 過去24時間で ALB 'prod-cluster' が504を返した回数は?
🛠️ Using tool: cloudwatch_get_metric_data from mcp server awslabs.core-mcp-server
⋮
● Running cloudwatch_get_metric_data with the param:
⋮ {
⋮ "namespace": "AWS/ApplicationELB",
⋮ "metric_name": "HTTPCode_Target_5XX_Count",
⋮ "start_time": "2025-09-24T01:40:58Z",
⋮ "end_time": "2025-09-25T01:40:58Z",
⋮ "dimensions": [
⋮ {
⋮ "name": "LoadBalancer",
⋮ "value": "prod-cluster"
⋮ }
⋮ ],
⋮ "statistic": "Sum",
⋮ "region": "ap-northeast-1"
⋮ }
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:
[peg-prod] > y
⋮
● Completed in 0.324s
> AWS認証が必要です。まずAWSプロファイルを設定してください:
bash
aws configure sso
または、既存のプロファイルがある場合:
bash
aws sso login --profile <your-profile>
認証後、ALBの504エラー数を確認するには以下のコマンドを実行できます:
bash
aws cloudwatch get-metric-statistics \
--namespace AWS/ApplicationELB \
--metric-name HTTPCode_Target_5XX_Count \
--dimensions Name=LoadBalancer,Value=prod-cluster \
--start-time 2025-09-24T01:40:58Z \
--end-time 2025-09-25T01:40:58Z \
--period 3600 \
--statistics Sum \
--region ap-northeast-1
[peg-prod] > !aws sso login --profile prod
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:
Successfully logged
[peg-prod] > 過去24時間で ALB 'prod-cluster' が504を返した回数は?
🛠️ Using tool: aws_api_call_aws from mcp server awslabs.core-mcp-server
⋮
● Running aws_api_call_aws with the param:
⋮ {
⋮ "cli_command": "aws cloudwatch get-metric-statistics --namespace AWS/ApplicationELB --metric-name HTTPCode_Target_5XX_Count --dimensions Name=LoadBalancer,Value=prod-cluster --start-time 2025-09-24T01:42:19Z --end-time 2025-09-25T01:42:19Z --period 3600 --statistics Sum --region ap-northeast-1"
⋮ }
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:
[peg-prod] > y
⋮
● Completed in 1.212s
> 過去24時間でALB 'prod-llm-gateway-cluster' が504エラー(5XXエラー)を返した回数は 0回 です。
データポイントが空のため、この期間中に5XXエラーは発生していません。
[peg-prod] > ターゲットではなくALBが返した5XXは?
🛠️ Using tool: aws_api_call_aws from mcp server awslabs.core-mcp-server
⋮
● Running aws_api_call_aws with the param:
⋮ {
⋮ "cli_command": "aws cloudwatch get-metric-statistics --namespace AWS/ApplicationELB --metric-name HTTPCode_ELB_5XX_Count --dimensions Name=LoadBalancer,Value=prod-cluster --start-time 2025-09-24T01:43:25Z --end-time 2025-09-25T01:43:25Z --period 3600 --statistics Sum --region ap-northeast-1"
⋮ }
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:
[peg-prod] > y
⋮
● Completed in 0.871s
> 過去24時間でALB 'prod-cluster' 自体が返した5XXエラーの回数は 0回 です。
ALB自体からの5XXエラー(HTTPCode_ELB_5XX_Count)も発生していません。
[peg-prod] > ALBの名前が違う。'prod-cluster'を含むALBを検索してみて。
🛠️ Using tool: aws_api_call_aws from mcp server awslabs.core-mcp-server
⋮
● Running aws_api_call_aws with the param:
⋮ {
⋮ "cli_command": "aws elbv2 describe-load-balancers --region ap-northeast-1"
⋮ }
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:
[peg-prod] > y
⋮
● Completed in 0.949s
> ALB名は正しく prod-cluster でした。CloudWatchメトリクスでは、LoadBalancerディメンションの値として完全なALB識別子 app/prod-cluster/xxxx を使用
する必要があります。
🛠️ Using tool: aws_api_call_aws from mcp server awslabs.core-mcp-server
⋮
● Running aws_api_call_aws with the param:
⋮ {
⋮ "cli_command": "aws cloudwatch get-metric-statistics --namespace AWS/ApplicationELB --metric-name HTTPCode_ELB_5XX_Count --dimensions Name=LoadBalancer,Value=app/app/prod-cluster/xxxx --start-time 2025-09-24T01:44:33Z --end-time 2025-09-25T01:44:33Z --period 3600 --statistics Sum --region ap-northeast-1"
⋮ }
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:
[peg-prod] > y
⋮
● Completed in 1.234s
> 過去24時間でALB prod-cluster が返した5XXエラーの回数は 13回 です。
内訳:
• 2025-09-24 13:44:00 UTC: 6回
• 2025-09-24 14:44:00 UTC: 7回
これらはALB自体が生成した5XXエラー(504 Gateway Timeout、502 Bad Gateway等)です。

[peg-prod] > その時間帯でECSログを検索して原因を推測して。CloudWatch Logs は '/ecs/llm-gateway'。
🛠️ Using tool: cloudwatch_execute_log_insights_query from mcp server awslabs.core-mcp-server
⋮
● Running cloudwatch_execute_log_insights_query with the param:
⋮ {
⋮ "start_time": "2025-09-24T13:30:00+00:00",
⋮ "end_time": "2025-09-24T15:00:00+00:00",
⋮ "query_string": "fields @timestamp, @message\n| filter @message like /ERROR/ or @message like /WARN/ or @message like /timeout/ or @message like /502/ or @message like /504/ or @message like /connection/ or @message like /failed/\n| sort @timestamp desc\n| limit 50",
⋮ "log_group_names": [
⋮ "/ecs/llm-gateway"
⋮ ],
⋮ "region": "ap-northeast-1"
⋮ }
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:
[peg-prod] > y
⋮
● Completed in 2.220s
ALBの5XXエラーの原因を分析しました。ログから以下の問題が特定できます:
主な原因
-
無効なモデル名エラー(最も頻繁)
• Invalid model name passed in model=claude-3-5-haiku-20241022
• 14:46-14:47頃に集中的に発生
• LiteLLMプロキシが無効なモデル名を受け取っている -
Redis接続問題
• CROSSSLOT Keys in request don't hash to the same slot
• Redisクラスターでキーが異なるスロットにハッシュされている
• キャッシュ機能に影響 -
接続拒否
• connection rejected (403 Forbidden)
• 認証エラーまたはアクセス制限
推測される504エラーの原因
- モデル名エラー: claude-3-5-haiku-20241022が存在しないか、設定が間違っている
- Redis設定問題: キャッシュの設定ミスによりレスポンス遅延
- 認証問題: 403エラーによる処理遅延
対処法
- LiteLLMの設定でモデル名を正しいものに修正
- Redisクラスター設定の見直し(キーのハッシュタグ使用)
- 認証設定の確認