0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【OpenSearch】サンプルデータを作る簡単な方法があったので紹介

Last updated at Posted at 2023-03-23

背景

OpenSearchのPainless scriptを利用することで重い処理を意図的に行いスローログを出力できるかテストしようとした
その際に大量のドキュメントが含まれたインデックスが必要だった
その大量のドキュメントをサンプルとして生成できる方法があったので紹介

環境

AWS OpenSearch 2.3
CUIの踏み台はAmazonLinux2を使用
curl 7.84

ポイント

CUIの場合OpenSearch Dashboards APIを使用するためにまずクッキーを取得する必要がある

やってみた

GUI ver

ログインをして、HomeからAdd data をクリック
image.png

Sample web logs > Add data をクリック
image.png

CUI ver

踏み台EC2からパスワード認証で実施した
auth.txtにクッキー情報がある

curl -k -X POST  https://opensearch.local/_dashboards/auth/login  \
-H "osd-xsrf: true" \
-H "content-type:application/json" \
-d '{"username":"<ユーザ名>", "password":"<パスワード>"}' \
-c auth.txt

curl -k  -X POST  https://opensearch.local/_dashboards/api/sample_data/logs  \
-H "osd-xsrf:true" \
-H "content-type:application/json" \
-b auth.txt

osd-xsrf: true をヘッダーに追加しない場合、下記のエラーが生じますので注意

{"status": 400, "body": "Request must contain a osd-xsrf header."}

参考資料
[1] Quickstart guide for OpenSearch Dashboards - OpenSearch documentation
https://opensearch.org/docs/latest/dashboards/quickstart-dashboards/
[2] Requests to OpenSearch Dashboards fail with “Request must contain a osd-xsrf header” | Common issues - OpenSearch documentation
https://opensearch.org/docs/2.0/troubleshoot/index/#requests-to-opensearch-dashboards-fail-with-request-must-contain-a-osd-xsrf-header
[3] Set advanced settings with the Amazon OpenSearch Service Dashboards API | AWS Big Data Blog
https://aws.amazon.com/blogs/big-data/set-advanced-settings-with-the-amazon-opensearch-service-dashboards-api/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?