logstash-codec-graphite 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +8 -1
- data/docs/index.asciidoc +93 -0
- data/lib/logstash/codecs/graphite.rb +4 -2
- data/logstash-codec-graphite.gemspec +2 -2
- data/spec/codecs/graphite_spec.rb +15 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 859dc15d43e063bcbedd5b0a2a2b9296d33f5562
|
4
|
+
data.tar.gz: bafc39cd683fcb28c29d04218a0cff3021015ca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6363a8e6244389d9a106ef5f7a929117521260414532baa394c046dabf2ea529dddbcbfbf40f2e7ae109bca5785e2e9569704e2af1bc684cc49720ad9b5afe92
|
7
|
+
data.tar.gz: 39d3adbe589138e5864f5c44d8f390334017be37dcb3502d711aea33978cbed0f9264cecebbea48e544e8188f5e020ac5a47f857c21dd61ddd903aab87f054f2
|
data/Gemfile
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in logstash-mass_effect.gemspec
|
4
3
|
gemspec
|
4
|
+
|
5
|
+
logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
|
6
|
+
use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
|
7
|
+
|
8
|
+
if Dir.exist?(logstash_path) && use_logstash_source
|
9
|
+
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
|
10
|
+
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
|
11
|
+
end
|
data/docs/index.asciidoc
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
:plugin: graphite
|
2
|
+
:type: codec
|
3
|
+
|
4
|
+
///////////////////////////////////////////
|
5
|
+
START - GENERATED VARIABLES, DO NOT EDIT!
|
6
|
+
///////////////////////////////////////////
|
7
|
+
:version: %VERSION%
|
8
|
+
:release_date: %RELEASE_DATE%
|
9
|
+
:changelog_url: %CHANGELOG_URL%
|
10
|
+
:include_path: ../../../../logstash/docs/include
|
11
|
+
///////////////////////////////////////////
|
12
|
+
END - GENERATED VARIABLES, DO NOT EDIT!
|
13
|
+
///////////////////////////////////////////
|
14
|
+
|
15
|
+
[id="plugins-{type}-{plugin}"]
|
16
|
+
|
17
|
+
=== Graphite codec plugin
|
18
|
+
|
19
|
+
include::{include_path}/plugin_header.asciidoc[]
|
20
|
+
|
21
|
+
==== Description
|
22
|
+
|
23
|
+
This codec will encode and decode Graphite formated lines.
|
24
|
+
|
25
|
+
[id="plugins-{type}s-{plugin}-options"]
|
26
|
+
==== Graphite Codec Configuration Options
|
27
|
+
|
28
|
+
[cols="<,<,<",options="header",]
|
29
|
+
|=======================================================================
|
30
|
+
|Setting |Input type|Required
|
31
|
+
| <<plugins-{type}s-{plugin}-exclude_metrics>> |<<array,array>>|No
|
32
|
+
| <<plugins-{type}s-{plugin}-fields_are_metrics>> |<<boolean,boolean>>|No
|
33
|
+
| <<plugins-{type}s-{plugin}-include_metrics>> |<<array,array>>|No
|
34
|
+
| <<plugins-{type}s-{plugin}-metrics>> |<<hash,hash>>|No
|
35
|
+
| <<plugins-{type}s-{plugin}-metrics_format>> |<<string,string>>|No
|
36
|
+
|=======================================================================
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
[id="plugins-{type}s-{plugin}-exclude_metrics"]
|
41
|
+
===== `exclude_metrics`
|
42
|
+
|
43
|
+
* Value type is <<array,array>>
|
44
|
+
* Default value is `["%{[^}]+}"]`
|
45
|
+
|
46
|
+
Exclude regex matched metric names, by default exclude unresolved %{field} strings
|
47
|
+
|
48
|
+
[id="plugins-{type}s-{plugin}-fields_are_metrics"]
|
49
|
+
===== `fields_are_metrics`
|
50
|
+
|
51
|
+
* Value type is <<boolean,boolean>>
|
52
|
+
* Default value is `false`
|
53
|
+
|
54
|
+
Indicate that the event @fields should be treated as metrics and will be sent as is to graphite
|
55
|
+
|
56
|
+
[id="plugins-{type}s-{plugin}-include_metrics"]
|
57
|
+
===== `include_metrics`
|
58
|
+
|
59
|
+
* Value type is <<array,array>>
|
60
|
+
* Default value is `[".*"]`
|
61
|
+
|
62
|
+
Include only regex matched metric names
|
63
|
+
|
64
|
+
[id="plugins-{type}s-{plugin}-metrics"]
|
65
|
+
===== `metrics`
|
66
|
+
|
67
|
+
* Value type is <<hash,hash>>
|
68
|
+
* Default value is `{}`
|
69
|
+
|
70
|
+
The metric(s) to use. This supports dynamic strings like `%{host}`
|
71
|
+
for metric names and also for values. This is a hash field with key
|
72
|
+
of the metric name, value of the metric value. Example:
|
73
|
+
[source,ruby]
|
74
|
+
[ "%{host}/uptime", "%{uptime_1m}" ]
|
75
|
+
|
76
|
+
The value will be coerced to a floating point value. Values which cannot be
|
77
|
+
coerced will zero (0)
|
78
|
+
|
79
|
+
[id="plugins-{type}s-{plugin}-metrics_format"]
|
80
|
+
===== `metrics_format`
|
81
|
+
|
82
|
+
* Value type is <<string,string>>
|
83
|
+
* Default value is `"*"`
|
84
|
+
|
85
|
+
Defines format of the metric string. The placeholder `*` will be
|
86
|
+
replaced with the name of the actual metric. This supports dynamic
|
87
|
+
strings like `%{host}`.
|
88
|
+
[source,ruby]
|
89
|
+
metrics_format => "%{host}.foo.bar.*.sum"
|
90
|
+
|
91
|
+
NOTE: If no metrics_format is defined the name of the metric will be used as fallback.
|
92
|
+
|
93
|
+
|
@@ -33,9 +33,10 @@ class LogStash::Codecs::Graphite < LogStash::Codecs::Base
|
|
33
33
|
config :exclude_metrics, :validate => :array, :default => [ "%\{[^}]+\}" ]
|
34
34
|
|
35
35
|
# Defines format of the metric string. The placeholder `*` will be
|
36
|
-
# replaced with the name of the actual metric.
|
36
|
+
# replaced with the name of the actual metric. This supports dynamic
|
37
|
+
# strings like `%{host}`.
|
37
38
|
# [source,ruby]
|
38
|
-
# metrics_format => "foo.bar.*.sum"
|
39
|
+
# metrics_format => "%{host}.foo.bar.*.sum"
|
39
40
|
#
|
40
41
|
# NOTE: If no metrics_format is defined the name of the metric will be used as fallback.
|
41
42
|
config :metrics_format, :validate => :string, :default => DEFAULT_METRICS_FORMAT
|
@@ -70,6 +71,7 @@ class LogStash::Codecs::Graphite < LogStash::Codecs::Base
|
|
70
71
|
|
71
72
|
messages = []
|
72
73
|
timestamp = event.sprintf("%{+%s}")
|
74
|
+
@metrics_format = event.sprintf(@metrics_format)
|
73
75
|
|
74
76
|
if @fields_are_metrics
|
75
77
|
@logger.debug("got metrics event", :metrics => event.to_hash)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-codec-graphite'
|
4
|
-
s.version = '3.0.
|
4
|
+
s.version = '3.0.3'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This codec will encode and decode Graphite formated lines."
|
7
7
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.require_paths = ["lib"]
|
12
12
|
|
13
13
|
# Files
|
14
|
-
s.files = Dir[
|
14
|
+
s.files = Dir["lib/**/*","spec/**/*","*.gemspec","*.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", "VERSION", "docs/**/*"]
|
15
15
|
|
16
16
|
# Tests
|
17
17
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
1
2
|
require "logstash/codecs/graphite"
|
2
3
|
require "logstash/event"
|
3
4
|
require "insist"
|
@@ -92,5 +93,19 @@ describe LogStash::Codecs::Graphite do
|
|
92
93
|
end
|
93
94
|
subject.encode(LogStash::Event.new("@timestamp" => timestamp))
|
94
95
|
end
|
96
|
+
|
97
|
+
it "should support dynamic strings in metrics_format" do
|
98
|
+
name = Random.srand.to_s(36)
|
99
|
+
value = Random.rand*1000
|
100
|
+
timestamp = Time.now.gmtime
|
101
|
+
host = "localhost"
|
102
|
+
subject.metrics = {name => value}
|
103
|
+
subject.metrics_format = "%{host}.foo.bar.*.baz"
|
104
|
+
subject.on_event do |event, data|
|
105
|
+
insist { data.is_a? String }
|
106
|
+
insist { data } == "#{host}.foo.bar.#{name}.baz #{value} #{timestamp.to_i}\n"
|
107
|
+
end
|
108
|
+
subject.encode(LogStash::Event.new({'host' => host, "@timestamp" => timestamp}))
|
109
|
+
end
|
95
110
|
end
|
96
111
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-codec-graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- LICENSE
|
71
71
|
- NOTICE.TXT
|
72
72
|
- README.md
|
73
|
+
- docs/index.asciidoc
|
73
74
|
- lib/logstash/codecs/graphite.rb
|
74
75
|
- logstash-codec-graphite.gemspec
|
75
76
|
- spec/codecs/graphite_spec.rb
|
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
version: '0'
|
96
97
|
requirements: []
|
97
98
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.4.8
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: This codec will encode and decode Graphite formated lines.
|