How to create and set default Index in kibana 6.1 using Python

Hi @all,

I would like to create and set default index in Kibana 6.1 using Python. How to achieve that?

Sandeep Sarkar

Hi ,
I don't really understand your question. What do you mean by Python?
By default, you will be using the default .kibana index. This is set in the kibana.yml . If you want this to be different, you could change the setting in the config file.

There will be no index created in ES until you load data from a source (like Logstash or Beats) or until you create it using the API yourself.
You can check what indices you have in your ES by running a "GET _cat/indices" on localhost:9200 (or your ES host and port).
If you've run Logstash and created the index, you should be seeing an index in the result from above that is starting with "logstash-".

Now, as far as Kibana is concerned, If that data is there, you can now create your index pattern in Kibana by going to "Management" -> "Index patterns" and you can create the pattern there (the field for Index pattern will have the default value of "logstash-*", which should work if you have the logstash index in ES).


Hi @rashmi,
I am sorry for not being clear. Prior to 6.x I used to use curl command to set default index in the following way:

curl -XPUT  'http://<es_ip>:9200/.kibana/config/5.6.4' -d '{"defaultIndex" : "log*"}'

But now after migrating to 6.x when I try to perform this step I get "Kibana index out of date..." error message. I figured out the problem is with this curl command. So I wanted to know how to achieve the same in Kibana 6.1. Has there been change in api if yes then which api to use?

Thanks for helping out.
Sandeep Sarkar

Hi @Sandeep_Sarkar
Ah, I get it now. In order to migrate to Kibana 6, your Kibana index needs to be reindexed. A UI is available in X-Pack 5.6 to assist with the migration for later versions. ( 6>) This is the easier way using Kibana Migration Assistant in the UI.
Should you require to do this manualy, here are some steps how to achieve this,

Hope this helps,

curl -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: true" localhost:5601/api/kibana/settings/defaultIndex -d '{"value": "your-index-id"}'


I just tried this command in Kibana 6.1.3, and confirmed that it didn't work. Steps to reproduce the issue,

  1. Load some sample data into Elasticsearch 6.1.3 cluster;
  2. Create two index patterns "sample1-* " and "sample2-* ", and make "sample1-* " as the default one. Everything is OK so far;
  3. Change the default index pattern to "sample2-*" using the following command,

curl -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: true" -d '{"value": "sample2-*"}' -u elastic:Changeme123

The response of the above command was:


  1. Go to kibana UI --> Management -> Index pattern, I expected to see that "example2-*" was the default one, but actual result was that I saw a warning message "No default index pattern.".

By the way, I do not find any REST APIs in the offical site as below to ceate/query/update objects, i.e., index patterns, users, roles. Can you please point me the exact link containing these info?

Kibana Guide [7.15] | Elastic

How did you create index-patterns? If you had created from UI, the ID of index-pattern would be different from the title. Use the following command to find id.

Use the ID of sample2-* in defaultIndex in the following POST call.

  • curl -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: true" localhost:5601/api/kibana/settings/defaultIndex -d '{"value": "your-index-id"}'

I am guessing that Kibana is looking for a defaultIndex with ID as sample2 and since it doesnt find any, its displaying no index pattern warning.

The latest REST API definitions are available at this page.

Thanks for the response.

This command did not work although it did not return any error message. But I got the ID of index pattern using the following command:

curl -u elastic:Changeme123

It did work either. The response was as below,


Did it work? Your message says it worked.

If it dint, Can you try setting default index to sample2-* from UI and then try navigating to a different tab, say visualize and check if the defaultIndex value remains same or does it ask you to set again?

Sorry, I wanted to say "It did NOT work either". :frowning:

I tried to set the default index to sample2-* from UI, and then navigating to discover, and the "sample2-* was selected by default correctly.

To be more clear, I need to logout and login kibana UI again after setting the default index to "sample2-", otherwise, the default index pattern displayed on discover page is still "sample1-".

Hi ahrtr,

Were you able to get this to work?

Did you check if the mapping for .kibana is correct? I had a similar issue recently where the defaultIndex was automatically reset. Turns out the .kibana mapping created by default when you start kibana wasnt correct. Your mapping should match the one at

hi @rajisankar.

I did not follow up this issue any more, since it's just a minor issue for me.

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