Create saved_objects API does not import time attributes

When I create a saved_object (dashboard) using the API, the 4 time attributes (timeRestore, timeTo, timeFrom, refreshInterval) are not created. But if I import the exact same object using the Saved Objects page of the Kibana UI, they are created. Here is the dashboard object:
[ { "_id": "metricbeat-system-host-overview", "_type": "dashboard", "_source": { "title": "[Metricbeat System] Host overview", "hits": 0, "description": "Overview of host metrics", "panelsJSON": "[<omitted>]", "optionsJSON": "{\"darkTheme\":false}", "version": 1, "timeRestore": true, "timeTo": "now", "timeFrom": "now-15m", "refreshInterval": { "pause": false, "value": 10000 }, "kibanaSavedObjectMeta": { "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"version\":true,\"highlightAll\":true}" } }, "_migrationVersion": { "dashboard": "7.0.0" }, "_references": [<omitted>] } ]

Here is the API curl command, which is issued through shellExec() in my app:

curl -f -k -X POST -H 'kbn-xsrf:true' -H 'Content-type:application/json' -d '{ "attributes": ${JSON.stringify(item._source)}, "references": ${JSON.stringify(item._references)} }' "${KIBANA_ADDRESS}/api/saved_objects/${item._type}/${item._id}?overwrite=true"

Everything is created nicely except nothing for those 4 time attributes. Am I doing something wrong, or is this a Kibana bug?

I am using the grafana/grafana docker (and the elasticsearch docker) v7.1.0.

Hey @Lannie_Rose,

I ran the following commands against my 7.1 installation, but I wasn't able to reproduce. The time attributes were saved along with the rest of the dashboard.

curl -XPOST http://localhost:5601/api/saved_objects/dashboard/test-object -H "kbn-xsrf: true" -H "content-type: application/json" -d '{"references": [], "attributes": {"title": "[Metricbeat System] Host overview", "hits": 0, "description": "Overview of host metrics", "panelsJSON": "[]", "optionsJSON": "{\"darkTheme\":false}", "version": 1, "timeRestore": true, "timeTo": "now", "timeFrom": "now-15m", "refreshInterval": { "pause": false, "value": 10000 }, "kibanaSavedObjectMeta": { "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"version\":true,\"highlightAll\":true}" }} }'
curl http://localhost:5601/api/saved_objects/dashboard/test-object -H "kbn-xsrf: true" -H "content-type: application/json"

{
  "id": "test-object",
  "type": "dashboard",
  "updated_at": "2019-05-29T10:40:08.451Z",
  "version": "WzQsMV0=",
  "attributes": {
    "title": "[Metricbeat System] Host overview",
    "hits": 0,
    "description": "Overview of host metrics",
    "panelsJSON": "[]",
    "optionsJSON": "{\"darkTheme\":false}",
    "version": 1,
    "timeRestore": true,
    "timeTo": "now",
    "timeFrom": "now-15m",
    "refreshInterval": {
      "pause": false,
      "value": 10000
    },
    "kibanaSavedObjectMeta": {
      "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"version\":true,\"highlightAll\":true}"
    }
  },
  "references": [],
  "migrationVersion": {
    "dashboard": "7.0.0"
  }
}

Looking at the underlying code that powers the API, I'm not seeing anything in there that would conditionally alter your input either.

1 Like

Hey thanks. Today mine is working, for some reason, though i didn't change anything as far as I can tell. I must have missed a build step somewhere. Sorry for the false alarum.

Those are the worst kinds of problems! No worries, we're here to help

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