Documentation index for AI agents

GS2-Log Deploy/CDK 레퍼런스

GS2-Deploy의 스택을 생성할 때 사용하는 템플릿 포맷과, CDK를 이용한 각종 언어의 템플릿 출력 구현 예제

엔티티

Deploy 처리에서 조작 대상이 되는 리소스

Namespace

네임스페이스

네임스페이스는 하나의 프로젝트 내에서 동일한 서비스를 서로 다른 용도로 여러 개 이용하기 위한 엔티티입니다.
GS2의 각 서비스는 네임스페이스 단위로 관리됩니다. 네임스페이스가 다르면 동일한 서비스라도 완전히 독립된 데이터 공간으로 취급됩니다.

따라서 각 서비스의 이용을 시작하려면 먼저 네임스페이스를 생성해야 합니다.

Request

리소스 생성·갱신 요청

타입활성화 조건필수기본값값 제한설명
namestring
~ 128자네임스페이스 이름
네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
descriptionstring~ 1024자설명문
type문자열 열거형
enum {
  “gs2”,
  “bigquery”,
  “firehose”
}
“gs2”로그 출력 방법
로그 데이터의 내보내기 대상을 결정합니다. “gs2"는 GS2의 매니지드 스토리지에 로그를 저장하며 내장된 검색·분석 기능을 이용할 수 있습니다. “bigquery"는 Google BigQuery로 로그를 내보내 고급 분석을 수행할 수 있습니다. “firehose"는 Amazon Kinesis Data Firehose로 로그를 스트리밍하여 S3, Redshift 등의 AWS 대상으로 전달합니다.
정의설명
gs2GS2에 의한 관리
bigqueryBigQuery로 내보내기
firehoseKinesis Firehose로 내보내기
gcpCredentialJsonstring{type} == “bigquery”
✓※
~ 5120자GCP 자격 증명
BigQuery로 로그를 내보낼 때 인증에 사용하는 GCP 자격 증명 JSON입니다. 서비스 계정에는 대상 데이터셋에 대한 BigQuery Data Editor 권한이 필요합니다.
※ type이(가) “bigquery” 이면 필수
bigQueryDatasetNamestring{type} == “bigquery”
✓※
~ 1024자BigQuery 데이터셋 이름
로그 데이터를 내보낼 대상이 되는 BigQuery 데이터셋의 이름입니다. 데이터셋은 제공된 자격 증명에 연결된 GCP 프로젝트 내에 미리 존재해야 합니다.
※ type이(가) “bigquery” 이면 필수
logExpireDaysint{type} in [“gs2”, “bigquery”]
✓※
0 ~ 3650로그 보존 기간(일)
로그 데이터를 보관하는 일수입니다. 이 기간을 초과한 로그는 자동으로 삭제됩니다. 내보내기 방법이 “gs2” 또는 “bigquery"인 경우에 적용됩니다. 최대 3650일(약 10년)까지 설정할 수 있습니다.
※ type이(가) “gs2”,“bigquery"이면 필수
awsRegionstring{type} == “firehose”
✓※
~ 256자AWS 리전
Kinesis Data Firehose 전송 스트림이 존재하는 AWS 리전입니다(예: us-east-1, ap-northeast-1).
※ type이(가) “firehose” 이면 필수
awsAccessKeyIdstring{type} == “firehose”
✓※
~ 256자AWS 액세스 키 ID
Kinesis Data Firehose 인증에 사용하는 AWS 액세스 키 ID입니다. IAM 사용자에게는 지정된 Firehose 전송 스트림으로 레코드를 전송할 수 있는 권한이 필요합니다.
※ type이(가) “firehose” 이면 필수
awsSecretAccessKeystring{type} == “firehose”
✓※
~ 256자AWS 시크릿 액세스 키
Kinesis Data Firehose 인증을 위해 액세스 키 ID와 짝을 이루는 AWS 시크릿 액세스 키입니다.
※ type이(가) “firehose” 이면 필수
firehoseStreamNamestring{type} == “firehose”
✓※
~ 256자Kinesis Firehose 스트림 이름
로그 데이터의 전송 대상이 되는 Kinesis Data Firehose 전송 스트림의 이름입니다.
※ type이(가) “firehose” 이면 필수
firehoseCompressData문자열 열거형
enum {
  “none”,
  “gzip”
}
{type} == “firehose”“none”Kinesis Firehose로 출력하는 데이터를 압축할지 여부
Kinesis Data Firehose로 전송하기 전에 로그 데이터를 압축할지를 설정합니다. Gzip 압축을 사용하면 데이터 전송량과 스토리지 비용을 절감할 수 있습니다.
정의설명
none압축하지 않음
gzipGzip
※ type이(가) “firehose” 이면 필수

GetAttr

!GetAttr 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemNamespace생성한 네임스페이스

구현 예제

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: null
import (
    "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 Template
class 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 Template
public 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 Template
import 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 Template

Dashboard

대시보드

로그 데이터와 메트릭을 시각화하기 위한 커스터마이즈 가능한 대시보드입니다. 각 대시보드는 레이아웃과 위젯 설정을 JSON 페이로드로 저장하여, 로그 분석의 맞춤형 뷰를 만들 수 있습니다.

Request

리소스 생성·갱신 요청

타입활성화 조건필수기본값값 제한설명
namespaceNamestring
~ 128자네임스페이스 이름
네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
displayNamestring
~ 256자표시용 이름
이 대시보드의 사람이 읽기 쉬운 이름으로, 대시보드 목록과 헤더에 표시됩니다.
descriptionstring~ 1024자설명문

GetAttr

!GetAttr 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemDashboard생성한 대시보드

구현 예제

Type: GS2::Log::Dashboard
Properties:
  NamespaceName: namespace-0001
  DisplayName: Sample Dashboard 0001
  Description: null
import (
    "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 Template
class 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 Template
public 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 Template
import 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 Template

FacetModel

패싯 모델

로그 데이터의 필터링과 집계에 사용할 수 있는 패싯 필드를 정의합니다. 패싯을 통해 서비스 이름, 메서드, 상태, 커스텀 필드 등 특정 차원으로 로그 검색 결과를 좁힐 수 있습니다.

Request

리소스 생성·갱신 요청

타입활성화 조건필수기본값값 제한설명
namespaceNamestring
~ 128자네임스페이스 이름
네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
fieldstring
~ 128자패싯 필드 이름
이 패싯이 대상으로 하는 로그 필드의 이름입니다(예: “service”, “method”, “status”).
type문자열 열거형
enum {
  “string”,
  “double”,
  “measure”
}
패싯 데이터 타입
패싯 필드의 데이터 타입입니다. “string"은 값 카운트가 있는 범주형 값에, “double"은 범위 필터링이 있는 숫자 값에, “measure"는 통계 분석이 있는 측정값에 사용됩니다.
정의설명
string문자열
double숫자
measure측정값
displayNamestring
~ 128자표시용 이름
이 패싯의 사람이 읽을 수 있는 이름으로, 로그 검색 UI에 표시됩니다.
orderint00 ~ 100000표시 순서
UI에서 이 패싯을 표시할 때의 정렬 순서입니다. 값이 작을수록 먼저 표시됩니다.

GetAttr

!GetAttr 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemFacetModel생성한 패싯 모델

구현 예제

Type: GS2::Log::FacetModel
Properties:
  NamespaceName: namespace-0001
  Field: facet-model-0001
  Type: string
  DisplayName: Sample Facet Model 0001
  Order: null
import (
    "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 Template
class 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 Template
public 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 Template
import 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