Sha256: 5584709da9d93dc07d1ca250bdd3e1acb1832992492d0eaa0a31cb5a863fd14f
Contents?: true
Size: 1.22 KB
Versions: 59
Compression:
Stored size: 1.22 KB
Contents
# encoding: utf-8 require_relative "kibana_base" module LogStash module Modules class KibanaSettings < KibanaBase include LogStash::Util::Loggable class Setting attr_reader :name, :value def initialize(name, value) @name, @value = name, value end end attr_reader :import_path, :content # content is an array of Setting required for this module def initialize(import_path, content) @import_path, @content = import_path, content end def import(client) # e.g. curl "http://localhost:5601/api/kibana/settings" # 6.0.0-beta1 -> {"settings":{"buildNum":{"userValue":15613},"defaultIndex":{"userValue":"arcsight-*"}}} # 5.4 -> {"settings":{"defaultIndex":{"userValue":"cef-*"},"metrics:max_buckets":{"userValue":"600000"}}} # array of Setting objects # The POST api body { "changes": { "defaultIndex": "arcsight-*", "metrics:max_buckets": "400" } } settings = {} content.each do |setting| settings[setting.name] = "#{setting.value}" end body = {"changes" => settings} response = client.post(import_path, body) if response.failed? logger.error("Attempted POST failed", :url_path => import_path, :response => response.body) end response end end end end
Version data entries
59 entries across 59 versions & 1 rubygems