GS2-Log GS2-Deploy/CDK リファレンス
GS2-Deployのスタックの作成に使用するテンプレートのフォーマットと、CDKによる各種言語のテンプレート出力の実装例
エンティティ
Namespace
ネームスペース
ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。
GS2 のサービスは基本的にネームスペースというレイヤーがあり、ネームスペースが異なれば同じサービスでもまったく別のデータ空間として取り扱われます。
そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128文字 | ネームスペース名 | ||||||||||
| description | string | ~ 1024文字 | 説明文 | |||||||||||
| type | 文字列列挙型 enum { “gs2”, “bigquery”, “firehose” } | ✓ | “gs2” | ~ 128文字 | ログの書き出し方法 
 | |||||||||
| gcpCredentialJson | string | {type} == “bigquery” | ✓ | ~ 5120文字 | GCPのクレデンシャル type が “bigquery” であれば 必須 | |||||||||
| bigQueryDatasetName | string | {type} == “bigquery” | ✓ | ~ 1024文字 | BigQueryのデータセット名 type が “bigquery” であれば 必須 | |||||||||
| logExpireDays | int | {type} in [“gs2”, “bigquery”] | ✓ | 0 ~ 3650 | ログの保存期間(日) type が “gs2”,“bigquery"であれば 必須 | |||||||||
| awsRegion | string | {type} == “firehose” | ✓ | ~ 256文字 | AWSのリージョン type が “firehose” であれば 必須 | |||||||||
| awsAccessKeyId | string | {type} == “firehose” | ✓ | ~ 256文字 | AWSのアクセスキーID type が “firehose” であれば 必須 | |||||||||
| awsSecretAccessKey | string | {type} == “firehose” | ✓ | ~ 256文字 | AWSのシークレットアクセスキー type が “firehose” であれば 必須 | |||||||||
| firehoseStreamName | string | {type} == “firehose” | ✓ | ~ 256文字 | Kinesis Firehose のストリーム名 type が “firehose” であれば 必須 | |||||||||
| firehoseCompressData | 文字列列挙型 enum { “none”, “gzip” } | {type} == “firehose” | ✓ | “none” | ~ 128文字 | Kinesis Firehose に出力するデータを圧縮するか 
 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 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 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 TemplateAccessLog
