OpenSearch 1.2 - 以编程方式索引模式

问题描述 投票:0回答:2

我正在尝试以编程方式为 Opensearch 中的仪表板创建

index_pattern

由于我在Opensearch文档上没有找到任何与之相关的内容,所以我尝试了elastic search

saved_objects
api:

POST /api/saved_objects/index-pattern/my_index_pattern
{
  "attributes":{
    "title": "my_index"
  }
}

但是当我调用它时,出现以下错误:

{
  "error" : "no handler found for uri [/api/saved_objects/index-pattern/my_index_pattern?pretty=true] and method [POST]"
}

如何解决?对于 Opensearch 创建

index_pattern
是否有不同的要求?

opensearch
2个回答
1
投票
curl -k -X POST http://<host>:5601/api/saved_objects/index-pattern/logs-* -H "osd-xsrf:true" -H "content-type:application/json" -d '
{
  "attributes": {
    "title": "logs-*",
    "timeFieldName": "@timestamp"
   }
}'

这对我有用


0
投票

感谢这里的博客:https://repost.aws/knowledge-center/opensearch-index-pattern

运行以下curl命令将授权cookie生成到auth.txt文件中:

curl -X POST  https://opensearch-end-point/_dashboards/auth/login  \
     -H "osd-xsrf: true" \
     -H "content-type: application/json" \
     -d '{"username":"<username>", "password":"<password>"}' \
     -c auth.txt

然后,提交索引模式创建请求:

curl -X POST  https://opensearch-end-point/_dashboards/api/saved_objects/index-pattern/  \
     -H "osd-xsrf: true" \
     -H "content-type: application/json" \
     -d '{ "attributes": { "title": "sample-index*" } }' \
     -b auth.txt

为我工作

© www.soinside.com 2019 - 2024. All rights reserved.