# How to set default Index in kibana 6.x using CLI

**URL:** https://discuss.elastic.co/t/how-to-set-default-index-in-kibana-6-x-using-cli/177651
**Category:** Kibana
**Created:** [April 19, 2019, 4:54pm UTC](https://discuss.elastic.co/t/how-to-set-default-index-in-kibana-6-x-using-cli/177651 "2019-04-19T16:54:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Alexey\_Zakharov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_zakharov/32/42165_2.png) [@Alexey\_Zakharov](https://discuss.elastic.co/u/Alexey_Zakharov)
#### Post date: [April 19, 2019, 4:54pm UTC](https://discuss.elastic.co/t/how-to-set-default-index-in-kibana-6-x-using-cli/177651/1 "2019-04-19T16:54:12Z")

</div>

This is a follow-up to [How to create and set default Index in kibana 6.1 using Python](https://discuss.elastic.co/t/how-to-create-and-set-default-index-in-kibana-6-1-using-python/119175)  
Any ideas how to sort that out?

---

<div class="post-metadata">

### Author: ![joshdover](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdover/32/42020_2.png) [@joshdover](https://discuss.elastic.co/u/joshdover)
#### Post date: [April 19, 2019, 10:12pm UTC](https://discuss.elastic.co/t/how-to-set-default-index-in-kibana-6-x-using-cli/177651/2 "2019-04-19T22:12:16Z")

</div>

With a little reverse engineering, I was able to get this request to work, where "myPattern" is the name of the index pattern I set as the default.

```auto
curl 'localhost:5601/api/kibana/settings' \
  -H 'content-type: application/json' \
  --data-binary '{"changes":{"defaultIndex":"myPattern"}}'

```

Keep in mind, this is not a public/stable API and could change at any time.

Let me know if that works for you!

---

<div class="post-metadata">

### Author: ![Alexey\_Zakharov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_zakharov/32/42165_2.png) [@Alexey\_Zakharov](https://discuss.elastic.co/u/Alexey_Zakharov)
#### Post date: [April 20, 2019, 10:23am UTC](https://discuss.elastic.co/t/how-to-set-default-index-in-kibana-6-x-using-cli/177651/3 "2019-04-20T10:23:30Z")

</div>

Hi @joshdover, thank you for suggestion.  
To make that request working, I had to add `-H "kbn-xsrf: true"` option.  
However it returns no error, it does not help. I can't see default index in UI ☹

---

<div class="post-metadata">

### Author: ![joshdover](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdover/32/42020_2.png) [@joshdover](https://discuss.elastic.co/u/joshdover)
#### Post date: [April 22, 2019, 2:53pm UTC](https://discuss.elastic.co/t/how-to-set-default-index-in-kibana-6-x-using-cli/177651/4 "2019-04-22T14:53:11Z")

</div>

Ah you may need to add the `-XPOST` option as well. I may have trimmed the original command too much. Could you share what command you're using if you get it to work?

---

<div class="post-metadata">

### Author: ![Alexey\_Zakharov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_zakharov/32/42165_2.png) [@Alexey\_Zakharov](https://discuss.elastic.co/u/Alexey_Zakharov)
#### Post date: [May 8, 2019, 5:17pm UTC](https://discuss.elastic.co/t/how-to-set-default-index-in-kibana-6-x-using-cli/177651/5 "2019-05-08T17:17:41Z")

</div>

Thank you, now it's working:

```
curl -XPOST http://localhost:5601/api/kibana/settings \
-H 'content-type: application/json' -H 'kbn-xsrf: true' \
--data-binary '{"changes":{"defaultIndex":"logs-*"}}'
```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 5, 2019, 5:17pm UTC](https://discuss.elastic.co/t/how-to-set-default-index-in-kibana-6-x-using-cli/177651/6 "2019-06-05T17:17:50Z")

</div>

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