Class: LogStash::Modules::KibanaConfig

Inherits:
Object
  • Object
show all
Includes:
Util::Loggable
Defined in:
lib/logstash/modules/kibana_config.rb

Constant Summary collapse

ALLOWED_DIRECTORIES =
["search", "visualization"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(modul, settings) ⇒ KibanaConfig

We name it ‘modul` here because `module` has meaning in Ruby.



14
15
16
17
18
19
20
21
22
23
# File 'lib/logstash/modules/kibana_config.rb', line 14

def initialize(modul, settings)
  build_versioned_directory(modul)
  @name = modul.module_name
  @settings = settings
  @index_name = "kibana"
  @pattern_name = "#{@name}-*"
  @kibana_settings = [
    KibanaSettings::Setting.new("defaultIndex", @pattern_name)
  ]
end

Instance Attribute Details

#index_nameObject (readonly)

not used when importing via kibana but for BWC with ElastsearchConfig



11
12
13
# File 'lib/logstash/modules/kibana_config.rb', line 11

def index_name
  @index_name
end

Instance Method Details

#dashboardsObject



25
26
27
28
29
30
31
# File 'lib/logstash/modules/kibana_config.rb', line 25

def dashboards
  # there can be more than one dashboard to load
  filenames = FileReader.read_json(dynamic("dashboard"))
  filenames.map do |filename|
    KibanaResource.new(@index_name, "dashboard", dynamic("dashboard", filename))
  end
end

#index_patternObject



33
34
35
# File 'lib/logstash/modules/kibana_config.rb', line 33

def index_pattern
  [KibanaResource.new(@index_name, "index-pattern", dynamic("index-pattern"),nil, @pattern_name)]
end

#resourcesObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/logstash/modules/kibana_config.rb', line 37

def resources
  list = index_pattern
  dashboards.each do |board|
    list << board
    extract_panels_into(board, list)
  end
  list.concat(extract_saved_searches_into(list))
  [
    KibanaSettings.new("api/kibana/settings", @kibana_settings),
    KibanaDashboards.new("api/kibana/dashboards/import", list)
  ]
end