class Fluent::KibanaServerInput

Constants

CONFIG_JS_PATH
PATH_TO_KIBANA

Public Instance Methods

shutdown() click to toggle source
# File lib/fluent/plugin/in_kibana_server.rb, line 35
def shutdown
  if @srv
    @srv.shutdown
    @srv = nil
  end

  if @access_log and (not @access_log.closed?)
    @access_log.close
  end

  if @thread
    @thread.join
    @thread = nil
  end
end
start() click to toggle source
# File lib/fluent/plugin/in_kibana_server.rb, line 16
def start
  $log.info "listening http server for kinaba on http://#{@bind}:#{@port}#{@mount}"

  @access_log = File.open(@access_log_path, 'a') if @access_log_path

  File.open(CONFIG_JS_PATH, 'w') {|f| f.write(kibana_config)}

  @srv = WEBrick::HTTPServer.new({
      :BindAddress => @bind,
      :Port => @port,
      :Logger => WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
      :AccessLog => @access_log ? [[@access_log, WEBrick::AccessLog::CLF]] : [],
    })

  @srv.mount(@mount, WEBrick::HTTPServlet::FileHandler, PATH_TO_KIBANA)

  @thread = Thread.new { @srv.start }
end

Private Instance Methods

kibana_config() click to toggle source
# File lib/fluent/plugin/in_kibana_server.rb, line 53
    def kibana_config
      elasticsearch = if @elasticsearch_url
                        %Q{"#{@elasticsearch_url}"}
                      else
                        %Q{"http://"+window.location.hostname+":9200"}
                      end
      <<-CONFIG
/**
 * These is the app's configuration, If you need to configure
 * the default dashboard, please see dashboards/default
 */
define(['settings'],
function (Settings) {
  

  return new Settings({

    /**
     * URL to your elasticsearch server. You almost certainly don't
     * want 'http://localhost:9200' here. Even if Kibana and ES are on
     * the same host
     *
     * By default this will attempt to reach ES at the same host you have
     * elasticsearch installed on. You probably want to set it to the FQDN of your
     * elasticsearch host
     * @type {String}
     */
    elasticsearch: #{elasticsearch},

    /**
     * The default ES index to use for storing Kibana specific object
     * such as stored dashboards
     * @type {String}
     */
    kibana_index: "kibana-int",

    /**
     * Panel modules available. Panels will only be loaded when they are defined in the
     * dashboard, but this list is used in the "add panel" interface.
     * @type {Array}
     */
    panel_names: [
      'histogram',
      'map',
      'pie',
      'table',
      'filtering',
      'timepicker',
      'text',
      'fields',
      'hits',
      'dashcontrol',
      'column',
      'derivequeries',
      'trends',
      'bettermap',
      'query',
      'terms'
    ]
  });
});
      CONFIG
    end