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