Notice
Recent Posts
Recent Comments
Link
투케이2K
185. (Aws/Amazon) [Amazon CloudWatch] DescribeLogGroups AWS CloudWatch Logs 로그 그룹 목록 조회 API 설명 정리 본문
Aws (Amazon)
185. (Aws/Amazon) [Amazon CloudWatch] DescribeLogGroups AWS CloudWatch Logs 로그 그룹 목록 조회 API 설명 정리
투케이2K 2026. 2. 19. 20:00728x90
반응형
[개발 환경 설정]
개발 환경 : Aws / Amazon Web Services

[설명 정리]
// --------------------------------------------------------------------------------------
[개발 및 환경]
// --------------------------------------------------------------------------------------
- 인프라 : Aws / Amazon Web Services
- 기술 구분 : Aws / Amazon CloudWatch / DescribeLogGroups
- 사전) AWS CloudWatchLogs 간다 설명 정리 :
>> Aws CloudWatch 는 Amazon Web Services (AWS) 리소스 및 AWS에서 실행되는 애플리케이션을 실시간으로 모니터링 할 수 있는 서비스입니다
>> Aws CloudWatch 를 사용하여 리소스 및 애플리케이션에 대해 측정할 수 있는 변수인 지표를 수집하고 추적할 수 있습니다
>> Aws CloudWatch 액세스 방법 :
- Amazon CloudWatch 콘솔 : https://console.aws.amazon.com/cloudwatch/
- AWS CLI : 자세한 내용은 AWS Command Line Interface 사용 설명서의 AWS Command Line Interface 설정 단원을 참조하세요.
- CloudWatch API : 자세한 내용은 Amazon CloudWatch API 참조 단원을 참조하세요.
- AWS SDK : 자세한 내용은 Amazon Web Services용 도구를 참조하세요.
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
[설 명]
// --------------------------------------------------------------------------------------
1. DescribeLogGroups 는 AWS CloudWatch Logs 에 존재하는 로그 그룹들의 목록을 조회하는 API 입니다.
>> AWS 계정의 특정 리전에 존재하는 모든 로그 그룹의 메타데이터를 나열하는 기능입니다.
2. CloudWatch Logs 는 ✅ 구조상 Log Group → Log Stream → Events(로그 줄) 계층 구조를 가지고 있으며, DescribeLogGroups 는 맨 상단 레벨인 Log Group 레벨만 조회합니다.
3. DescribeLogGroups 가 사용 되는 상황 :
>> 계정/리전 내 모든 로그 그룹을 탐색하고 싶을 때
- /aws/lambda/... 로그
- /aws/api-gateway/... 로그
>> 특정 서비스의 로그 그룹을 찾기 위한 검색
- 예 : "/aws/lambda" 로 시작하는 모든 그룹 찾기
>> 이후 작업을 위한 준비
- DescribeLogStreams 호출 (로그 스트림 조회)
- GetLogEvents, FilterLogEvents 호출 (실제 로그 조회)
- StartQuery 실행 (Logs Insights 쿼리)
4. ✅ DescribeLogGroups 호출 시 주요 요청 파라미터
>> limit : 한 번에 가져올 최대 로그 그룹 개수 (기본 50 내외)
>> nextToken : 다음 페이지를 가져올 때 사용하는 토큰
>> logGroupNamePrefix : 특정 접두사로 시작하는 그룹만 필터링
>> 호출 파라미터 예시 :
{
limit: 50,
nextToken: "eyJ2IjoiMSIsImsiOiIxMjM0NTYifQ=="
}
5. ✅ DescribeLogGroups 응답 구조 설명
>> logGroups[] : 각 로그 그룹에 대한 정보 목록
- logGroupName : 로그 그룹 이름
- creationTime : 생성 시각(epoch ms)
- retentionInDays : 로그 보존 일수(없으면 null = 무제한)
- metricFilterCount : 메트릭 필터 개수
- arn : 로그 그룹 ARN
- storedBytes : 저장된 로그 데이터 크기(근사치)
- kmsKeyId : 저장 로그를 암호화한 KMS Key ID (옵션)
>> nextToken : 더 많은 로그 그룹이 있을 때만 반환되며, 다음 조회 시 사용
>> DescribeLogGroups 응답 JSON 예시 :
{
"logGroups": [
{
"logGroupName": "/aws/lambda/my-lambda-func",
"creationTime": 1672531200000,
"retentionInDays": 14,
"metricFilterCount": 2,
"arn": "arn:aws:logs:ap-northeast-2:123456789012:log-group:/aws/lambda/my-lambda-func:*",
"storedBytes": 458762
}
],
"nextToken": "eyJ2IjoiMSIsImsiOiIxMjM0NTYifQ=="
}
6. DescribeLogGroups 을 호출 하기 위한 필요 IAM 권한 :
{
"Effect": "Allow",
"Action": [
"logs:DescribeLogGroups"
],
"Resource": "*"
}
7. ✅ DescribeLogGroups 호출 자바스크립트 예시 소스 코드 :
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1416.0.min.js"></script>
<script>
// [AWS 인증 변수 선언]
const accessKey = 'AK..A6';
const secretKey = 'mP..5J';
const region = 'ap-northeast-2';
window.onload = async function() {
// -----------------------------------------
// [AWS.config 지정]
// -----------------------------------------
AWS.config.update({
region: region,
accessKeyId: accessKey,
secretAccessKey: secretKey
});
// -----------------------------------------
// [AWS 객체 생성]
// -----------------------------------------
const aws = new AWS.CloudWatchLogs();
// -----------------------------------------
// [describeLogGroups 호출 수행]
// -----------------------------------------
aws.describeLogGroups({ limit: 50 }, (err, data) => {
if (err) console.error(err);
else console.log(data.logGroups);
});
};
</script>
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
[참고 사이트]
// --------------------------------------------------------------------------------------
[Amazon CloudWatch] Aws CloudWatch 클라우드 와치 개념 및 설정 정리 - Aws 애플리케이션 실시간으로 모니터링 서비스
https://kkh0977.tistory.com/7920
https://blog.naver.com/kkh0977/223834321984?trackingCode=blog_bloghome_searchlist
[AWS] [Lambda] 런타임 Python 3.13 - boto3 모듈 사용해 AWS CloudWatch 로그 그룹 목록 조회
https://kkh0977.tistory.com/8216
https://blog.naver.com/kkh0977/223970759098?trackingCode=blog_bloghome_searchlist
[AWS] [Lambda] 런타임 Python 3.13 - boto3 모듈 사용해 AWS CloudWatch 특정 로그 그룹 스트림 목록 조회
https://kkh0977.tistory.com/8217
https://blog.naver.com/kkh0977/223971181373?trackingCode=blog_bloghome_searchlist
[AWS] [Lambda] 런타임 Python 3.13 - boto3 모듈 사용해 AWS CloudWatch 특정 로그 스트림의 로그 이벤트 조회
https://blog.naver.com/kkh0977/223974859391?trackingCode=blog_bloghome_searchlist
// --------------------------------------------------------------------------------------
728x90
반응형
'Aws (Amazon)' 카테고리의 다른 글
Comments
