Sha256: 5a7e98a55e9183f57b41a0e9cd75be58873554ead8c5eef85501bc22f08c05c2

Contents?: true

Size: 1.01 KB

Versions: 19

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8
require "logstash/namespace"
require "logstash/logging"
require_relative "kibana_base"

module LogStash module Modules class KibanaDashboards < KibanaBase
  include LogStash::Util::Loggable

  attr_reader :import_path, :content

  # content is a list of kibana file resources
  def initialize(import_path, content)
    @import_path, @content = import_path, content
  end

  def import(client)
    # e.g. curl "http://localhost:5601/api/kibana/dashboards/import"
    # extract and prepare all objects
    objects = []
    content.each do |resource|
      hash = {
        "id" => resource.content_id,
        "type" => resource.content_type,
        "version" => 1,
        "attributes" => resource.content_as_object
      }
      objects << hash
    end
    body = {"version": client.version, "objects": objects}
    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_dashboards.rb
logstash-core-6.3.1-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.3.0-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.2.4-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.2.3-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.1.4-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.2.2-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.2.1-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.2.0-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.1.3-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.1.2-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.1.1-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.1.0-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.0.1-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.0.0-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.0.0.rc2-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.0.0.rc1-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.0.0.beta2-java lib/logstash/modules/kibana_dashboards.rb
logstash-core-6.0.0.beta1-java lib/logstash/modules/kibana_dashboards.rb