fluent-plugin-librato 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/README.md +36 -0
- data/fluent-plugin-librato.gemspec +23 -0
- data/lib/fluent/plugin/out_librato.rb +53 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5c7f542d70ea4bf1d5e90fb934234fe5aaff95ee
|
4
|
+
data.tar.gz: 6c04b63fbad778d437c7181ff7284118bdd2ab4d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 861233dabd54b218bd9557e3fcb63a161dffdcf3cc682c0174806a3390ee7270cf854ce402228c08bb420339322367e591678097a95cf4ad0b2c8167b5973c30
|
7
|
+
data.tar.gz: 05187cea5fb691d64640fa56b781a559498082fe0a812a2d1e2177cb33965390c2e9b72baa1dc39add8040d6b996eec7b1ec2d9f7e34078d1238c00b7971ca1d
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Fluentd Librato Output Plugin
|
2
|
+
|
3
|
+
This is a [Fluentd](http://www.fluentd.org) plugin to post data to [Librato Metrics](http://librato.com)
|
4
|
+
|
5
|
+
## Installing
|
6
|
+
|
7
|
+
to be uploaded on Rubygems
|
8
|
+
|
9
|
+
## Example config
|
10
|
+
|
11
|
+
```
|
12
|
+
<match librato.**>
|
13
|
+
type librato
|
14
|
+
email YOUR_EMAIL_FOR_LIBRATO
|
15
|
+
apikey YOUR_APIKEY_FOR_LIBRATO
|
16
|
+
</match>
|
17
|
+
```
|
18
|
+
|
19
|
+
## Parameters
|
20
|
+
|
21
|
+
* **email**: (required) The email address associated with Librato.
|
22
|
+
* **apikey**: (required) The apikey associated with Librato.
|
23
|
+
* **measurement_key**: (optional) The measurement key field. Defaults to "key"
|
24
|
+
* **source_key**: (optional) The source key field. Defaults to "source"
|
25
|
+
* **type_key**: (optional) The field that specified type (gauge or counter). Defaults to "type"
|
26
|
+
|
27
|
+
## Example Expected Input
|
28
|
+
|
29
|
+
```
|
30
|
+
{
|
31
|
+
"source": "web.example.com",
|
32
|
+
"key": "memory_usage",
|
33
|
+
"value": 12092323,
|
34
|
+
"type": "gauge"
|
35
|
+
}
|
36
|
+
```
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-librato"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["kiyoto"]
|
9
|
+
spec.email = ["kiyoto@treasure-data.com"]
|
10
|
+
spec.summary = %q{Fluentd plugin to post data to Librato Metrics}
|
11
|
+
spec.homepage = "https://github.com/kiyoto/fluent-plugin-librato"
|
12
|
+
spec.license = "Apache License, Version 2.0"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_runtime_dependency "fluentd"
|
22
|
+
spec.add_runtime_dependency "librato-metrics"
|
23
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Fluent
|
2
|
+
class LibratoOutput < BufferedOutput
|
3
|
+
Plugin.register_output('librato', self)
|
4
|
+
|
5
|
+
config_param :email, :string
|
6
|
+
config_param :apikey, :string
|
7
|
+
config_param :value_key, :string, :default => "value"
|
8
|
+
config_param :measurement_key, :string, :default => "key"
|
9
|
+
config_param :source_key, :string, :default => "source"
|
10
|
+
config_param :type_key, :string, :default => "type"
|
11
|
+
|
12
|
+
def configure(conf)
|
13
|
+
super
|
14
|
+
require 'librato/metrics'
|
15
|
+
Librato::Metrics.authenticate @email, @apikey
|
16
|
+
@queue = Librato::Metrics::Queue.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def start
|
20
|
+
# This is where you instantiate resources specific to the output, e.g.
|
21
|
+
# database connections, client library, etc.
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def shutdown
|
26
|
+
super
|
27
|
+
@queue.submit
|
28
|
+
end
|
29
|
+
|
30
|
+
def write(chunk)
|
31
|
+
chunk.msgpack_each { |tag, time, record|
|
32
|
+
missing_keys = [@measurement_key, @value_key, @source_key].select { |k| !record[k] }
|
33
|
+
if missing_keys.length > 0
|
34
|
+
log.warn "missing the required field(s) " + missing_keys.join(",")
|
35
|
+
next
|
36
|
+
end
|
37
|
+
@queue.add(
|
38
|
+
record[@measurement_key].to_s =>
|
39
|
+
{
|
40
|
+
:source => record[@source_key] || tag,
|
41
|
+
:value => record[@value_key],
|
42
|
+
:type => record[@type_key] || "gauge"
|
43
|
+
})
|
44
|
+
}
|
45
|
+
|
46
|
+
@queue.submit
|
47
|
+
end
|
48
|
+
|
49
|
+
def format(tag, time, record)
|
50
|
+
[tag, time, record].to_msgpack
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-librato
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kiyoto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-23 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: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fluentd
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: librato-metrics
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- kiyoto@treasure-data.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- Gemfile
|
77
|
+
- README.md
|
78
|
+
- fluent-plugin-librato.gemspec
|
79
|
+
- lib/fluent/plugin/out_librato.rb
|
80
|
+
homepage: https://github.com/kiyoto/fluent-plugin-librato
|
81
|
+
licenses:
|
82
|
+
- Apache License, Version 2.0
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.2.2
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Fluentd plugin to post data to Librato Metrics
|
104
|
+
test_files: []
|