fluent-plugin-cmetrics 0.1.0.rc3 → 0.1.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0cb7fd9484f58d44c52df4a1420bb4ecfc3cd612e47e223bd7dd74871e477c3
|
4
|
+
data.tar.gz: 0cdeabbb2069ccac75b15337f9f5141909944d5bc70ad4e6a46cecc4b6d82904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bd6c7e03deeceae65fc856e89f8340e2c207e27aa77cf83805399d6475db7662aea8fb421c2c1314dc3cc35d2ec9f20f8d0ab2dba7c53efee6d3e06a26fd947
|
7
|
+
data.tar.gz: 7349f9dd27645fbe3f8fd024bdd00e8db31c5ac728642a75bc8570157098a76827b7308e4b9526b4d3d34fbd54b81f73eb9c0f27fae3b55b65e8be1201cb359a
|
@@ -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.rc4"
|
7
7
|
spec.authors = ["Hiroshi Hatake"]
|
8
8
|
spec.email = ["cosmo0920.oucc@gmail.com"]
|
9
9
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2021- Calyptia Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require "fluent/plugin/formatter"
|
17
|
+
require 'fluent/plugin_helper/record_accessor'
|
18
|
+
require 'fluent/plugin_helper'
|
19
|
+
require "fluent/event"
|
20
|
+
require "fluent/time"
|
21
|
+
require "yajl"
|
22
|
+
require "socket"
|
23
|
+
|
24
|
+
module Fluent
|
25
|
+
module Plugin
|
26
|
+
class CMetricsSplunkMetricPayloadFormatter < Fluent::Plugin::Formatter
|
27
|
+
include PluginHelper::Mixin
|
28
|
+
|
29
|
+
Fluent::Plugin.register_formatter('cmetrics_splunk_metric_payload', self)
|
30
|
+
|
31
|
+
helpers :record_accessor
|
32
|
+
|
33
|
+
desc "cmetrics metrics name key"
|
34
|
+
config_param :cmetrics_name_key, :string, default: "name"
|
35
|
+
desc "cmetrics metrics value key"
|
36
|
+
config_param :cmetrics_value_key, :string, default: "value"
|
37
|
+
desc "Specify host key"
|
38
|
+
config_param :host_key, :string, default: "host"
|
39
|
+
desc "Specify splunk index name"
|
40
|
+
config_param :index, :string, default: nil
|
41
|
+
desc "Specify splunk source name"
|
42
|
+
config_param :source, :string, default: nil
|
43
|
+
desc "Specify splunk sourcetype name"
|
44
|
+
config_param :sourcetype, :string, default: nil
|
45
|
+
|
46
|
+
def initialize
|
47
|
+
super
|
48
|
+
@default_host = Socket.gethostname
|
49
|
+
end
|
50
|
+
|
51
|
+
def configure(conf)
|
52
|
+
super
|
53
|
+
|
54
|
+
@cmetrics_name_accessor = record_accessor_create(@cmetrics_name_key)
|
55
|
+
@cmetrics_value_accessor = record_accessor_create(@cmetrics_value_key)
|
56
|
+
@host_key_accessor = record_accessor_create(@host_key)
|
57
|
+
end
|
58
|
+
|
59
|
+
def format(tag, time, record)
|
60
|
+
host = if host = @host_key_accessor.call(record)
|
61
|
+
host
|
62
|
+
else
|
63
|
+
@default_host
|
64
|
+
end
|
65
|
+
payload = {
|
66
|
+
host: host,
|
67
|
+
# From the API reference
|
68
|
+
# https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTinput#services.2Fcollector
|
69
|
+
time: time.to_f.to_s,
|
70
|
+
event: 'metric',
|
71
|
+
}
|
72
|
+
payload[:index] = @index if @index
|
73
|
+
payload[:source] = @source if @source
|
74
|
+
payload[:sourcetype] = @sourcetype if @sourcetype
|
75
|
+
|
76
|
+
metric_fields = {
|
77
|
+
"metric_name:#{@cmetrics_name_accessor.call(record)}" => @cmetrics_value_accessor.call(record)
|
78
|
+
}
|
79
|
+
payload.merge!(metric_fields)
|
80
|
+
Yajl.dump(payload)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
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.rc4
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- Rakefile
|
101
101
|
- fluent-plugin-cmetrics.gemspec
|
102
102
|
- lib/fluent/plugin/filter_cmetrics_parser.rb
|
103
|
+
- lib/fluent/plugin/formatter_cmetrics_splunk_metric_payload.rb
|
103
104
|
- test/fixtures/cmetrics.bin
|
104
105
|
- test/helper.rb
|
105
106
|
- test/plugin/test_filter_cmetrics_parser.rb
|
@@ -122,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
123
|
- !ruby/object:Gem::Version
|
123
124
|
version: 1.3.1
|
124
125
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.2.22
|
126
127
|
signing_key:
|
127
128
|
specification_version: 4
|
128
129
|
summary: Fluentd plugin for cmetrics format handling.
|