OpenSearch Ingestion が NextGen の時系列コレクションに書き込めるようになったので試してみた

OpenSearch Ingestion が NextGen の時系列コレクションに書き込めるようになったので試してみた

Amazon OpenSearch Ingestion (OSIS) のパイプラインから NextGen の時系列コレクションへ、追加の引数なしで書き込めました。timestamp が欠けたドキュメントは、コレクションへの直接書き込みでは拒否され、OSIS 経由では取り込み時刻が入って保存されました。
2026.11.19

はじめに

2026年11月17日に、Amazon OpenSearch Ingestion (OSIS) のパイプラインから Amazon OpenSearch Serverless (NextGen) の時系列コレクションへ書き込めるようになりました。

https://aws.amazon.com/jp/about-aws/whats-new/2026/11/amazon-opensearch-ingestion-service-nextgen-time-series-collections/

この記事では、OSIS のパイプラインから時系列コレクションへの書き込みと検索、index template の設定の継承、timestamp が欠けたドキュメントの扱いを確かめます。

検証環境

項目 内容
実施日 2026年11月19日
リージョン ap-northeast-1
AWS CLI 2.41.1
パイプラインのソース HTTP
コレクションの種類 TIMESERIES(NextGen)
署名付きリクエスト awscurl

作成するリソース

コレクション

NextGen のコレクショングループ、暗号化ポリシー、手元から検索できるよう公開アクセスを許可するネットワークポリシー、時系列コレクションの順に作りました。コレクショングループは --generation NEXTGEN で作り、OCU は最小 0、最大 2、standby replica は ENABLED にしました。

aws opensearchserverless create-collection-group --name ngts-group --standby-replicas ENABLED --generation NEXTGEN --capacity-limits minIndexingCapacityInOCU=0\,minSearchCapacityInOCU=0\,maxIndexingCapacityInOCU=2\,maxSearchCapacityInOCU=2
aws opensearchserverless create-security-policy --type encryption --name ngts-enc --policy file://encryption-policy.json
aws opensearchserverless create-security-policy --type network --name ngts-net --policy file://network-policy.json
aws opensearchserverless create-collection --name ngts-logs --type TIMESERIES --collection-group-name ngts-group
aws opensearchserverless batch-get-collection --names ngts-logs

コレクションの種類は TIMESERIES で、作成から約20秒後に確認すると ACTIVE になっていました。パイプラインの hosts と検索リクエストで使うエンドポイントは、batch-get-collection の応答の collectionEndpoint で確認できます。

encryption-policy.json と network-policy.json

encryption-policy.json

{
  "Rules": [{"ResourceType": "collection", "Resource": ["collection/ngts-logs"]}],
  "AWSOwnedKey": true
}

network-policy.json

[
  {
    "Description": "Public access for queries",
    "Rules": [
      {"ResourceType": "collection", "Resource": ["collection/ngts-logs"]},
      {"ResourceType": "dashboard", "Resource": ["collection/ngts-logs"]}
    ],
    "AllowFromPublic": true
  }
]

パイプラインロールとアクセス権限

OSIS が引き受けるパイプラインロールを作り、権限ポリシーを付けます。続けて、このロールを Principal に含むデータアクセスポリシーを作ります。

aws iam create-role --role-name ngts-pipeline-role --assume-role-policy-document file://pipeline-role-trust.json
aws iam put-role-policy --role-name ngts-pipeline-role --policy-name ngts-pipeline-access --policy-document file://pipeline-role-policy.json
aws opensearchserverless create-access-policy --type data --name ngts-data --policy file://data-access-policy.json

データアクセスポリシーでは、パイプラインロールと、検索・template 登録に使う IAM ロールへ、同じ規則で権限を付与します。ReadDocument は検索のために、collection の CreateCollectionItems と UpdateCollectionItems は template の登録のために含めました。このポリシーで書き込みと検索が通りました。パイプラインロールの権限ポリシーと信頼ポリシーの例は、公式ドキュメントにあります。

https://docs.aws.amazon.com/opensearch-service/latest/developerguide/pipeline-collection-access.html

pipeline-role-trust.json、pipeline-role-policy.json、data-access-policy.json

