Kibana Plugin persist config

I'm making a Kibana plugin, and I want to use the config built into Kibana instead of trying to handle things downstream in my plugin. My intention is to be able to set a few variables, and have them persist across reboots, and across clustered kibana instances. Here's how I'm doing it.

// myPlugin's index.js
  return new kibana.Plugin({
// skipping for brevity
    config(Joi) {
      return Joi.object({
        enabled: Joi.boolean().default(true),
        gcpStorageKey: Joi.string().optional(),
      }).default();
    },
// skipping more
}

Later, I'm setting my config by doing:

const setKey = (key: string): void => {
  const conf = server.config(); // *server* defined elsewhere in file
  conf.set('myPlugin.gcpStorageKey', key);
}

Later later, reading it with:

const init = (): void => {
  const conf = server.config();
  const key =  conf.get('myPlugin.gcpStorageKey'); // <- works just fine, unless I restart kibana
  // ... using the key
}

Is the server.config() supposed to persist changes to the config? Is this only happening because I'm using the development server, and not the permanent one?

Thanks for the help.

Hi @McKittrick_Kaminski,

Calling config.set will override the configuration setting at runtime, but it will not persist those settings across reboots.

Each time Kibana starts, the bootstrap process will read the settings out of the config/kibana.yml file and override them with any settings explicitly provided as CLI args when starting the Kibana server.

Subsequent calls to config.set only persist the changes in memory until the next time the server is started.

To ensure the value is always set, you'll need to include the myPlugin.gcpStorageKey: abc123 in your kibana.yml for each of those instances, or alternatively provide them via the CLI when starting Kibana, --myPlugin.gcpStorageKey=abc123.

Thanks,

Luke

Thanks! That clears up a lot!

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