I was successfully using API to create/import index-patterns using API with kibana 5.6.x version.
After upgrading to kibana 6.0.0, the API format has changed and I cannot anymore create index-patterns using curl.
What's the new format? I have multiple ways to get (export) the index-patterns from kibana 6 but I don't know how to save them programmatically.
There are two API's which can accomplish this, both of which are available in 5.6.x and remain unchanged.
We are currently working on documentation, but in the meantime, you can reference the PR's.
Dashboard import/export API. This can be used to export/import a dashboard with all of its dependencies, including the index pattern: https://github.com/elastic/kibana/pull/10858#issuecomment-327802510
Saved Objects API. This is used under the hood by the dashboard import/export API and can be used to persist the data underlying Kibana. https://github.com/elastic/kibana/pull/11632
Thanks tylersmalley for your response.
I've tried that but it doesn't seem to be working.
Example:
- The following query:
curl -XPUT -H "kbn-xsrf:true" "http://localhost:5601/api/saved_objects/index-pattern/e38f6e90-cf2f-11e7-a5ef-9f5ab64be49e" -d '{"version": 1, "attributes": {"title": "test-*"}}'
- it returns:
{"statusCode":400,"error":"Bad Request","message":"child "attributes" fails because ["attributes" is required]. "{"version": 1, "attributes": {"title": "test-*"}" is not allowed","validation":{"source":"payload","keys":["attributes","{"version": 1, "attributes": {"title": "test-*"}"]}}
After more investigation with the links you provided,
I've successfully installed a index-pattern in a indirect way.
I've done it by installing a dashboard. It seems that it also installs the index-patterns that depends on it.
However, I don't see how to set an index-pattern as the defaultIndex using an API.
I see that the defaultIndex is stored in the .kibana config but I don't know how to set it:
curl -XGET http://localhost:9200/.kibana/doc/_search?q=type:config
{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":1,"max_score":3.205453,"hits":[{"_index":".kibana","_type":"doc","_id":"config:6.0.0","_score":3.205453,"_source":{"type":"config","config":{"buildNum":16070,"defaultIndex":"291176c0-cfda-11e7-a5ef-9f5ab64be49e"}}}]}}
Any help on this will be very much appreciated. Thanks.
You need to add Content-Type: application/json
to the saved_objects API call.
There is an API to set settings, you can set the setting and inspect the network calls.
curl -X POST -H "Content-Type: application/json" -H "kbn-xsrf: true" -d '{"value":"e7502fa0-ca17-11e7-bab5-157d3f7aa014"}' http://elastic:changeme@localhost:5601/api/kibana/settings/defaultIndex
thanks a lot tylersmalley for your response, that worked!
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.