pipeline-role-trust.json

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {"Service": "osis-pipelines.amazonaws.com"},
      "Action": "sts:AssumeRole"
    }
  ]
}

pipeline-role-policy.json

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Statement1",
      "Effect": "Allow",
      "Action": [
        "aoss:APIAccessAll",
        "aoss:BatchGetCollection",
        "aoss:CreateSecurityPolicy",
        "aoss:GetSecurityPolicy",
        "aoss:UpdateSecurityPolicy"
      ],
      "Resource": "*"
    }
  ]
}

data-access-policy.json(<ACCOUNT_ID> と <YOUR_ROLE_NAME> は自分の環境の値に置き換えます)

[
  {
    "Description": "Pipeline role and verification user",
    "Rules": [
      {
        "ResourceType": "index",
        "Resource": ["index/ngts-logs/*"],
        "Permission": [
          "aoss:CreateIndex",
          "aoss:UpdateIndex",
          "aoss:DescribeIndex",
          "aoss:WriteDocument",
          "aoss:ReadDocument"
        ]
      },
      {
        "ResourceType": "collection",
        "Resource": ["collection/ngts-logs"],
        "Permission": [
          "aoss:DescribeCollectionItems",
          "aoss:CreateCollectionItems",
          "aoss:UpdateCollectionItems"
        ]
      }
    ],
    "Principal": [
      "arn:aws:iam::<ACCOUNT_ID>:role/ngts-pipeline-role",
      "arn:aws:iam::<ACCOUNT_ID>:role/<YOUR_ROLE_NAME>"
    ]
  }
]

パイプライン

パイプラインの設定は次のとおりです。sink の hosts にコレクションのエンドポイントを指定し、serverless を true にします。index の ${/idx} は、ドキュメントの idx フィールドの値を書き込み先の index 名にする書式です。template のある index とない index を1つのパイプラインで比べるため、この書式にしました。network_policy_name には、まだ存在しないネットワークポリシー名を指定しました(動作は後述)。

version: "2"
ngts-pipeline:
  source:
    http:
      path: "/logs"
  sink:
    - opensearch:
        hosts: ["https://<collection-id>.aoss.ap-northeast-1.on.aws"]
        index: "${/idx}"
        aws:
          sts_role_arn: "arn:aws:iam::<ACCOUNT_ID>:role/ngts-pipeline-role"
          region: "ap-northeast-1"
          serverless: true
          serverless_options:
            network_policy_name: "ngts-osis-net"

この設定を pipeline.yaml として保存し、create-pipeline に渡します。NextGen 向けの追加引数なしで作成できました。

aws osis create-pipeline --pipeline-name ngts-pipeline --min-units 1 --max-units 1 --pipeline-configuration-body file://pipeline.yaml --pipeline-role-arn arn:aws:iam::<ACCOUNT_ID>:role/ngts-pipeline-role
aws osis get-pipeline --pipeline-name ngts-pipeline

作成から3分37秒後に確認すると、Status は ACTIVE になっていました。取り込み先のエンドポイントは get-pipeline の IngestEndpointUrls に出るので、値が入ってから POST します。

ドキュメントが拒否された理由は POST の応答に出ないため(後述)、パイプラインのログ出力を有効にしておきます。CloudWatch Logs の log group を作り、update-pipeline で指定します。

aws logs create-log-group --log-group-name /aws/vendedlogs/OpenSearchIngestion/ngts-pipeline/audit-logs
aws osis update-pipeline --pipeline-name ngts-pipeline --log-publishing-options IsLoggingEnabled=true\,CloudWatchLogDestination=\{LogGroup=/aws/vendedlogs/OpenSearchIngestion/ngts-pipeline/audit-logs\}

動作確認

コレクションのエンドポイントとパイプラインの取り込みエンドポイントへのリクエストには、SigV4 署名を付けられる awscurl を使いました。

template の登録と書き込み

まず、次の index template を、ngts-tpl-test への最初の書き込みより前に登録します。index_patterns に一致する index へ適用されます。

{
  "index_patterns": ["ngts-tpl*"],
  "template": {
    "settings": {
      "index.warm.after": "2d",
      "index.data.retention": "30"
    }
  }
}

