GS2-Log Deploy/CDK 레퍼런스
GS2-Deploy의 스택을 생성할 때 사용하는 템플릿 포맷과, CDK를 이용한 각종 언어의 템플릿 출력 구현 예제
엔티티
Deploy 처리에서 조작 대상이 되는 리소스
Namespace
네임스페이스
네임스페이스는 하나의 프로젝트 내에서 동일한 서비스를 서로 다른 용도로 여러 개 이용하기 위한 엔티티입니다.
GS2의 각 서비스는 네임스페이스 단위로 관리됩니다. 네임스페이스가 다르면 동일한 서비스라도 완전히 독립된 데이터 공간으로 취급됩니다.
따라서 각 서비스의 이용을 시작하려면 먼저 네임스페이스를 생성해야 합니다.
Request
리소스 생성·갱신 요청
| 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128자 | 네임스페이스 이름 네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. | ||||||||||
| description | string | ~ 1024자 | 설명문 | |||||||||||
| type | 문자열 열거형 enum { “gs2”, “bigquery”, “firehose” } | “gs2” | 로그 출력 방법 로그 데이터의 내보내기 대상을 결정합니다. “gs2"는 GS2의 매니지드 스토리지에 로그를 저장하며 내장된 검색·분석 기능을 이용할 수 있습니다. “bigquery"는 Google BigQuery로 로그를 내보내 고급 분석을 수행할 수 있습니다. “firehose"는 Amazon Kinesis Data Firehose로 로그를 스트리밍하여 S3, Redshift 등의 AWS 대상으로 전달합니다.
| |||||||||||
| gcpCredentialJson | string | {type} == “bigquery” | ✓※ | ~ 5120자 | GCP 자격 증명 BigQuery로 로그를 내보낼 때 인증에 사용하는 GCP 자격 증명 JSON입니다. 서비스 계정에는 대상 데이터셋에 대한 BigQuery Data Editor 권한이 필요합니다. ※ type이(가) “bigquery” 이면 필수 | |||||||||
| bigQueryDatasetName | string | {type} == “bigquery” | ✓※ | ~ 1024자 | BigQuery 데이터셋 이름 로그 데이터를 내보낼 대상이 되는 BigQuery 데이터셋의 이름입니다. 데이터셋은 제공된 자격 증명에 연결된 GCP 프로젝트 내에 미리 존재해야 합니다. ※ type이(가) “bigquery” 이면 필수 | |||||||||
| logExpireDays | int | {type} in [“gs2”, “bigquery”] | ✓※ | 0 ~ 3650 | 로그 보존 기간(일) 로그 데이터를 보관하는 일수입니다. 이 기간을 초과한 로그는 자동으로 삭제됩니다. 내보내기 방법이 “gs2” 또는 “bigquery"인 경우에 적용됩니다. 최대 3650일(약 10년)까지 설정할 수 있습니다. ※ type이(가) “gs2”,“bigquery"이면 필수 | |||||||||
| awsRegion | string | {type} == “firehose” | ✓※ | ~ 256자 | AWS 리전 Kinesis Data Firehose 전송 스트림이 존재하는 AWS 리전입니다(예: us-east-1, ap-northeast-1). ※ type이(가) “firehose” 이면 필수 | |||||||||
| awsAccessKeyId | string | {type} == “firehose” | ✓※ | ~ 256자 | AWS 액세스 키 ID Kinesis Data Firehose 인증에 사용하는 AWS 액세스 키 ID입니다. IAM 사용자에게는 지정된 Firehose 전송 스트림으로 레코드를 전송할 수 있는 권한이 필요합니다. ※ type이(가) “firehose” 이면 필수 | |||||||||
| awsSecretAccessKey | string | {type} == “firehose” | ✓※ | ~ 256자 | AWS 시크릿 액세스 키 Kinesis Data Firehose 인증을 위해 액세스 키 ID와 짝을 이루는 AWS 시크릿 액세스 키입니다. ※ type이(가) “firehose” 이면 필수 | |||||||||
| firehoseStreamName | string | {type} == “firehose” | ✓※ | ~ 256자 | Kinesis Firehose 스트림 이름 로그 데이터의 전송 대상이 되는 Kinesis Data Firehose 전송 스트림의 이름입니다. ※ type이(가) “firehose” 이면 필수 | |||||||||
| firehoseCompressData | 문자열 열거형 enum { “none”, “gzip” } | {type} == “firehose” | “none” | Kinesis Firehose로 출력하는 데이터를 압축할지 여부 Kinesis Data Firehose로 전송하기 전에 로그 데이터를 압축할지를 설정합니다. Gzip 압축을 사용하면 데이터 전송량과 스토리지 비용을 절감할 수 있습니다.
※ type이(가) “firehose” 이면 필수 |
GetAttr
!GetAttr 태그로 취득 가능한 리소스 생성 결과
| 타입 | 설명 | |
|---|---|---|
| Item | Namespace | 생성한 네임스페이스 |
구현 예제
Type: GS2::Log::Namespace
Properties:
Name: namespace-0001
Description: null
Type: gs2
GcpCredentialJson: {"project_id": "gs2-dev"}
BigQueryDatasetName: dataset_0001
LogExpireDays: 3
AwsRegion: awsRegion
AwsAccessKeyId: awsAccessKeyId
AwsSecretAccessKey: awsSecretAccessKey
FirehoseStreamName: firehoseStreamName
FirehoseCompressData: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/log"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
log.NewNamespace(
&SampleStack,
"namespace-0001",
log.NamespaceOptions{
Type: log.NamespaceTypeGs2,
GcpCredentialJson: pointy.String("{\"project_id\": \"gs2-dev\"}"),
BigQueryDatasetName: pointy.String("dataset_0001"),
LogExpireDays: pointy.Int32(3),
AwsRegion: pointy.String("awsRegion"),
AwsAccessKeyId: pointy.String("awsAccessKeyId"),
AwsSecretAccessKey: pointy.String("awsSecretAccessKey"),
FirehoseStreamName: pointy.String("firehoseStreamName"),
},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
new \Gs2Cdk\Log\Model\Namespace_(
stack: $this,
name: "namespace-0001",
options: new \Gs2Cdk\Log\Model\Options\NamespaceOptions(
type: \Gs2Cdk\Log\Model\Enums\NamespaceType::GS2,
gcpCredentialJson: "{\"project_id\": \"gs2-dev\"}",
bigQueryDatasetName: "dataset_0001",
logExpireDays: 3,
awsRegion: "awsRegion",
awsAccessKeyId: "awsAccessKeyId",
awsSecretAccessKey: "awsSecretAccessKey",
firehoseStreamName: "firehoseStreamName"
)
);
}
}
print((new SampleStack())->yaml()); // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.log.model.Namespace(
this,
"namespace-0001",
new io.gs2.cdk.log.model.options.NamespaceOptions()
.withType(io.gs2.cdk.log.model.enums.NamespaceType.GS2)
.withGcpCredentialJson("{\"project_id\": \"gs2-dev\"}")
.withBigQueryDatasetName("dataset_0001")
.withLogExpireDays(3)
.withAwsRegion("awsRegion")
.withAwsAccessKeyId("awsAccessKeyId")
.withAwsSecretAccessKey("awsSecretAccessKey")
.withFirehoseStreamName("firehoseStreamName")
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Log.Model.Namespace(
stack: this,
name: "namespace-0001",
options: new Gs2Cdk.Gs2Log.Model.Options.NamespaceOptions
{
type = Gs2Cdk.Gs2Log.Model.Enums.NamespaceType.Gs2,
gcpCredentialJson = "{\"project_id\": \"gs2-dev\"}",
bigQueryDatasetName = "dataset_0001",
logExpireDays = 3,
awsRegion = "awsRegion",
awsAccessKeyId = "awsAccessKeyId",
awsSecretAccessKey = "awsSecretAccessKey",
firehoseStreamName = "firehoseStreamName"
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import log from "@/gs2cdk/log";
class SampleStack extends core.Stack
{
public constructor() {
super();
new log.model.Namespace(
this,
"namespace-0001",
{
type: log.model.NamespaceType.GS2,
gcpCredentialJson: "{\"project_id\": \"gs2-dev\"}",
bigQueryDatasetName: "dataset_0001",
logExpireDays: 3,
awsRegion: "awsRegion",
awsAccessKeyId: "awsAccessKeyId",
awsSecretAccessKey: "awsSecretAccessKey",
firehoseStreamName: "firehoseStreamName"
}
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
from gs2_cdk import Stack, core, log
class SampleStack(Stack):
def __init__(self):
super().__init__()
log.Namespace(
stack=self,
name='namespace-0001',
options=log.NamespaceOptions(
type=log.NamespaceType.GS2,
gcp_credential_json='{"project_id": "gs2-dev"}',
big_query_dataset_name='dataset_0001',
log_expire_days=3,
aws_region='awsRegion',
aws_access_key_id='awsAccessKeyId',
aws_secret_access_key='awsSecretAccessKey',
firehose_stream_name='firehoseStreamName',
),
)
print(SampleStack().yaml()) # Generate TemplateDashboard
대시보드
로그 데이터와 메트릭을 시각화하기 위한 커스터마이즈 가능한 대시보드입니다. 각 대시보드는 레이아웃과 위젯 설정을 JSON 페이로드로 저장하여, 로그 분석의 맞춤형 뷰를 만들 수 있습니다.
Request
리소스 생성·갱신 요청
| 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128자 | 네임스페이스 이름 네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. | ||
| displayName | string | ✓ | ~ 256자 | 표시용 이름 이 대시보드의 사람이 읽기 쉬운 이름으로, 대시보드 목록과 헤더에 표시됩니다. | ||
| description | string | ~ 1024자 | 설명문 |
GetAttr
!GetAttr 태그로 취득 가능한 리소스 생성 결과
| 타입 | 설명 | |
|---|---|---|
| Item | Dashboard | 생성한 대시보드 |
구현 예제
Type: GS2::Log::Dashboard
Properties:
NamespaceName: namespace-0001
DisplayName: Sample Dashboard 0001
Description: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/log"
)
SampleStack := core.NewStack()
log.NewDashboard(
&SampleStack,
"namespace-0001",
"Sample Dashboard 0001",
log.DashboardOptions{},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
new \Gs2Cdk\Log\Model\Dashboard(
stack: $this,
namespaceName: "namespace-0001",
displayName: "Sample Dashboard 0001"
);
}
}
print((new SampleStack())->yaml()); // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.log.model.Dashboard(
this,
"namespace-0001",
"Sample Dashboard 0001"
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Log.Model.Dashboard(
stack: this,
namespaceName: "namespace-0001",
displayName: "Sample Dashboard 0001"
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import log from "@/gs2cdk/log";
class SampleStack extends core.Stack
{
public constructor() {
super();
new log.model.Dashboard(
this,
"namespace-0001",
"Sample Dashboard 0001"
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
from gs2_cdk import Stack, core, log
class SampleStack(Stack):
def __init__(self):
super().__init__()
log.Dashboard(
stack=self,
namespace_name='namespace-0001',
display_name='Sample Dashboard 0001',
)
print(SampleStack().yaml()) # Generate TemplateFacetModel
패싯 모델
로그 데이터의 필터링과 집계에 사용할 수 있는 패싯 필드를 정의합니다. 패싯을 통해 서비스 이름, 메서드, 상태, 커스텀 필드 등 특정 차원으로 로그 검색 결과를 좁힐 수 있습니다.
Request
리소스 생성·갱신 요청
| 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128자 | 네임스페이스 이름 네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. | ||||||||||
| field | string | ✓ | ~ 128자 | 패싯 필드 이름 이 패싯이 대상으로 하는 로그 필드의 이름입니다(예: “service”, “method”, “status”). | ||||||||||
| type | 문자열 열거형 enum { “string”, “double”, “measure” } | ✓ | 패싯 데이터 타입 패싯 필드의 데이터 타입입니다. “string"은 값 카운트가 있는 범주형 값에, “double"은 범위 필터링이 있는 숫자 값에, “measure"는 통계 분석이 있는 측정값에 사용됩니다.
| |||||||||||
| displayName | string | ✓ | ~ 128자 | 표시용 이름 이 패싯의 사람이 읽을 수 있는 이름으로, 로그 검색 UI에 표시됩니다. | ||||||||||
| order | int | 0 | 0 ~ 100000 | 표시 순서 UI에서 이 패싯을 표시할 때의 정렬 순서입니다. 값이 작을수록 먼저 표시됩니다. |
GetAttr
!GetAttr 태그로 취득 가능한 리소스 생성 결과
| 타입 | 설명 | |
|---|---|---|
| Item | FacetModel | 생성한 패싯 모델 |
구현 예제
Type: GS2::Log::FacetModel
Properties:
NamespaceName: namespace-0001
Field: facet-model-0001
Type: string
DisplayName: Sample Facet Model 0001
Order: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/log"
)
SampleStack := core.NewStack()
log.NewFacetModel(
&SampleStack,
"namespace-0001",
"facet-model-0001",
log.FacetModelTypeString,
"Sample Facet Model 0001",
log.FacetModelOptions{},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
new \Gs2Cdk\Log\Model\FacetModel(
stack: $this,
namespaceName: "namespace-0001",
field: "facet-model-0001",
type: \Gs2Cdk\Log\Model\Enums\FacetModelType::STRING,
displayName: "Sample Facet Model 0001"
);
}
}
print((new SampleStack())->yaml()); // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.log.model.FacetModel(
this,
"namespace-0001",
"facet-model-0001",
io.gs2.cdk.log.model.enums.FacetModelType.STRING,
"Sample Facet Model 0001"
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Log.Model.FacetModel(
stack: this,
namespaceName: "namespace-0001",
field: "facet-model-0001",
type: Gs2Cdk.Gs2Log.Model.Enums.FacetModelType.String,
displayName: "Sample Facet Model 0001"
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import log from "@/gs2cdk/log";
class SampleStack extends core.Stack
{
public constructor() {
super();
new log.model.FacetModel(
this,
"namespace-0001",
"facet-model-0001",
log.model.FacetModelType.STRING,
"Sample Facet Model 0001"
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
from gs2_cdk import Stack, core, log
class SampleStack(Stack):
def __init__(self):
super().__init__()
log.FacetModel(
stack=self,
namespace_name='namespace-0001',
field='facet-model-0001',
type=log.FacetModelType.STRING,
display_name='Sample Facet Model 0001',
)
print(SampleStack().yaml()) # Generate Template