Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenSearch 1.2 - Index pattern programmatically

Tags:

opensearch

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?

like image 767
Wolfetto Avatar asked Aug 16 '26 00:08

Wolfetto


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

like image 114
doge76 Avatar answered Aug 18 '26 12:08

doge76



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!