この内容を index-template.json として保存し、コレクションのエンドポイントへ PUT します。

awscurl --service aoss --region ap-northeast-1 -X PUT -H Content-Type:\ application/json -d @index-template.json https://<collection-id>.aoss.ap-northeast-1.on.aws/_index_template/ngts-tpl

data.retention には、日数を単位なしの数字で渡します。"30d" を渡すと、400 で Data retention value must be a valid integer representing days が返りました。"30" を渡すと、{"acknowledged":true} が返って登録できました。

続けて、パイプラインへ5件を POST します。idx の値で、3件が ngts-default(template なし)、2件が ngts-tpl-test(template ngts-tpl の対象)に振り分けられます。

awscurl --service osis --region ap-northeast-1 -X POST -H Content-Type:\ application/json -d @batch-1-valid.json https://<pipeline-endpoint>/logs

応答は 200 OK でした。

batch-1-valid.json
[
  {"idx": "ngts-default", "@timestamp": "2026-11-19T01:25:00Z", "level": "INFO",  "message": "valid-1 default index"},
  {"idx": "ngts-default", "@timestamp": "2026-11-19T01:25:01Z", "level": "WARN",  "message": "valid-2 default index"},
  {"idx": "ngts-default", "@timestamp": "2026-11-19T01:25:02Z", "level": "ERROR", "message": "valid-3 default index"},
  {"idx": "ngts-tpl-test", "@timestamp": "2026-11-19T01:25:03Z", "level": "INFO", "message": "valid-4 template index"},
  {"idx": "ngts-tpl-test", "@timestamp": "2026-11-19T01:25:04Z", "level": "INFO", "message": "valid-5 template index"}
]

POST から44秒後に検索すると、ngts-default に3件、ngts-tpl-test に2件が入っていました。@timestamp は date 型にマップされました。

awscurl --service aoss --region ap-northeast-1 -X GET https://<collection-id>.aoss.ap-northeast-1.on.aws/ngts-default/_search\?sort=@timestamp:asc
{"took":109,"timed_out":false,"_shards":{"total":0,"successful":0,"skipped":0,"failed":0},"hits":{"total":{"value":3,"relation":"eq"},"max_score":null,"hits":[{"_index":"ngts-default","_id":"1%3A0%3Arlxn8aEBEOGzI3mxkSZa","_score":null,"_source":{"idx":"ngts-default","@timestamp":"2026-11-19T01:25:00Z","level":"INFO","message":"valid-1 default index"},"sort":[1795051500000]},{"_index":"ngts-default","_id":"1%3A0%3Ar1xn8aEBEOGzI3mxkSZa","_score":null,"_source":{"idx":"ngts-default","@timestamp":"2026-11-19T01:25:01Z","level":"WARN","message":"valid-2 default index"},"sort":[1795051501000]},{"_index":"ngts-default","_id":"1%3A0%3AsFxn8aEBEOGzI3mxkSZa","_score":null,"_source":{"idx":"ngts-default","@timestamp":"2026-11-19T01:25:02Z","level":"ERROR","message":"valid-3 default index"},"sort":[1795051502000]}]}}

index 設定の継承

設定は次のコマンドで取得しました。

awscurl --service aoss --region ap-northeast-1 -X GET https://<collection-id>.aoss.ap-northeast-1.on.aws/<index名>/_settings

template を登録してから OSIS が初めて書き込んだ index(ngts-tpl-test)には、warm.after と data.retention が継承されました。template のない ngts-default と並べると次のとおりです。

index template warm.after data.retention
ngts-default なし 1d(既定) 設定なし
ngts-tpl-test ngts-tpl 2d 30d(template には 30 を渡した)

ネットワークポリシーの規則

パイプラインの作成時に、network_policy_name に指定した名前(ngts-osis-net)のネットワークポリシーを OSIS が作りました。公開アクセス用の ngts-net とは別のポリシーです。中身は、OSIS が作る VPC エンドポイントからコレクションへのアクセスを許可する規則です。VPC エンドポイントの ID は、get-pipeline の ServiceVpcEndpoints で確認できます。

aws opensearchserverless get-security-policy --type network --name ngts-osis-net

応答に含まれる policy の中身は次のとおりです。

