logstash-output-librato 0.1.2 → 0.1.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/lib/logstash/outputs/librato.rb +13 -12
- data/logstash-output-librato.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d8f6622975d71749bdcf732b227e20ae302e829
|
4
|
+
data.tar.gz: 405b9e76c811ed3cea2b1355ffd11e626ca9b5e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5d164e5f81608a2ec10ee7457af57cf021045f442575366320eec1c765b704548631a306f912920428eaf77f22b270ea55b435aae20e75484bfd481bec5299f
|
7
|
+
data.tar.gz: 545f60bea32dc01e560a06ade9474b0db15455f90b56157a161796fabe07dcbe40707407a3f9f38e62064d7db68ce6649321a5eab40232557996ef2d15f91380
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/outputs/base"
|
3
3
|
require "logstash/namespace"
|
4
|
+
require "logstash/json"
|
4
5
|
|
5
6
|
|
6
7
|
class LogStash::Outputs::Librato < LogStash::Outputs::Base
|
7
8
|
# This output lets you send metrics, annotations and alerts to
|
8
9
|
# Librato based on Logstash events
|
9
|
-
#
|
10
|
+
#
|
10
11
|
# This is VERY experimental and inefficient right now.
|
11
12
|
|
12
13
|
config_name "librato"
|
@@ -71,7 +72,7 @@ class LogStash::Outputs::Librato < LogStash::Outputs::Base
|
|
71
72
|
@client = Net::HTTP.new(@uri.host, @uri.port)
|
72
73
|
@client.use_ssl = true
|
73
74
|
@client.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
74
|
-
|
75
|
+
|
75
76
|
end # def register
|
76
77
|
|
77
78
|
public
|
@@ -86,9 +87,9 @@ class LogStash::Outputs::Librato < LogStash::Outputs::Base
|
|
86
87
|
g_hash.each do |k,v|
|
87
88
|
g_hash[k] = v.to_f if k=="value"
|
88
89
|
end
|
89
|
-
g_hash['measure_time'] = event
|
90
|
+
g_hash['measure_time'] = event.timestamp.to_i unless g_hash['measure_time']
|
90
91
|
@logger.warn("Gauges hash", :data => g_hash)
|
91
|
-
metrics_event['gauges'] = Array.new
|
92
|
+
metrics_event['gauges'] = Array.new
|
92
93
|
metrics_event['gauges'] << g_hash
|
93
94
|
@logger.warn("Metrics hash", :data => metrics_event)
|
94
95
|
end
|
@@ -97,21 +98,21 @@ class LogStash::Outputs::Librato < LogStash::Outputs::Base
|
|
97
98
|
c_hash.each do |k,v|
|
98
99
|
c_hash[k] = v.to_f if k=="value"
|
99
100
|
end
|
100
|
-
c_hash['measure_time'] = event
|
101
|
+
c_hash['measure_time'] = event.timestamp.to_i unless c_hash['measure_time']
|
101
102
|
@logger.warn("Counters hash", :data => c_hash)
|
102
103
|
metrics_event['counters'] = Array.new
|
103
104
|
metrics_event['counters'] << c_hash
|
104
105
|
@logger.warn("Metrics hash", :data => metrics_event)
|
105
106
|
end
|
106
|
-
|
107
|
+
|
107
108
|
# TODO (lusis)
|
108
109
|
# Clean this mess up
|
109
110
|
unless metrics_event.size == 0
|
110
111
|
request = Net::HTTP::Post.new(@uri.path+"metrics")
|
111
112
|
request.basic_auth(@account_id, @api_token)
|
112
|
-
|
113
|
+
|
113
114
|
begin
|
114
|
-
request.body = metrics_event
|
115
|
+
request.body = LogStash::Json.dump(metrics_event)
|
115
116
|
request.add_field("Content-Type", 'application/json')
|
116
117
|
response = @client.request(request)
|
117
118
|
@logger.warn("Librato convo", :request => request.inspect, :response => response.inspect)
|
@@ -127,19 +128,19 @@ class LogStash::Outputs::Librato < LogStash::Outputs::Base
|
|
127
128
|
@logger.warn("Original Annotation", :data => @annotation)
|
128
129
|
annotation_event = Hash[*@annotation.collect{|k,v| [event.sprintf(k),event.sprintf(v)]}.flatten]
|
129
130
|
@logger.warn("Annotation event", :data => annotation_event)
|
130
|
-
|
131
|
+
|
131
132
|
annotation_path = "#{@uri.path}annotations/#{annotation_event['name']}"
|
132
133
|
@logger.warn("Annotation path", :data => annotation_path)
|
133
134
|
request = Net::HTTP::Post.new(annotation_path)
|
134
135
|
request.basic_auth(@account_id, @api_token)
|
135
136
|
annotation_event.delete('name')
|
136
|
-
annotation_event['start_time'] = event
|
137
|
-
annotation_event['end_time'] = event
|
137
|
+
annotation_event['start_time'] = event.timestamp.to_i unless annotation_event['start_time']
|
138
|
+
annotation_event['end_time'] = event.timestamp.to_i unless annotation_event['end_time']
|
138
139
|
annotation_hash['annotations'] << annotation_event
|
139
140
|
@logger.warn("Annotation event", :data => annotation_event)
|
140
141
|
|
141
142
|
begin
|
142
|
-
request.body = annotation_event
|
143
|
+
request.body = LogStash::Json.dump(annotation_event)
|
143
144
|
request.add_field("Content-Type", 'application/json')
|
144
145
|
response = @client.request(request)
|
145
146
|
@logger.warn("Librato convo", :request => request.inspect, :response => response.inspect)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-librato'
|
4
|
-
s.version = '0.1.
|
4
|
+
s.version = '0.1.3'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This output lets you send metrics, annotations and alerts to Librato based on Logstash events"
|
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/plugin install gemname. This gem is not a stand-alone program"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-librato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elasticsearch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.4.5
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: This output lets you send metrics, annotations and alerts to Librato based on Logstash events
|