fluentd-ui 1.0.0.alpha.2 → 1.0.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd-ui might be problematic. Click here for more details.

Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +5 -0
  3. data/Gemfile.lock +56 -1
  4. data/README.md +2 -2
  5. data/app/controllers/api/config_definitions_controller.rb +55 -0
  6. data/app/controllers/api_controller.rb +20 -3
  7. data/app/controllers/concerns/setting_concern.rb +18 -2
  8. data/app/controllers/fluentd/settings/in_tail_controller.rb +13 -5
  9. data/app/controllers/fluentd/settings/out_forward_controller.rb +0 -9
  10. data/app/controllers/fluentd/settings/out_s3_controller.rb +0 -5
  11. data/app/controllers/fluentd/settings/out_tdlog_controller.rb +9 -0
  12. data/app/form_builders/fluentd_form_builder.rb +83 -0
  13. data/app/helpers/settings_helper.rb +81 -18
  14. data/app/javascript/packs/application.js +4 -0
  15. data/app/javascript/packs/in_tail_parse.js +159 -0
  16. data/app/javascript/packs/owned_plugin_form.js +141 -0
  17. data/app/javascript/packs/parser_multiline_form.js +51 -0
  18. data/app/javascript/packs/plugin_setting.js +19 -0
  19. data/app/models/concerns/fluentd/setting/configurable.rb +113 -0
  20. data/app/models/concerns/fluentd/setting/pattern.rb +11 -0
  21. data/app/models/concerns/fluentd/setting/plugin.rb +78 -0
  22. data/app/models/concerns/fluentd/setting/plugin_config.rb +74 -0
  23. data/app/models/concerns/fluentd/setting/plugin_parameter.rb +121 -0
  24. data/app/models/concerns/fluentd/setting/section_parser.rb +36 -0
  25. data/app/models/concerns/fluentd/setting/section_validator.rb +21 -0
  26. data/app/models/fluentd.rb +5 -5
  27. data/app/models/fluentd/setting/buffer_file.rb +23 -0
  28. data/app/models/fluentd/setting/buffer_memory.rb +17 -0
  29. data/app/models/fluentd/setting/formatter_csv.rb +21 -0
  30. data/app/models/fluentd/setting/formatter_hash.rb +19 -0
  31. data/app/models/fluentd/setting/formatter_json.rb +25 -0
  32. data/app/models/fluentd/setting/formatter_ltsv.rb +21 -0
  33. data/app/models/fluentd/setting/formatter_msgpack.rb +13 -0
  34. data/app/models/fluentd/setting/formatter_out_file.rb +21 -0
  35. data/app/models/fluentd/setting/formatter_single_value.rb +20 -0
  36. data/app/models/fluentd/setting/formatter_stdout.rb +19 -0
  37. data/app/models/fluentd/setting/formatter_tsv.rb +21 -0
  38. data/app/models/fluentd/setting/in_forward.rb +7 -17
  39. data/app/models/fluentd/setting/in_http.rb +13 -19
  40. data/app/models/fluentd/setting/in_monitor_agent.rb +6 -19
  41. data/app/models/fluentd/setting/in_syslog.rb +14 -12
  42. data/app/models/fluentd/setting/in_tail.rb +7 -84
  43. data/app/models/fluentd/setting/out_elasticsearch.rb +12 -21
  44. data/app/models/fluentd/setting/out_forward.rb +22 -66
  45. data/app/models/fluentd/setting/out_mongo.rb +20 -26
  46. data/app/models/fluentd/setting/out_s3.rb +18 -30
  47. data/app/models/fluentd/setting/out_stdout.rb +21 -18
  48. data/app/models/fluentd/setting/out_tdlog.rb +35 -0
  49. data/app/models/fluentd/setting/parser_apache.rb +13 -0
  50. data/app/models/fluentd/setting/parser_apache2.rb +13 -0
  51. data/app/models/fluentd/setting/parser_apache_error.rb +13 -0
  52. data/app/models/fluentd/setting/parser_csv.rb +22 -0
  53. data/app/models/fluentd/setting/parser_in_http.rb +13 -0
  54. data/app/models/fluentd/setting/parser_json.rb +25 -0
  55. data/app/models/fluentd/setting/parser_ltsv.rb +30 -0
  56. data/app/models/fluentd/setting/parser_msgpack.rb +13 -0
  57. data/app/models/fluentd/setting/parser_multiline.rb +24 -0
  58. data/app/models/fluentd/setting/parser_nginx.rb +13 -0
  59. data/app/models/fluentd/setting/parser_none.rb +19 -0
  60. data/app/models/fluentd/setting/parser_regexp.rb +26 -0
  61. data/app/models/fluentd/setting/parser_syslog.rb +29 -0
  62. data/app/models/fluentd/setting/parser_tsv.rb +19 -0
  63. data/app/models/fluentd/setting/section.rb +38 -0
  64. data/app/models/fluentd/setting/storage_local.rb +22 -0
  65. data/app/models/fluentd/setting/type/array.rb +17 -0
  66. data/app/models/fluentd/setting/type/bool.rb +18 -0
  67. data/app/models/fluentd/setting/type/enum.rb +17 -0
  68. data/app/models/fluentd/setting/type/hash.rb +17 -0
  69. data/app/models/fluentd/setting/type/regexp.rb +17 -0
  70. data/app/models/fluentd/setting/type/section.rb +17 -0
  71. data/app/models/fluentd/setting/type/size.rb +17 -0
  72. data/app/models/fluentd/setting/type/time.rb +17 -0
  73. data/app/views/api/settings/_element.json.jbuilder +1 -1
  74. data/app/views/fluentd/settings/in_forward/_form.html.haml +16 -0
  75. data/app/views/fluentd/settings/in_tail/_form.html.haml +22 -29
  76. data/app/views/fluentd/settings/in_tail/after_file_choose.html.haml +1 -1
  77. data/app/views/fluentd/settings/in_tail/after_format.html.haml +4 -4
  78. data/app/views/fluentd/settings/in_tail/confirm.html.haml +5 -5
  79. data/app/views/fluentd/settings/source_and_output.html.haml +1 -1
  80. data/app/views/shared/_global_nav.html.erb +8 -8
  81. data/app/views/shared/settings/_form.html.haml +40 -9
  82. data/app/views/shared/settings/show.html.haml +4 -1
  83. data/app/views/shared/vue/_in_tail_parse.html.haml +20 -0
  84. data/app/views/shared/vue/_owned_plugin_form.html.haml +68 -0
  85. data/app/views/shared/vue/_parser_multiline_form.html.haml +19 -0
  86. data/app/views/shared/vue/_setting.html.erb +1 -1
  87. data/config/application.rb +1 -1
  88. data/config/environment.rb +3 -0
  89. data/config/initializers/types.rb +7 -0
  90. data/config/routes.rb +2 -1
  91. data/fluentd-ui.gemspec +5 -0
  92. data/lib/fluentd-ui/version.rb +1 -1
  93. data/lib/regexp_preview.rb +2 -2
  94. data/lib/regexp_preview/multi_line.rb +53 -63
  95. data/lib/regexp_preview/single_line.rb +40 -46
  96. data/spec/features/fluentd/setting/out_forward_spec.rb +1 -1
  97. data/spec/features/fluentd/setting/out_stdout_spec.rb +1 -1
  98. data/spec/features/{out_td_spec.rb → out_tdlog_spec.rb} +3 -3
  99. data/spec/lib/regexp_preview/multi_line_spec.rb +29 -34
  100. data/spec/lib/regexp_preview/single_line_spec.rb +89 -87
  101. data/spec/models/fluentd/setting/in_forward_spec.rb +75 -0
  102. data/spec/models/fluentd/setting/in_http_spec.rb +31 -0
  103. data/spec/models/fluentd/setting/in_monitor_agent_spec.rb +31 -0
  104. data/spec/models/fluentd/setting/in_syslog_spec.rb +65 -7
  105. data/spec/models/fluentd/setting/in_tail_spec.rb +47 -0
  106. data/spec/models/fluentd/setting/out_elasticsearch_spec.rb +31 -0
  107. data/spec/models/fluentd/setting/out_mongo_spec.rb +35 -12
  108. data/spec/models/fluentd/setting/out_s3_spec.rb +128 -0
  109. data/spec/models/fluentd/setting/out_stdout_spec.rb +31 -0
  110. data/spec/models/fluentd/setting/out_tdlog_spec.rb +47 -0
  111. metadata +164 -38
  112. data/app/controllers/fluentd/settings/out_td_controller.rb +0 -18
  113. data/app/helpers/fluentd/settings_helper.rb +0 -2
  114. data/app/javascript/packs/in_tail_format.js +0 -174
  115. data/app/models/fluentd/setting/common.rb +0 -185
  116. data/app/models/fluentd/setting/out_td.rb +0 -48
  117. data/app/views/shared/vue/_in_tail_format.html.erb +0 -43
  118. data/spec/models/fluentd/setting/common_spec.rb +0 -178
  119. data/spec/models/fluentd/setting/out_td_spec.rb +0 -38
