mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 19:06:12 +02:00
Add out_elasticsearch setting
This commit is contained in:
parent
6551280ba0
commit
242e23732c
@ -0,0 +1,22 @@
|
||||
class Fluentd::Settings::OutElasticsearchController < ApplicationController
|
||||
include SettingConcern
|
||||
|
||||
private
|
||||
|
||||
def target_class
|
||||
Fluentd::Setting::OutElasticsearch
|
||||
end
|
||||
|
||||
def initial_params
|
||||
{
|
||||
host: "127.0.0.1",
|
||||
port: 9200,
|
||||
index_name: "via_fluentd",
|
||||
type_name: "via_fluentd",
|
||||
logstash_format: true,
|
||||
include_tag_key: false,
|
||||
tag_key: "tag",
|
||||
utc_index: true,
|
||||
}
|
||||
end
|
||||
end
|
||||
24
app/models/fluentd/setting/out_elasticsearch.rb
Normal file
24
app/models/fluentd/setting/out_elasticsearch.rb
Normal file
@ -0,0 +1,24 @@
|
||||
class Fluentd
|
||||
module Setting
|
||||
class OutElasticsearch
|
||||
include Common
|
||||
|
||||
KEYS = [
|
||||
:match,
|
||||
:host, :port, :index_name, :type_name,
|
||||
:logstash_format, :logstash_prefix, :logstash_dateformat, :utc_index,
|
||||
:hosts, :request_timeout, :include_tag_key, :tag_key
|
||||
].freeze
|
||||
|
||||
attr_accessor(*KEYS)
|
||||
|
||||
booleans :logstash_format, :utc_index, :include_tag_key
|
||||
|
||||
validates :match, presence: true
|
||||
validates :host, presence: true
|
||||
validates :port, presence: true
|
||||
validates :index_name, presence: true
|
||||
validates :type_name, presence: true
|
||||
end
|
||||
end
|
||||
end
|
||||
25
app/views/fluentd/settings/out_elasticsearch/_form.html.haml
Normal file
25
app/views/fluentd/settings/out_elasticsearch/_form.html.haml
Normal file
@ -0,0 +1,25 @@
|
||||
= render "shared/setting_errors"
|
||||
|
||||
= form_for(@setting, url: finish_daemon_setting_out_elasticsearch_path(@fluentd), html: {class: "ignore-rails-error-div"}) do |f|
|
||||
= field(f, :match)
|
||||
= field(f, :host)
|
||||
= field(f, :port)
|
||||
= field(f, :logstash_format)
|
||||
= field(f, :index_name)
|
||||
= field(f, :type_name)
|
||||
|
||||
.well.well-sm
|
||||
%h4{"data-toggle" => "collapse", "href" => "#advanced-setting"}
|
||||
= icon('fa-caret-down')
|
||||
= t('terms.advanced_setting')
|
||||
#advanced-setting.collapse
|
||||
= field(f, :hosts)
|
||||
= field(f, :logstash_prefix)
|
||||
= field(f, :logstash_dateformat)
|
||||
= field(f, :utc_index)
|
||||
= field(f, :request_timeout)
|
||||
= field(f, :include_tag_key)
|
||||
= field(f, :tag_key)
|
||||
= field(f, :tag_key)
|
||||
= f.submit t('fluentd.common.finish'), class: "btn btn-lg btn-primary pull-right"
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
- page_title t(".page_title")
|
||||
|
||||
.well
|
||||
= raw t('fluentd.settings.out_elasticsearch.option_guide')
|
||||
|
||||
= render "form"
|
||||
@ -39,6 +39,10 @@
|
||||
= link_to(daemon_setting_out_mongo_path(@fluentd)) do
|
||||
= icon('fa-file-text-o fa-lg')
|
||||
= t("fluentd.common.setup_out_mongo")
|
||||
%p
|
||||
= link_to(daemon_setting_out_elasticsearch_path(@fluentd)) do
|
||||
= icon('fa-file-text-o fa-lg')
|
||||
= t("fluentd.common.setup_out_elasticsearch")
|
||||
%p
|
||||
= link_to(daemon_setting_out_forward_path(@fluentd)) do
|
||||
= icon('fa-file-text-o fa-lg')
|
||||
|
||||
@ -97,6 +97,7 @@ en:
|
||||
setup_out_mongo: MongoDB
|
||||
setup_out_forward: Forwarding
|
||||
setup_out_s3: Amazon S3
|
||||
setup_out_elasticsearch: Elasticsearch
|
||||
finish: Update & Restart
|
||||
fluentd_info: Setting info
|
||||
recent_errors: "Errors within recent %{days} days"
|
||||
@ -144,6 +145,11 @@ en:
|
||||
For each config parameter, pelase refer to the <a href="http://docs.fluentd.org/articles/out_td" target="_blank">Treasure Data output plugin</a> documentation page.
|
||||
show:
|
||||
page_title: Add Output to Treasure Data
|
||||
out_elasticsearch:
|
||||
option_guide: |
|
||||
For each config parameter, pelase refer to the <a target="_blank" href="https://github.com/uken/fluent-plugin-elasticsearch">Elasticsearch output plugin</a> documentation page.
|
||||
show:
|
||||
page_title: Add Output to Elasticsearch
|
||||
out_mongo:
|
||||
option_guide: |
|
||||
For each config parameter, pelase refer to the <a href="http://docs.fluentd.org/articles/out_mongo" target="_blank">MongoDB output plugin</a> documentation page.
|
||||
|
||||
@ -96,6 +96,7 @@ ja:
|
||||
setup_out_mongo: MongoDB
|
||||
setup_out_forward: 転送
|
||||
setup_out_s3: AWS S3
|
||||
setup_out_elasticsearch: Elasticsearch
|
||||
finish: 設定する
|
||||
fluentd_info: 設定情報
|
||||
recent_errors: "直近 %{days} 日内のエラー"
|
||||
@ -143,6 +144,12 @@ ja:
|
||||
fluent-plugin-tdプラグインのインストールが必要です。<br />
|
||||
show:
|
||||
page_title: Treasure Data書き出し設定
|
||||
out_elasticsearch:
|
||||
option_guide: |
|
||||
fluent-plugin-elasticsearchプラグインのインストールが必要です。<br />
|
||||
<a target="_blank" href="https://github.com/uken/fluent-plugin-elasticsearch">out_elasticsearchプラグインの解説</a>もご参照ください。
|
||||
show:
|
||||
page_title: Elasticsearch設定
|
||||
out_mongo:
|
||||
option_guide: |
|
||||
fluent-plugin-mongoプラグインのインストールが必要です。<br />
|
||||
|
||||
@ -43,6 +43,10 @@ Rails.application.routes.draw do
|
||||
resource :out_forward, only: [:show], module: :settings, controller: :out_forward do
|
||||
post "finish"
|
||||
end
|
||||
|
||||
resource :out_elasticsearch, only: [:show], module: :settings, controller: :out_elasticsearch do
|
||||
post "finish"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
38
spec/features/fluentd/setting/out_elasticsearch_spec.rb
Normal file
38
spec/features/fluentd/setting/out_elasticsearch_spec.rb
Normal file
@ -0,0 +1,38 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "out_elasticsearch" do
|
||||
let(:exists_user) { build(:user) }
|
||||
let(:daemon) { build(:fluentd, variant: "td-agent") }
|
||||
let(:match) { "test.out_elasticsearch.#{Time.now.to_i}.*" }
|
||||
let(:location) { daemon_setting_out_elasticsearch_path }
|
||||
|
||||
before do
|
||||
Fluentd.stub(:instance).and_return(daemon)
|
||||
Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
|
||||
daemon.agent.config_write ""
|
||||
|
||||
visit '/sessions/new'
|
||||
within("form") do
|
||||
fill_in 'session_name', :with => exists_user.name
|
||||
fill_in 'session_password', :with => exists_user.password
|
||||
end
|
||||
click_button I18n.t("terms.sign_in")
|
||||
end
|
||||
|
||||
it "Shown form" do
|
||||
visit location
|
||||
page.should have_css('input[name="fluentd_setting_out_elasticsearch[match]"]')
|
||||
end
|
||||
|
||||
it "Updated config after submit", js: true do
|
||||
daemon.agent.config.should_not include(match)
|
||||
visit location
|
||||
within('#new_fluentd_setting_out_elasticsearch') do
|
||||
fill_in "Match", with: match
|
||||
fill_in "Index name", with: "index"
|
||||
fill_in "Type name", with: "type_name"
|
||||
end
|
||||
click_button I18n.t("fluentd.common.finish")
|
||||
daemon.agent.config.should include(match)
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user