OpenSearch 1.2 - Index pattern programmatically

Viewed 834

I am trying to create an index_pattern for dashboard in Opensearch programmatically.

Due to the fact that I didn't found anything related to it on Opensearch documentation, I tried the elastic search saved_objects api:

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

But when I call it I got the following error:

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

How can I solve it? Are there a different call for Opensearch to create an index_pattern?

1 Answers
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"
   }
}'

this works for me

Related