Sha256: 2e30184699b53b389cc734ee5c71f7a553d1c9b77b67fab867eecbed1612a979

Contents?: true

Size: 1.28 KB

Versions: 19

Compression:

Stored size: 1.28 KB

Contents

# encoding: utf-8
require "logstash/namespace"
require "logstash/logging"
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

19 entries across 19 versions & 1 rubygems

Version Path
logstash-core-6.3.2-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.3.1-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.3.0-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.2.4-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.2.3-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.1.4-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.2.2-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.2.1-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.2.0-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.1.3-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.1.2-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.1.1-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.1.0-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.0.1-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.0.0-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.0.0.rc2-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.0.0.rc1-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.0.0.beta2-java lib/logstash/modules/kibana_settings.rb
logstash-core-6.0.0.beta1-java lib/logstash/modules/kibana_settings.rb