@@ -1,18 +0,0 @@
1
- class Fluentd::Settings::OutTdController < ApplicationController
2
- include SettingConcern
3
-
4
- private
5
-
6
- def target_class
7
- Fluentd::Setting::OutTd
8
- end
9
-
10
- def initial_params
11
- {
12
- buffer_type: "file",
13
- buffer_path: "/var/log/td-agent/buffer/td",
14
- auto_create_table: true,
15
- match: "td.*.*",
16
- }
17
- end
18
- end
@@ -1,2 +0,0 @@
1
- module Fluentd::SettingsHelper
2
- end
@@ -1,174 +0,0 @@
1
- 'use strict'
2
- import 'lodash/lodash'
3
-
4
- window.addEventListener('load', () => {
5
- const maxFormatCount = 20;
6
-
7
- new Vue({
8
- el: "#in_tail_format",
9
- props: ["formatOptionsJson", "initialSelected", "targetFile", "paramsJson"],
10
- data: {
11
- previewProcessing: false,
12
- format: "",
13
- highlightedLines: null,
14
- },
15
-
16
- computed: {
17
- options: {
18
- get: function(){
19
- return this.formatOptions[this.format];
20
- },
21
- },
22
- selectableFormats: {
23
- get: function() {
24
- return Object.keys(this.formatOptions);
25
- }
26
- },
27
- useTextArea: function() {
28
- return this.format === "multiline";
29
- }
30
- },
31
-
32
- beforeMount: function() {
33
- this.formatOptions = JSON.parse(this.$el.attributes.formatOptionsJson.nodeValue);
34
- this.format = this.$el.attributes.initialSelected.nodeValue;
35
-
36
- // initialize params
37
- // NOTE: if `params.setting.foo` is undefined, Vue can't binding with v-model="params.setting.foo"
38
- var params = JSON.parse(this.$el.attributes.paramsJson.nodeValue);
39
- if(!params.setting) {
40
- params.setting = {};
41
- }
42
-
43
- var formats = _.chain(_.range(1, maxFormatCount + 1)).map(function(i) {return params.setting["format" + String(i)];}).compact().value();
44
- params.setting.formats = formats.join("\n");
45
-
46
- _.each(this.formatOptions, function(options){
47
- _.each(options, function(key){
48
- if(!params.setting.hasOwnProperty(key)){
49
- params.setting[key] = "";
50
- }
51
- });
52
- });
53
- this.params = params;
54
-
55
- this.targetFile = this.$el.attributes.targetFile.nodeValue;
56
- },
57
- mounted: function(){
58
- this.$emit("data-loaded");
59
- },
60
-
61
- watch: {
62
- 'params.setting.formats': function(formats) {
63
- _.range(1, maxFormatCount + 1).forEach(()=> {params.setting["format" + String(i)] = "";});
64
-
65
- _.compact(formats.split("\n")).forEach((formatLine, index)=> {
66
- params.setting["format" + String(index + 1)] = formatLine;
67
- })
68
- },
69
- 'params.setting.regexp': function() {
70
- this.preview();
71
- },
72
- 'format': function() {
73
- this.preview();
74
- },
75
- },
76
-
77
- methods: {
78
- onKeyup: function(ev){
79
- var el = ev.target;
80
- if(el.name.match(/\[format/)){
81
- this.preview();
82
- }
83
- },
84
- updateHighlightedLines: function() {
85
- if(!this.regexpMatches) {
86
- this.highlightedLines = null;
87
- return;
88
- }
89
-
90
- var $container = jQuery('<div>');
91
- _.each(this.regexpMatches, function(match){
92
- var colors = [
93
- "#ff9", "#cff", "#fcf", "#dfd"
94
- ];
95
- var whole = match.whole;
96
- var html = "";
97
- var matches = [];
98
-
99
- var lastPos = 0;
100
- _.each(match.matches, function(match) {
101
- var matched = match.matched;
102
- if(!matched) return;
103
- if(matched.length === 0) return; // Ignore empty matched with "foobar".match(/foo(.*?)bar/)[1] #=> ""
104
-
105
- // rotated highlight color
106
- var currentColor = colors.shift();
107
- colors.push(currentColor);
108
-
109
- // create highlighted range HTML
110
- var $highlighted = jQuery('<span>').text(matched);
111
- $highlighted.attr({
112
- "class": "regexp-preview",
113
- "data-toggle": "tooltip",
114
- "data-placement": "top",
115
- "title": match.key,
116
- 'style': 'background-color:' + currentColor
117
- });
118
- var highlightedHtml = $highlighted.wrap('<div>').parent().html();
119
-
120
- var pos = {
121
- "start": match.pos[0],
122
- "end": match.pos[1]
123
- };
124
- if(pos.start > 0) {
125
- html += _.escape(whole.substring(lastPos, pos.start));
126
- }
127
- html += highlightedHtml;
128
- lastPos = pos.end;
129
- });
130
- html += whole.substring(lastPos);
131
-
132
- $container.append(html);
133
- $container.append("<br />");
134
- });
135
-
136
- this.highlightedLines = $container.html();
137
- },
138
-
139
- preview: function(){
140
- if(this.previewAjax) {
141
- this.previewAjax.abort();
142
- }
143
-
144
- const token = document.getElementsByName("csrf-token")[0].getAttribute('content')
145
-
146
- var self = this;
147
- new Promise(function(resolve, reject) {
148
- self.previewAjax = $.ajax({
149
- method: "POST",
150
- url: "/api/regexp_preview",
151
- headers: {
152
- 'X-CSRF-Token': token
153
- },
154
- data: {
155
- regexp: self.params.setting.regexp,
156
- time_format: self.params.setting.time_format,
157
- format: _.isEmpty(self.format) ? "regexp" : self.format,
158
- params: self.params.setting,
159
- file: self.targetFile
160
- }
161
- }).done(resolve).fail(reject);
162
- }).then(function(result){
163
- self.params = _.merge(self.params, result.params);
164
- self.regexpMatches = result.matches;
165
- self.updateHighlightedLines();
166
- })["catch"](function(error){
167
- if(error.stack) {
168
- console.error(error.stack);
169
- }
170
- });
171
- },
172
- }
173
- });
174
- });
@@ -1,185 +0,0 @@
1
- class Fluentd
2
- module Setting
3
- module Common
4
- extend ActiveSupport::Concern
5
- include ActiveModel::Model
6
-
7
- module ClassMethods
8
- attr_accessor :values, :types, :children, :hidden_values
9
-
10
- def choice(key, values)
11
- @values ||= {}
12
- @values[key] = values
13
- set_type(:choice, [key])
14
- end
15
-
16
- def hidden(key)
17
- set_type(:hidden, [key])
18
- end
19
-
20
- def nested(key, klass, options = {})
21
- # e.g.:
22
- # <match>
23
- # type forward
24
- # <server>
25
- # ..
26
- # </server>
27
- # </match>
28
- @children ||= {}
29
- @children[key] = {
30
- class: klass,
31
- options: options,
32
- }
33
- set_type(:nested, [key])
34
- end
35
-
36
- def booleans(*keys)
37
- # e.g.:
38
- # use_ssl true
39
- # include_time_key false
40
- set_type(:boolean, keys)
41
- end
42
-
43
- def flags(*keys)
44
- # e.g.:
45
- # tag_mapped
46
- # utc
47
- set_type(:flag, keys)
48
- end
49
-
50
- private
51
-
52
- def set_type(type, keys)
53
- @types ||= {}
54
- keys.each do |key|
55
- @types[key] = type
56
- end
57
- end
58
- end
59
-
60
- def children_of(key)
61
- meta = self.class.children[key]
62
- return unless meta
63
- klass = meta[:class]
64
- data = send(key) || {"0" => {}}
65
- children = []
66
- data.each_pair do |index, attrs|
67
- children << klass.new(attrs)
68
- end
69
- children
70
- end
71
-
72
- def child_class(key)
73
- self.class.children[key][:class]
74
- end
75
-
76
- def values_of(key)
77
- self.class.values.try(:[], key) || []
78
- end
79
-
80
- def column_type(key)
81
- self.class.types.try(:[], key) || "string"
82
- end
83
-
84
- def conf(key)
85
- case column_type(key)
86
- when :boolean
87
- boolenan(key)
88
- when :flag
89
- flag(key)
90
- when :nested
91
- return "" unless send(key)
92
- klass = child_class(key)
93
- send(key).map do |(_, child)|
94
- # send("servers")
95
- #
96
- # "servers" => {
97
- # "0" => {
98
- # "name" => "foo",
99
- # "host" => "bar",
100
- # ..
101
- # },
102
- # "1" => {
103
- # ..
104
- # }
105
- # }
106
- child_instance = klass.new(child)
107
- unless child_instance.empty_value?
108
- "\n" + child_instance.to_config(key).gsub(/^/m, " ")
109
- end
110
- end.join
111
- else # including :hidden
112
- print_if_present(key)
113
- end
114
- end
115
-
116
- def plugin_type_name
117
- # Fluentd::Setting::OutS3 -> s3
118
- # Override this method if not above style
119
- try(:plugin_name) || self.class.to_s.split("::").last.sub(/(In|Out)/, "").downcase
120
- end
121
-
122
- def print_if_present(key)
123
- # e.g.:
124
- # path /var/log/td/aaa
125
- # user nobody
126
- # retry_limit 3
127
- send(key).present? ? "#{key} #{send(key)}" : ""
128
- end
129
-
130
- def boolenan(key)
131
- send(key).presence == "true" ? "#{key} true" : "#{key} false"
132
- end
133
-
134
- def flag(key)
135
- send(key).presence == "true" ? key.to_s : ""
136
- end
137
-
138
- def empty_value?
139
- config = ""
140
- self.class.const_get(:KEYS).each do |key|
141
- config << conf(key)
142
- end
143
- config.empty?
144
- end
145
-
146
- def input_plugin?
147
- self.class.to_s.match(/::In|^In/)
148
- end
149
-
150
- def output_plugin?
151
- not input_plugin?
152
- end
153
-
154
- def to_config(elm_name = nil)
155
- indent = " "
156
- if elm_name
157
- config = "<#{elm_name}>\n"
158
- else
159
- if input_plugin?
160
- config = "<source>\n"
161
- else
162
- config = "<match #{match}>\n"
163
- end
164
- config << "#{indent}type #{plugin_type_name}\n"
165
- end
166
- self.class.const_get(:KEYS).each do |key|
167
- next if key == :match
168
- config << indent
169
- config << conf(key)
170
- config << "\n"
171
- end
172
- if elm_name
173
- config << "</#{elm_name}>\n"
174
- else
175
- if input_plugin?
176
- config << "</source>\n"
177
- else
178
- config << "</match>\n"
179
- end
180
- end
181
- config.gsub(/^[ ]*\n/m, "")
182
- end
183
- end
184
- end
185
- end
@@ -1,48 +0,0 @@
1
- class Fluentd
2
- module Setting
3
- class OutTd
4
- include ActiveModel::Model
5
- include Common
6
-
7
- KEYS = [
8
- :match,
9
- :apikey, :auto_create_table, :database, :table,
10
- :flush_interval, :buffer_type, :buffer_path,
11
- ].freeze
12
-
13
- attr_accessor(*KEYS)
14
-
15
- flags :auto_create_table
16
-
17
- validates :match, presence: true
18
- validates :apikey, presence: true
19
- validates :auto_create_table, presence: true
20
- validates :buffer_path, presence: true, if: ->{ buffer_type == "file" }
21
-
22
- def plugin_name
23
- "tdlog"
24
- end
25
-
26
- def self.initial_params
27
- {
28
- buffer_type: "file",
29
- buffer_path: "/var/log/td-agent/buffer/td",
30
- auto_create_table: true,
31
- match: "td.*.*",
32
- }
33
- end
34
-
35
- def common_options
36
- [
37
- :match, :apikey, :auto_create_table, :database, :table,
38
- ]
39
- end
40
-
41
- def advanced_options
42
- [
43
- :flush_interval, :buffer_type, :buffer_path,
44
- ]
45
- end
46
- end
47
- end
48
- end
@@ -1,43 +0,0 @@
1
- <%- add_javascript_pack_tag("in_tail_format") %>
2
-
3
- <div id="in_tail_format"
4
- formatOptionsJson="<%= formats.to_json %>"
5
- initialSelected="<%= initialSelected %>"
6
- targetFile="<%= file %>"
7
- paramsJson="<%= params.to_json %>"
8
- >
9
-
10
- <div class="form-inline form-group">
11
- <label for="in_tail_setting_format">format</label>
12
- <select id="in_tail_setting_format" name="setting[format]" v-model="format" class="form-control">
13
- <option v-for="selectableFormat in selectableFormats" v-bind:value="selectableFormat" v-bind:selected="format==selectableFormat" v-if="selectableFormats">{{ selectableFormat }}</option>
14
- </select>
15
- </div>
16
- <div class="form-inline form-group" v-for="option in options">
17
- <label v-bind:for="'in_tail_setting_' + option" v-if="!useTextArea">{{ option }} </label>
18
- <input v-bind:id="'in_tail_setting_' + option" v-bind:type="useTextArea ? 'hidden' : 'text'" v-bind:name="'setting[' + option + ']'" v-model="params.setting[option]" v-on:keyup="onKeyup" size="100%" class="form-control" />
19
- </div>
20
-
21
- <div v-if="useTextArea">
22
- <div class="form-inline form-group">
23
- <label for="in_tail_setting_format_firstline">format_firstline</label>
24
- <input id="in_tail_setting_format_firstline" type="text" name="setting[format_firstline]" v-model="params.setting['format_firstline']" v-on:keyup="onKeyup" size="100%" class="form-control" />
25
- </div>
26
-
27
- <div class="form-group">
28
- <p class="alert alert-warning"><%= t("fluentd.settings.in_tail.notice_for_multiline_limit") %></p>
29
- <label for="in_tail_setting_formats">formats</label>
30
- <textarea id="in_tail_setting_formats" type="text" name="setting[formats]" v-model="params.setting['formats']" v-on:keyup="onKeyup" rows='20' size='100%' class="form-control"></textarea>
31
- </div>
32
- </div>
33
-
34
- <div class="card mb-3">
35
- <pre class="card-body" v-html="highlightedLines"></pre>
36
- </div>
37
-
38
- <div class="card mb-3">
39
- <p class="card-body pb-0">
40
- <%= raw t('fluentd.settings.in_tail_option_guide') %>
41
- </p>
42
- </div>
43
- </div>