logstash_writer 0.0.1 → 0.0.2

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: 1e9c21173eb335510d759c7a95e155143843638f57683255a76b6004d5436d43
4
- data.tar.gz: 84b3446aeed41977f6323afa1ddc2dbb30d6ac53ae1bf4e5a809754c63a308cb
3
+ metadata.gz: 9576e2183a13c91af62f4c79799abfc40d972fd73fdcdae1ac0bad43130dcd60
4
+ data.tar.gz: 374055c057069d5fc384238d3c7e25d94a3a1dcdc36043bc91b59f41816351e7
5
5
  SHA512:
6
- metadata.gz: 44e83922151535909f5994645bfcbf4049b98213759fa4b3655a3f4bfe185fca8da7c6970c6e95cee8f081e53bfe2ed020d8502eced9f1aa30625c88b5634bd4
7
- data.tar.gz: 68131f6cf7c645a67a0d71ac95247b084bde331b464770bfed28bb2153365e40c06e3265f0399096f55150e2e5b000e23d63bf3622336f72c689f162a70f91ef
6
+ metadata.gz: 13e50c9fd6de39119a8ceee4950d5c43317678c4af61fc2bd85a531b2fb57be2825e0ca1ca46324a5a3a791dc797b6c6d428e58459965504c4b91bf5e89b2ec4
7
+ data.tar.gz: c6d45ca2e6dd84fc0047a97e31dbfd6a1841e2e4f978fa91bd46e876837d0ae82a55351d873d0cd86fffc675ca8865e03b12f8dd5e0498cfc5052a53dff8f50d
data/README.md CHANGED
@@ -6,11 +6,11 @@ implementation of a means of getting events to a logstash cluster.
6
6
 
7
7
  It's a gem:
8
8
 
9
- gem install gemplate
9
+ gem install logstash_writer
10
10
 
11
11
  There's also the wonders of [the Gemfile](http://bundler.io):
12
12
 
13
- gem 'gemplate'
13
+ gem 'logstash_writer'
14
14
 
15
15
  If you're the sturdy type that likes to run from git:
16
16
 
@@ -41,6 +41,10 @@ as that is fixed, we are stuck with the `json_lines` approach.
41
41
 
42
42
  # Usage
43
43
 
44
+ Start by including the necessary files:
45
+
46
+ require 'logstash_writer'
47
+
44
48
  An instance of `LogstashWriter` needs to be given the location of a server
45
49
  (or servers) to send the events to. This can be any of:
46
50
 
@@ -117,7 +121,7 @@ The metrics that are exposed are:
117
121
  always be `received - (sent + dropped)`, but this gauge is maintained
118
122
  separately as a cross-check in case of bugs.
119
123
 
120
- * **`logstash_writer_last_sent_event_timestamp`** -- the UTC timestamp,
124
+ * **`logstash_writer_last_sent_event_time_seconds`** -- the UTC timestamp,
121
125
  represented as the number of (fractional) seconds since the Unix epoch, at
122
126
  which the most recent event sent to a logstash server was originally
123
127
  submitted via `#send_event`. This might require some unpacking.
@@ -129,7 +133,7 @@ The metrics that are exposed are:
129
133
 
130
134
  Firstly, if there are queued events, you can tell how far behind in real
131
135
  time your logstash event history is, by calculating `NOW() -
132
- logstash_writer_last_sent_event_timestamp`. Thus, if you're not finding
136
+ logstash_writer_last_sent_event_time_seconds`. Thus, if you're not finding
133
137
  events in your Kibana dashboard you were expecting to see, you can tell
134
138
  that there's a clog in the pipes by looking at this.
135
139
 
@@ -79,7 +79,7 @@ class LogstashWriter
79
79
  queue_size: metrics_registry.gauge(:"#{metrics_prefix}_queue_size", "The number of events currently in the queue to be sent"),
80
80
  dropped: metrics_registry.counter(:"#{metrics_prefix}_events_dropped_total", "The number of events which have been dropped from the queue"),
81
81
 
82
- lag: metrics_registry.gauge(:"#{metrics_prefix}_last_sent_event_timestamp", "When the last event successfully sent to logstash was originally received"),
82
+ lag: metrics_registry.gauge(:"#{metrics_prefix}_last_sent_event_time_seconds", "When the last event successfully sent to logstash was originally received"),
83
83
 
84
84
  connected: metrics_registry.gauge(:"#{metrics_prefix}_connected_to_server", "Boolean flag indicating whether we are currently connected to a logstash server"),
85
85
  connect_exception: metrics_registry.counter(:"#{metrics_prefix}_connect_exceptions_total", "The number of exceptions that have occurred whilst attempting to connect to a logstash server"),
@@ -115,7 +115,7 @@ class LogstashWriter
115
115
  end
116
116
 
117
117
  unless e.has_key?(:@timestamp) || e.has_key?("@timestamp")
118
- e[:@timestamp] = Time.now.utc.strftime("%FT%TZ")
118
+ e[:@timestamp] = Time.now.utc.strftime("%FT%T.%NZ")
119
119
  end
120
120
 
121
121
  unless e.has_key?(:_id) || e.has_key?("_id")
@@ -243,6 +243,12 @@ class LogstashWriter
243
243
  end
244
244
  rescue StandardError => ex
245
245
  @logger.error("LogstashWriter") { (["Exception in write_loop: #{ex.message} (#{ex.class})"] + ex.backtrace).join("\n ") }
246
+ # If there was some sort of error, there's a non-trivial chance the
247
+ # socket has gone *boom*, so let's invalidate it and go around again
248
+ if @current_socket
249
+ @current_socket.close
250
+ @current_socket = nil
251
+ end
246
252
  @queue_mutex.synchronize { @queue.unshift(event) if event }
247
253
  @metrics[:write_loop_exception].increment(class: ex.class.to_s)
248
254
  @metrics[:write_loop_ok].set({}, 0)
@@ -27,7 +27,6 @@ Gem::Specification.new do |s|
27
27
 
28
28
  s.required_ruby_version = ">= 2.3.0"
29
29
 
30
- s.add_runtime_dependency "frankenstein", "~> 1.0"
31
30
  # prometheus-client provides no guaranteed backwards compatibility,
32
31
  # and in fact happily breaks things with no notice, so we're stuck
33
32
  # with hard-coding a specific version to avoid unexpected disaster.
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash_writer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2018-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: frankenstein
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: prometheus-client
29
15
  requirement: !ruby/object:Gem::Requirement