Set default index automatically in new spaces

I'm using the Rest API to create spaces for all of my different user groups in my Kibana 6.7.1 hosted in Elastic Cloud.

How do I set the default index in all of the spaces without having to use the web interface? I've not found anything in the current documentation, and the api/kibana/settings/defaultIndex API merrily replies 200 to my {"value": "space:index-pattern:indexPatternName"} POST body but doesn't seem to do anything. It particularly does not seem to have updated the index-pattern or the space's config documents in the index pointed to by the.kibana alias. Nor does the UI respond as if the index-pattern has been set. This behaviour appears to have been happening since 6.1.

Hey @Steven_Ensslen,

To set the default index pattern for a new space, you can prefix the API call with the space identifier. For example, if you are setting this for the "Marketing" space with a Space Identifier of marketing, then your API call would look something like:

POST /s/marketing/api/kibana/settings/defaultIndex

{
   "value": "indexPatternGUID"
}

If you were to inspect your .kibana index, this would set the default index pattern for the marketing space to the index pattern with the document id marketing:index-pattern:indexPatternGUID.

A couple of notes:

  • This will not create the index pattern; it only tells Kibana which index pattern should be the default for that particular space.
  • The API endpoint to set the default index pattern is not a publicly documented API, so it can potentially change unexpectedly between versions.
  • We recognize the docs for calling APIs within a particular space are lacking. We have a few open issues to improve the documentation, including https://github.com/elastic/kibana/issues/29646
1 Like

Thanks @Larry_Gregory!

For future reference, the mistake that I was making was the value I provided in value. The indexPatternGUID is the only thing to be entered there.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.