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 Templateclass 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 Templatefrom 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 Templateclass 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 Templatefrom 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 Templateclass 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 Templatefrom 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