[
    {
        "Rules": [
            {
                "Resource": [
                    "collection/ngts-logs"
                ],
                "ResourceType": "collection"
            }
        ],
        "SourceVPCEs": [
            "<VPC_ENDPOINT_ID>"
        ],
        "Description": "Created by Data Prepper"
    }
]

timestamp の扱い

時系列コレクションでは、全ドキュメントに timestamp フィールドが必要です。timestamp が欠落している、null である、または値が不正なドキュメントは拒否されます。

https://aws.amazon.com/blogs/big-data/introducing-the-next-generation-of-serverless-time-series-for-amazon-opensearch-service/

OSIS 経由で書き込むとこの条件がどう効くかを、コレクションへ直接 _bulk で書き込んだ場合と比べました。

OSIS 経由と直接書き込みの違い

@timestamp が有効な2件と、欠落・null・不正文字列 "not-a-date" の各1件、計5件を OSIS へ POST しました。応答は 200 OK で、検索では5件のうち4件が入っていました。不正文字列の1件は保存されませんでした。

awscurl --service osis --region ap-northeast-1 -X POST -H Content-Type:\ application/json -d @batch-2-mixed.json https://<pipeline-endpoint>/logs
batch-2-mixed.json
[
  {"idx": "ngts-default", "@timestamp": "2026-11-19T01:30:00Z", "message": "mixed-1 valid"},
  {"idx": "ngts-default", "message": "mixed-2 timestamp missing"},
  {"idx": "ngts-default", "@timestamp": null, "message": "mixed-3 timestamp null"},
  {"idx": "ngts-default", "@timestamp": "not-a-date", "message": "mixed-4 timestamp invalid string"},
  {"idx": "ngts-default", "@timestamp": "2026-11-19T01:30:04Z", "message": "mixed-5 valid"}
]

同じパターンの4件(有効、欠落、null、不正文字列)を、コレクションへ直接 _bulk で送りました。

awscurl --service aoss --region ap-northeast-1 -X POST -H Content-Type:\ application/x-ndjson -d @direct-bulk-mixed.ndjson https://<collection-id>.aoss.ap-northeast-1.on.aws/_bulk
direct-bulk-mixed.ndjson
{"index":{"_index":"ngts-direct"}}
{"@timestamp":"2026-11-19T01:35:00Z","message":"direct-1 valid"}
{"index":{"_index":"ngts-direct"}}
{"message":"direct-2 timestamp missing"}
{"index":{"_index":"ngts-direct"}}
{"@timestamp":null,"message":"direct-3 timestamp null"}
{"index":{"_index":"ngts-direct"}}
{"@timestamp":"not-a-date","message":"direct-4 timestamp invalid string"}

応答は errors: true で、有効な1件の status は 201 でした。欠落と null は document is missing required timestamp field [@timestamp]、不正文字列は failed to parse field [@timestamp] of type [date] で拒否されました。

@timestamp OSIS 経由(検索結果) 直接書き込み(_bulk の各項目の status)
欠落 数値 1795051761411 で保存 400
null 数値 1795051761411 で保存 400
不正文字列 保存されない 400

OSIS 経由で補われた 1795051761411 はエポックミリ秒で、2026-11-19T01:29:21.411Z です。POST は 01:29:20Z に送ったので、送信直後の時刻が入っています。有効な @timestamp の2件は、元の文字列のまま保存されました。

OSS の Data Prepper 2.17.0 の変更履歴には、NextGen の時系列 index に対する sink の動作が書かれています。timestamp_field に当たるフィールドがないドキュメントには、@timestamp の値を移し、それもなければイベント時刻を補います。「document is missing required timestamp field」で拒否された項目は、timestamp を補ってから同じフラッシュで再送します。

https://raw.githubusercontent.com/opensearch-project/data-prepper/main/release/release-notes/data-prepper.change-log-2.17.0.md

S3 のログを ingestion job で取り込む intelligent ingestion でも、@timestamp が欠落した行は拒否されず、S3 オブジェクトの LastModified が入った例があります。OSIS 経由の取り込み時刻とは、補われる値が違います。

https://dev.classmethod.jp/articles/amazon-opensearch-serverless-time-series-intelligent-ingestion/

拒否の確認