アクセスログ
マイクロサービスへのリクエスト及びその応答内容を記録したログです。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| timestamp | long | ✓ | 日時 (UNIX時間 単位:ミリ秒) | |||
| requestId | string | ✓ | ~ 1024文字 | リクエストID | ||
| service | string | ✓ | ~ 1024文字 | マイクロサービスの種類 | ||
| method | string | ✓ | ~ 1024文字 | マイクロサービスのメソッド | ||
| userId | string | ~ 128文字 | ユーザーID | |||
| request | string | ✓ | ~ 10485760文字 | リクエストパラメータ | ||
| result | string | ✓ | ~ 10485760文字 | 応答内容 | 
AccessLogCount
アクセスログ集計
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| service | string | ~ 1024文字 | マイクロサービスの種類 | |||
| method | string | ~ 1024文字 | マイクロサービスのメソッド | |||
| userId | string | ~ 128文字 | ユーザーID | |||
| count | long | ✓ | 0 ~ 9223372036854775805 | 回数 | 
IssueStampSheetLog
トランザクション発行ログ
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| timestamp | long | ✓ | 日時 (UNIX時間 単位:ミリ秒) | |||
| transactionId | string | ✓ | ~ 1024文字 | トランザクションID | ||
| service | string | ✓ | ~ 1024文字 | マイクロサービスの種類 | ||
| method | string | ✓ | ~ 1024文字 | マイクロサービスのメソッド | ||
| userId | string | ✓ | ~ 128文字 | ユーザーID | ||
| action | string | ✓ | ~ 1024文字 | 入手アクション | ||
| args | string | ✓ | ~ 5242880文字 | 引数 | ||
| tasks | List<string> | 0 ~ 10 items | スタンプタスクリスト | 
IssueStampSheetLogCount
トランザクション発行ログ集計
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| service | string | ~ 1024文字 | マイクロサービスの種類 | |||
| method | string | ~ 1024文字 | マイクロサービスのメソッド | |||
| userId | string | ~ 128文字 | ユーザーID | |||
| action | string | ~ 1024文字 | 入手アクション | |||
| count | long | ✓ | 0 ~ 9223372036854775805 | 回数 | 
ExecuteStampSheetLog
入手アクション実行ログ
マイクロサービスごとのトランザクションの実行内容ログです。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| timestamp | long | ✓ | 日時 (UNIX時間 単位:ミリ秒) | |||
| transactionId | string | ✓ | ~ 1024文字 | トランザクションID | ||
| service | string | ✓ | ~ 1024文字 | マイクロサービスの種類 | ||
| method | string | ✓ | ~ 1024文字 | マイクロサービスのメソッド | ||
| userId | string | ✓ | ~ 128文字 | ユーザーID | ||
| action | string | ✓ | ~ 1024文字 | 入手アクション | ||
| args | string | ✓ | ~ 5242880文字 | 引数 | 
ExecuteStampSheetLogCount
入手アクション実行ログ集計
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| service | string | ~ 1024文字 | マイクロサービスの種類 | |||
| method | string | ~ 1024文字 | マイクロサービスのメソッド | |||
| userId | string | ~ 128文字 | ユーザーID | |||
| action | string | ~ 1024文字 | 入手アクション | |||
| count | long | ✓ | 0 ~ 9223372036854775805 | 回数 | 
ExecuteStampTaskLog
スタンプタスク実行ログ
マイクロサービスごとのスタンプタスクの実行内容ログです。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| timestamp | long | ✓ | 日時 (UNIX時間 単位:ミリ秒) | |||
| taskId | string | ✓ | ~ 1024文字 | タスクID | ||
| service | string | ✓ | ~ 1024文字 | マイクロサービスの種類 | ||
| method | string | ✓ | ~ 1024文字 | マイクロサービスのメソッド | ||
| userId | string | ✓ | ~ 128文字 | ユーザーID | ||
| action | string | ✓ | ~ 1024文字 | 入手アクション | ||
| args | string | ✓ | ~ 5242880文字 | 引数 | 
ExecuteStampTaskLogCount
入手アクション実行ログ集計
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| service | string | ~ 1024文字 | マイクロサービスの種類 | |||
| method | string | ~ 1024文字 | マイクロサービスのメソッド | |||
| userId | string | ~ 128文字 | ユーザーID | |||
| action | string | ~ 1024文字 | 入手アクション | |||
| count | long | ✓ | 0 ~ 9223372036854775805 | 回数 | 
AccessLogWithTelemetry
テレメトリー情報付きアクセスログ
マイクロサービスへのリクエスト及びその応答内容を記録したログにレスポンスタイムや呼び出し元のコンテキスト情報を付加したログ
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| timestamp | long | ✓ | 日時 (UNIX時間 単位:ミリ秒) | |||||||||
| sourceRequestId | string | ✓ | ~ 1024文字 | 呼び出し元リクエストID | ||||||||
| requestId | string | ✓ | ~ 1024文字 | リクエストID | ||||||||
| duration | long | ✓ | 0 ~ 9223372036854775805 | 実行時間(ms) | ||||||||
| service | string | ✓ | ~ 1024文字 | マイクロサービスの種類 | ||||||||
| method | string | ✓ | ~ 1024文字 | マイクロサービスのメソッド | ||||||||
| userId | string | ~ 128文字 | ユーザーID | |||||||||
| request | string | ✓ | ~ 10485760文字 | リクエストパラメータ | ||||||||
| result | string | ✓ | ~ 10485760文字 | 応答内容 | ||||||||
| status | 文字列列挙型 enum { “ok”, “error” } | ✓ | ~ 128文字 | 実行時間(ms) 
 | 
InGameLogTag
ゲーム内ログのタグ
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| key | string | ✓ | ~ 64文字 | タグ名 | ||
| value | string | ✓ | ~ 128文字 | タグ値 |