fluent-plugin-cmetrics 0.1.0.rc5 → 0.1.0.rc6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/fluent-plugin-cmetrics.gemspec +1 -1
- data/lib/fluent/plugin/filter_cmetrics_parser.rb +7 -0
- data/test/plugin/test_filter_cmetrics_parser.rb +30 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65548cae758782bc23022e7078dbab4a7c566b6175a652e7c5cee348a3b1ef93
|
4
|
+
data.tar.gz: e5fe401babbfe22ac5038130dd72d29135a794c155e4a294c59fbc4b5898dd41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6991cae004f796934cd0b4dd7d5d1ef9f175798c7c799ac0c417860451b6c4c04deb2d9c9fb0776a20eae180f826854b8c089b31ea79cdc2ea1ced376defe1a1
|
7
|
+
data.tar.gz: 28fd06e6a2df8d259aab80eff36a27cc2bd3a2155e47c45170c6d5704c24882d42226d3ff1f8f55fd8e6a73c1825adb45d1e05d46cffae0bea56e7b1097edd51
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-cmetrics"
|
6
|
-
spec.version = "0.1.0.
|
6
|
+
spec.version = "0.1.0.rc6"
|
7
7
|
spec.authors = ["Hiroshi Hatake"]
|
8
8
|
spec.email = ["cosmo0920.oucc@gmail.com"]
|
9
9
|
|
@@ -30,6 +30,8 @@ module Fluent
|
|
30
30
|
config_param :cmetrics_metric_key, :string, default: "cmetrics"
|
31
31
|
desc "cmetrics labels key"
|
32
32
|
config_param :cmetrics_labels_key, :string, default: "labels"
|
33
|
+
desc "hostname key"
|
34
|
+
config_param :host_key, :string, default: "host"
|
33
35
|
desc "format to Splunk metrics"
|
34
36
|
config_param :format_to_splunk_metric, :bool, default: false
|
35
37
|
desc "dimensions key"
|
@@ -40,6 +42,7 @@ module Fluent
|
|
40
42
|
@serde = ::CMetrics::Serde.new
|
41
43
|
@record_accessor = record_accessor_create(@cmetrics_metric_key)
|
42
44
|
@labels_accessor = record_accessor_create(@cmetrics_labels_key)
|
45
|
+
@hostname_accessor = record_accessor_create(@host_key)
|
43
46
|
end
|
44
47
|
|
45
48
|
def format_to_splunk_style_with_dims(inner)
|
@@ -59,6 +62,7 @@ module Fluent
|
|
59
62
|
new_es = Fluent::MultiEventStream.new
|
60
63
|
es.each do |time, record|
|
61
64
|
data = @record_accessor.call(record)
|
65
|
+
hostname = @hostname_accessor.call(record)
|
62
66
|
@serde.feed_each(data) do |cmetrics|
|
63
67
|
metrics = cmetrics.metrics
|
64
68
|
metrics.each do |metric|
|
@@ -73,6 +77,9 @@ module Fluent
|
|
73
77
|
inner.merge!(dims)
|
74
78
|
end
|
75
79
|
end
|
80
|
+
if hostname
|
81
|
+
inner[@host_key] = hostname
|
82
|
+
end
|
76
83
|
time = Time.at(inner.delete("timestamp"))
|
77
84
|
new_es.add(Fluent::EventTime.new(time.to_i, time.nsec), inner)
|
78
85
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "helper"
|
2
2
|
require "fluent/plugin/filter_cmetrics_parser.rb"
|
3
|
+
require 'socket'
|
3
4
|
|
4
5
|
class CmetricsParserTest < Test::Unit::TestCase
|
5
6
|
setup do
|
@@ -49,6 +50,35 @@ class CmetricsParserTest < Test::Unit::TestCase
|
|
49
50
|
d.feed(time, record)
|
50
51
|
end
|
51
52
|
d.filtered.map {|e| assert_equal(!!use_dimensions, e.last.has_key?("dims"))}
|
53
|
+
d.filtered.map {|e| assert_false(e.last.has_key?("hostname"))}
|
54
|
+
assert do
|
55
|
+
d.filtered.size > 0
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
data("with dimensions" => "dims",
|
60
|
+
"without dimensions" => nil)
|
61
|
+
test "#filter_stream with host_key" do |data|
|
62
|
+
use_dimensions = data
|
63
|
+
d = if use_dimensions
|
64
|
+
create_driver(%[
|
65
|
+
format_to_splunk_metric true
|
66
|
+
dimensions_key dims
|
67
|
+
host_key hostname
|
68
|
+
])
|
69
|
+
else
|
70
|
+
create_driver(%[
|
71
|
+
format_to_splunk_metric true
|
72
|
+
host_key hostname
|
73
|
+
])
|
74
|
+
end
|
75
|
+
time = event_time("2012-01-02 13:14:15")
|
76
|
+
record = {"cmetrics" => @binary, "hostname" => Socket.gethostname}
|
77
|
+
d.run(default_tag: 'test') do
|
78
|
+
d.feed(time, record)
|
79
|
+
end
|
80
|
+
d.filtered.map {|e| assert_equal(!!use_dimensions, e.last.has_key?("dims"))}
|
81
|
+
d.filtered.map {|e| assert_true(e.last.has_key?("hostname"))}
|
52
82
|
assert do
|
53
83
|
d.filtered.size > 0
|
54
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-cmetrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.rc6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Hatake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|