拒否された理由は、パイプラインの CloudWatch Logs で確かめます。

aws logs filter-log-events --log-group-name /aws/vendedlogs/OpenSearchIngestion/ngts-pipeline/audit-logs --start-time <ミリ秒>

混在バッチを POST した直後に、次の4行が出ました(AWS SDK の警告と OpenSearchSink の起動行を除きます)。

2026-11-19T01:29:22.059 [ngts-pipeline-sink-worker-2-thread-1] WARN  org.opensearch.dataprepper.plugins.sink.opensearch.BulkRetryStrategy - Bulk Operation Failed. Number of retries 0. Retrying...
2026-11-19T01:29:22.059 [ngts-pipeline-sink-worker-2-thread-1] WARN  org.opensearch.dataprepper.plugins.sink.opensearch.BulkRetryStrategy - index = ngts-default operation = Index, error = document is missing required timestamp field [@timestamp]
2026-11-19T01:29:22.059 [ngts-pipeline-sink-worker-2-thread-1] WARN  org.opensearch.dataprepper.plugins.sink.opensearch.BulkRetryStrategy - index = ngts-default operation = Index, error = failed to parse field [@timestamp] of type [date] in document with id '15xs8aEBEB__X7foMJKF'. Preview of field's value: 'not-a-date'
2026-11-19T01:29:22.118 [ngts-pipeline-sink-worker-2-thread-1] WARN  org.opensearch.dataprepper.plugins.sink.opensearch.BulkIngester - Document failed to write to OpenSearch with error code 400. Configure a DLQ to save failed documents. Error: failed to parse field [@timestamp] of type [date] in document with id '15xs8aEBEB__X7foMJKF'. Preview of field's value: 'not-a-date' caused by failed to parse date field [not-a-date] with format [strict_date_optional_time||epoch_millis] caused by date_time_parse_exception: Failed to parse with all enclosed parsers

欠落と null の2件については、再試行の警告として missing の行が1行だけ出ました。2件とも、検索で保存されていることを確認できました。保存されなかった不正文字列の1件には、BulkIngester の失敗行が対応します。

timestamp_field を変えた index

index.timestamp_field を event_time にした template ngts-ctf を、書き込みの前に登録しました。

{
  "index_patterns": ["ngts-ctf*"],
  "template": {
    "settings": {
      "index.timestamp_field": "event_time"
    }
  }
}

この内容を index-template-ctf.json として保存し、前掲と同じコマンドで /_index_template/ngts-ctf へ PUT しました。続けて、次の4件を同様に POST しました。

batch-4-custom-timestamp-field.json
[
  {"idx": "ngts-ctf-test", "event_time": "2026-11-19T01:45:00Z", "message": "ctf-1 event_time present"},
  {"idx": "ngts-ctf-test", "@timestamp": "2026-11-19T01:45:01Z", "message": "ctf-2 only @timestamp"},
  {"idx": "ngts-ctf-test", "message": "ctf-3 no timestamp"},
  {"idx": "ngts-ctf-test", "event_time": "not-a-date", "message": "ctf-4 event_time invalid"}
]

応答は 200 OK で、3件が保存されました。event_time がある1件はそのまま保存されました。@timestamp だけを持つ1件は、その値 "2026-11-19T01:45:01Z" が event_time に移され、@timestamp は残りませんでした。どちらも持たない1件には、event_time に取り込み時刻の数値 1795052025250 が入りました。event_time が不正文字列の1件は保存されませんでした。この POST で作られた ngts-ctf-test の _settings では、timestamp_field は template どおり event_time になっていました。

まとめ

create-pipeline に NextGen 向けの追加引数を渡さなくても、OSIS のパイプラインから NextGen の時系列コレクションへ書き込めることを確認できました。

timestamp が欠けたドキュメントも、OSIS 経由では取り込み時刻が入って保存されました。

OSIS のパイプラインを使わずに、S3 に保存されたログを取り込む場合は、先日発表された intelligent ingestion のアップデートもご検討ください。

https://dev.classmethod.jp/articles/amazon-opensearch-serverless-time-series-intelligent-ingestion/

この記事をシェアする

AWSのお困り事はクラスメソッドへ

関連記事