I'm playing around with the (relatively) new "saved objects" API and programmatically populating Kibana.
In 5.4 I used to dump the .kibana index and (re)create it. (Because there was no other way to populate Kibana besides the frontend - ugly, but it worked just good enough)
Under 6.6 I struggle for two reasons:
First: I can not use the create object api to (re-)import data generated with the get object api. I have to modify the exported data (drop id, updated_at, ...), there seems to be no way to import it otherwise.
Is this a known limitation and will be fixed in a future version? In my opinion the create object API should work with data exported by the get object API.
Second: If the imported index is the first one to be created I have still can't use it out of the box, because it seems to have to manually "star" the index pattern to set it as the default pattern.
Is there a way to set an index pattern as default pattern using the Kibana API?
Hi, can you share an example of an object that was retrieved with Get Object API, but can't be imported with the Create Object API? I agree that the output of get should be compatible with create.
It is not possible to set an index pattern as "default" through the saved object API, because that state is stored as a Kibana Advanced Setting (defaultIndex). That setting might be able to be updated through updating the corresponding .kibana doc, however.
{
"id": "my-pattern",
"type": "index-pattern",
"updated_at": "2019-02-12T15:23:06.871Z",
"version": 6,
"attributes": {
"title": "dummy-*",
"timeFieldName": "@timestamp",
"fields": lots of field definitions goes here
}
}
I try to reimport the JSON: curl --silent -XPUT "http://localhost:5601/api/saved_objects/index-pattern/my-pattern" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d @my-pattern.json
I get the following response (reformated, because unfortunately there is no ?pretty (yet?))
{
"statusCode": 400,
"error": "Bad Request",
"message": "\"id\" is not allowed. \"type\" is not allowed. \"updated_at\" is not allowed. \"version\" is not allowed",
"validation": {
"source": "payload",
"keys": [
"id",
"type",
"updated_at",
"version"
]
}
}
I have to adjust the json file like this:
{
"attributes": {
"title": "dummy-*",
"timeFieldName": "@timestamp",
"fields": lots of field definitions goes here
}
}
{
"id": "my-pattern",
"type": "index-pattern",
"updated_at": "2019-02-27T15:03:36.691Z",
"version": 7,
"attributes": {
"title": "dummy-*",
"timeFieldName": "@timestamp",
"fields": lots of field definitions goes here
}
}
Same goes for creating new patterns, same errors. I don't say this is wrong, because even the documentation says it is working as I described it.
It's just pain to me and I wanted to ask if
a) I'm doing something wrong (maybe using wrong API to fetch the objects in the first place?) and/or
b) we can expect changes on this in the (near - 7.0?) future?
Regarding to the default index. You wrote
It is not possible to set an index pattern as "default" through the saved object API, because that state is stored as a Kibana Advanced Setting ( defaultIndex ). That setting might be able to be updated through updating the corresponding .kibana doc, however.
Thank you for the heads up. I do it like this now:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.