vitals-riemann_reporter 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +56 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/vitals/riemann_reporter/riemann_format.rb +16 -0
- data/lib/vitals/riemann_reporter/version.rb +5 -0
- data/lib/vitals/riemann_reporter.rb +45 -0
- data/vitals-riemann_reporter.gemspec +30 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f063bb98df4b827f5b05968e517e308fed6e032a
|
4
|
+
data.tar.gz: 15b3b06a7ee7e27d62641be55a29fa8f06ee91c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c63d6b7ffd6ea4b56b5237724075e5d348d9b80959f3194338a9a82bba1316e6507638652881f0157f5d15d61ad30fd1b660fb259dd2e8b496786c97fe7085c7
|
7
|
+
data.tar.gz: b3eb695eab7e8938778e7ae62728f956921b4da8a22ca72748939c36d8fca0f856f9f0cd93e0abc61eb17a25b528f3d8953b1af64e3e71ed237524e3f7adfb46
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Ben Maraney
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Vitals::RiemannReporter
|
2
|
+
|
3
|
+
The Riemann Reporter allows [Vitals](https://github.com/jondot/vitals) to send metrics to Riemann instead of StatsD.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'vitals-riemann_reporter'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install vitals-riemann_reporter
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Initialise Vitals with a RiemannReporter. You may also like to use the RiemannFormat so that your metric names do not include things that are already passed to Riemann as fields(ie. host, facility and environment):
|
24
|
+
|
25
|
+
```
|
26
|
+
require 'vitals'
|
27
|
+
Vitals.configure! do |c|
|
28
|
+
c.format = Vitals::Formats:RiemannFormat
|
29
|
+
c.facility = 'facility'
|
30
|
+
c.environment = 'environment'
|
31
|
+
c.reporter = Vitals::Reporters::RiemannReporter.new(host: 'riemann-host', port: 5555, facility: 'facility', environment: 'environment')
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
The Riemann client does not open a connection until a metric is sent, so you can speed up your first request by sending a connected event in your initializer:
|
36
|
+
|
37
|
+
```
|
38
|
+
Vitals.inc('riemann_connected')
|
39
|
+
```
|
40
|
+
|
41
|
+
In Riemann, events will be tagged as 'vitals' and either 'counter', 'gauge' or 'timer' depending on the type of event. They will have their host, facility and environment set as fields.
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Ben-M/vitals-riemann_reporter.
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
56
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "vitals/riemann_reporter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Vitals::Formats
|
2
|
+
class RiemannFormat
|
3
|
+
attr_accessor :environment
|
4
|
+
attr_accessor :host
|
5
|
+
attr_accessor :facility
|
6
|
+
|
7
|
+
def initialize(environment:nil, facility:nil, host:nil)
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
def format(m)
|
12
|
+
return "" if (m.nil? || m.empty?)
|
13
|
+
Vitals::Utils.normalize_metric(m)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "vitals/riemann_reporter/version"
|
2
|
+
|
3
|
+
require 'riemann/client'
|
4
|
+
require_relative 'riemann_reporter/riemann_format'
|
5
|
+
require 'vitals'
|
6
|
+
|
7
|
+
module Vitals::Reporters
|
8
|
+
class RiemannReporter < BaseReporter
|
9
|
+
attr_accessor :format
|
10
|
+
attr_reader :riemann
|
11
|
+
|
12
|
+
def initialize(host: 'localhost', port: 5555, timeout: 5, format: nil, facility: nil, environment: nil)
|
13
|
+
@riemann = Riemann::Client.new(host: host, port: port, timeout: timeout)
|
14
|
+
@format = format
|
15
|
+
@facility = facility
|
16
|
+
@environment = environment
|
17
|
+
end
|
18
|
+
|
19
|
+
def inc(m)
|
20
|
+
emit(format.format(m), 1, 'counter')
|
21
|
+
end
|
22
|
+
|
23
|
+
def gauge(m, v)
|
24
|
+
emit(format.format(m), v, 'gauge')
|
25
|
+
end
|
26
|
+
|
27
|
+
def timing(m, v)
|
28
|
+
emit(format.format(m), v, 'timer')
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def emit(m, v, type)
|
33
|
+
@riemann << {
|
34
|
+
service: m,
|
35
|
+
metric: v,
|
36
|
+
time: Time.now.to_i,
|
37
|
+
tags: ['vitals', type],
|
38
|
+
facility: @facility,
|
39
|
+
environment: @environment
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vitals/riemann_reporter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vitals-riemann_reporter"
|
8
|
+
spec.version = Vitals::RiemannReporter::VERSION
|
9
|
+
spec.authors = ["Ben Maraney"]
|
10
|
+
spec.email = ["ben@maraney.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A Riemann Reporter for Vitals}
|
13
|
+
spec.description = %q{Send your Vitals metrics to Riemann}
|
14
|
+
spec.homepage = "https://github.com/Ben-M/vitals_riemann-reporter"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
25
|
+
spec.add_development_dependency "rr", "~> 1.1.2"
|
26
|
+
|
27
|
+
|
28
|
+
spec.add_runtime_dependency "vitals", ">= 0.9.1"
|
29
|
+
spec.add_runtime_dependency "riemann-client", ">= 0.2.6"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vitals-riemann_reporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Maraney
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.1.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vitals
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.9.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.9.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: riemann-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.2.6
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.2.6
|
97
|
+
description: Send your Vitals metrics to Riemann
|
98
|
+
email:
|
99
|
+
- ben@maraney.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/console
|
111
|
+
- bin/setup
|
112
|
+
- lib/vitals/riemann_reporter.rb
|
113
|
+
- lib/vitals/riemann_reporter/riemann_format.rb
|
114
|
+
- lib/vitals/riemann_reporter/version.rb
|
115
|
+
- vitals-riemann_reporter.gemspec
|
116
|
+
homepage: https://github.com/Ben-M/vitals_riemann-reporter
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.2.2
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: A Riemann Reporter for Vitals
|
140
|
+
test_files: []
|