REST API to access/update Advanced Settings

I am currently using Kibana version 7.4.2 Saved Objects REST API (see here) to programmatically customize some Kibana Advanced Settings.

In particular, I am customizing the dateFormat:tz setting to choose the timezone Kibana uses to localize data, as the default value Browser is not appropriate for our use case.

The problem is that if I try to set an invalid value like INVALID_TIMEZONE_NAME, I don't get any error, and I can't find a way to programmatically check if the setting was correctly applied.

In particular, if I do the following:

PUT /api/saved_objects/config/7.4.2
{
  "attributes": {
    "dateFormat:tz": "INVALID_TIMEZONE_NAME"
  }
}

I get the following VALID answer (http status 200):

{
  "id":"7.4.2",
  "type":"config",
  "updated_at":"2020-02-21T12:01:34.908Z",
  "version":"WzkzMSwxXQ==",
  "attributes": {
    "dateFormat:tz": "INVALID_TIMEZONE_NAME"
  }
}

If I check the Advanced Settings from the Kibana GUI, I see that the timezone has been set to the default value of Browser. But if I call GET api/saved_objects/config/7.4.2, I get the following result:

{
  "id":"7.4.2",
  "type":"config",
  "updated_at":"2020-02-21T12:01:34.908Z",
  "version":"WzkzMSwxXQ==",
  "attributes": {
    "buildNum": 26506,
    "dateFormat:tz": "INVALID_TIMEZONE_NAME"
  },
  "references":[]
}

To summarize, the problems are:

  • I don't get an error if I try to set an invalid value for dateFormat:tz (I would expect an http status of 400), so it looks like there's no validation of the passed timezone value
  • I cannot cross-check the value I passed with the current value, as the REST API still returns the incorrect value, while the Kibana GUI shows the default value Browser

Is there any way to validate the value I passed to Kibana?

Hi, this sounds like a bug in Kibana. I would guess the GUI shows Browser as the selected option because it can't select the value in the data so it defaults to Browser.

Would you be willing to file an issue about this bug? https://github.com/elastic/kibana/issues/new/choose

Hi @tsullivan, thanks for the quick answer.

I just filed a bug about this, see Missing validation for "dateFormat:tz" setting via Saved Objects REST API · Issue #58437 · elastic/kibana · GitHub

1 Like

Hello again @tsullivan, sorry to come back on this, but I got an idea while working on the feature in my project.

Right now Kibana offers basically 2 choices for the dateFormat:tz setting: either the client (i.e. Browser) time zone, or a specific time zone chosen from an explicit list (e.g. America/New_York).

Why not add also the Server choice? The Kibana server is surely running in an environment with a configured time zone, be it a virtual machine, a bare metal machine, or a Docker container; if I could choose to localize data in the server time zone, I could just configure the server time zone accordingly (as I already do for other components of my project), and the data would be localized in THAT time zone. If that changes, I would not have to change the Kibana setting, as it would already be set to Server.

Do you think this might make sense as a feature request? It would make sense in my use case, but do you think it might be useful also to others?

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