'Create Index Pattern' via python3 / API

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

OpenSearch Dashboards v2.5.0

Describe the issue:

Using python3 and the API, have successfully ingested data, created an index and bulk loaded the data.

I have a dashboard that I manually set up by going to Stack Management → Index Patterns → Create Index Pattern; and creating an index pattern with the data I uploaded; then I can make dashboards / visualizations.

Is there a way via the API to do this part “Stack Management → Index Patterns → Create Index Pattern”?

My hope is that since I have a manual dashboard, when I upload new data to the same index, if I can re-create or update the index pattern, the dashboard will just update to reflect the new data that has been added.

Not certain if this is possible; appreciate any ideas.

Thanks!

Dan.

Configuration:

Relevant Logs or Screenshots:

You can call the saved object API of OpenSearch-Dashboards, note the request url should be OSD’s endpoint, not OpenSearch’s, like this:

$ curl -X POST localhost:5601/api/index_patterns/index-pattern/my-pattern  -H 'osd-xsrf: true' -H 'Content-Type: application/json' -d '
{
  "attributes": {
    "title": "my-pattern-*"
  }
}'

Thank you for your suggestion; my email notifications were ending up in spam and I missed this one (plus our OpenSearch work stalled, we are back on it now :slight_smile: ).

When I attempt in dev tools, I am getting :

NOTE : wr_0135_20240226110442 is the exact name of the source that has been successfully ingested

POST /api/index_patterns/index-pattern/wr_0135_20240226110442 -H ‘osd-xsrf: true’ -H ‘Content-Type: application/json’ -d ’
{
“attributes”: {
“title”: “wr_0135_20240226110442”
}
}’

{
“error”: “no handler found for uri [/api/index_patterns/index-pattern/wr_0135_20240226110442] and method [POST]”
}


Some additional information, after our last server update, the workflow I am trying to reproduce with the API is :

Dashboard management → Index Pattern → Create Index Pattern

where we specify the ingested data (index pattern name) and the time field in order to produce the Index Pattern.

Searching through the API documentation, I cannot find a reference that allows us to do this. It is the last piece blocking our full utilization of Opensearch.

Appreciate your help!

---- More Information ----

I saw a reply you posted regarding Kibana API, I tried :

curl -k -u ‘username:pswd’ -X POST https://<server_hn>:9200/api/saved_objects/index-pattern/wr_0135_20240226110442 -H ‘osd-xsrf: true’ -H ‘Content-Type: application/json’ -d ‘{“attributes”:{“title”: “wr_0135_20240226110442”}}’

Response :

{“error”:“no handler found for uri [/api/saved_objects/index-pattern/wr_0135_20240226110442] and method [POST]”}-bash-4.2$

The API is not in OpenSearch, but in OpenSearch-Dashboards, so you need to access the endpoint of OpenSearch-Dashboards whose port is 5601:

curl POST https://<the domain of OpenSearch-Dashboards>:5601/api/saved_objects/index-pattern/wr_0135_20240226110442