twemproxy_exporter 0.1.1 → 0.3.1
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 +5 -5
- data/.gitignore +2 -2
- data/.travis.yml +3 -2
- data/README.md +6 -4
- data/lib/twemproxy_exporter/counter.rb +5 -5
- data/lib/twemproxy_exporter/twemproxy.rb +12 -5
- data/lib/twemproxy_exporter/version.rb +1 -1
- data/twemproxy_exporter.gemspec +2 -2
- metadata +7 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6c526524a297bbd8e6ec6756d36277d134c2099071ba8ff3134c37af63e61954
|
|
4
|
+
data.tar.gz: 971989dceffd599097d2ff3d07a87b8c2cc878d590f174716bf719eb2f2d076a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44c1cf6c4e423d569b4b7b046cfcb08b354da23431861852f4aac774f6e3b7f2d6aa56a31238f530f40cedcd5cf0b4c71f14edab9786eaca2d6ab9142d2fce08
|
|
7
|
+
data.tar.gz: a08c9480dcb77c88616b247bb409eb8096b4298a5cc50e5a4156d401761f0e7770144a1d8741fbb9f1a54cbd461a7f6575e9221f26db368d2eedd33b494c2d16
|
data/.gitignore
CHANGED
|
@@ -29,8 +29,8 @@ build/
|
|
|
29
29
|
# for a library or gem, you might want to ignore these files since the code is
|
|
30
30
|
# intended to run in multiple environments; otherwise, check them in:
|
|
31
31
|
Gemfile.lock
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
.ruby-version
|
|
33
|
+
.ruby-gemset
|
|
34
34
|
|
|
35
35
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
36
36
|
.rvmrc
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# twemproxy_exporter
|
|
2
2
|
[](https://travis-ci.org/xavierholt/twemproxy_exporter)
|
|
3
|
+
[](https://rubygems.org/gems/twemproxy_exporter)
|
|
3
4
|
|
|
4
5
|
This is a simple Prometheus exporter for Twemproxy (a.k.a. Nutcracker), written
|
|
5
6
|
in Ruby. It currently takes a list of Twemproxy URLs to monitor and exposes
|
|
@@ -11,8 +12,9 @@ Run it from the command line like this:
|
|
|
11
12
|
twemproxy_exporter my.proxy.host my.other.proxy.host:33333
|
|
12
13
|
```
|
|
13
14
|
|
|
14
|
-
Run it with the `--help` flag to see the full list of options
|
|
15
|
-
|
|
15
|
+
Run it with the `--help` flag to see the full list of options, or check out [the
|
|
16
|
+
source](https://github.com/xavierholt/twemproxy_exporter/blob/master/bin/twemproxy_exporter).
|
|
17
|
+
It can also read these options from a JSON or YAML file:
|
|
16
18
|
|
|
17
19
|
```yml
|
|
18
20
|
bind: 127.0.0.1
|
|
@@ -20,8 +22,8 @@ port: 9876
|
|
|
20
22
|
interval: 10
|
|
21
23
|
timeout: 2
|
|
22
24
|
proxies:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
- my.twemproxy.host
|
|
26
|
+
- my.other.twemproxy.host:33333
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
```sh
|
|
@@ -3,17 +3,17 @@ module TwemproxyExporter
|
|
|
3
3
|
def initialize(registry, name, desc)
|
|
4
4
|
@counter = Prometheus::Client::Counter.new(name, desc)
|
|
5
5
|
registry.register(@counter)
|
|
6
|
-
@
|
|
6
|
+
@last_values = {}
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def count(value, labels = {})
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
last = @last_values[labels] || 0
|
|
11
|
+
if value >= last
|
|
12
|
+
@counter.increment(labels, value - last)
|
|
12
13
|
else
|
|
13
14
|
@counter.increment(labels, value)
|
|
14
15
|
end
|
|
15
|
-
|
|
16
|
-
@last = value
|
|
16
|
+
@last_values[labels] = value
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def value(labels = {})
|
|
@@ -16,7 +16,8 @@ module TwemproxyExporter
|
|
|
16
16
|
def count
|
|
17
17
|
stats = self.stats
|
|
18
18
|
name = stats['source']
|
|
19
|
-
|
|
19
|
+
proxy = "#{@host}:#{@port}"
|
|
20
|
+
labels = {twemproxy: name, proxy: proxy}
|
|
20
21
|
|
|
21
22
|
@exporter.total_connections.count stats['total_connections'], labels
|
|
22
23
|
@exporter.curr_connections.count stats['curr_connections'], labels
|
|
@@ -24,7 +25,7 @@ module TwemproxyExporter
|
|
|
24
25
|
|
|
25
26
|
stats.each do |cluster, cinfo|
|
|
26
27
|
next unless cinfo.is_a? Hash
|
|
27
|
-
labels = {twemproxy: name, cluster: cluster}
|
|
28
|
+
labels = {twemproxy: name, proxy: proxy, cluster: cluster}
|
|
28
29
|
|
|
29
30
|
@exporter.fragments.count cinfo['fragments'], labels
|
|
30
31
|
@exporter.forward_error.count cinfo['forward_error'], labels
|
|
@@ -35,7 +36,7 @@ module TwemproxyExporter
|
|
|
35
36
|
|
|
36
37
|
cinfo.each do |server, sinfo|
|
|
37
38
|
next unless sinfo.is_a? Hash
|
|
38
|
-
labels = {twemproxy: name, cluster: cluster, server: server}
|
|
39
|
+
labels = {twemproxy: name, proxy: proxy, cluster: cluster, server: server}
|
|
39
40
|
|
|
40
41
|
@exporter.in_queue.count sinfo['in_queue'], labels
|
|
41
42
|
@exporter.in_queue_bytes.count sinfo['in_queue_bytes'], labels
|
|
@@ -58,8 +59,14 @@ module TwemproxyExporter
|
|
|
58
59
|
|
|
59
60
|
def stats
|
|
60
61
|
socket = TCPSocket.new(@host, @port)
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
if not select([socket], nil, nil, @exporter.timeout)
|
|
63
|
+
raise "Connection to #{@host}:#{@port} timed out after #{@exporter.timeout} seconds."
|
|
64
|
+
end
|
|
65
|
+
data = socket.read
|
|
66
|
+
# Double-quoted server aliases are not escaped by twemproxy
|
|
67
|
+
# https://github.com/twitter/twemproxy/issues/532
|
|
68
|
+
data.gsub!(/"("[^"]+")"/, '\1')
|
|
69
|
+
return YAML.load(data)
|
|
63
70
|
ensure
|
|
64
71
|
socket.close if socket
|
|
65
72
|
end
|
data/twemproxy_exporter.gemspec
CHANGED
|
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
22
22
|
spec.require_paths = ["lib"]
|
|
23
23
|
|
|
24
|
-
spec.add_development_dependency "bundler", "~> 1
|
|
25
|
-
spec.add_development_dependency "rake", "~>
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 12.3.3"
|
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
27
27
|
|
|
28
28
|
spec.add_runtime_dependency "prometheus-client", "~> 0.6.0"
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: twemproxy_exporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Burk
|
|
8
8
|
- Andrew Tongen
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: bundler
|
|
@@ -17,28 +16,28 @@ dependencies:
|
|
|
17
16
|
requirements:
|
|
18
17
|
- - "~>"
|
|
19
18
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '1
|
|
19
|
+
version: '2.1'
|
|
21
20
|
type: :development
|
|
22
21
|
prerelease: false
|
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
23
|
requirements:
|
|
25
24
|
- - "~>"
|
|
26
25
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '1
|
|
26
|
+
version: '2.1'
|
|
28
27
|
- !ruby/object:Gem::Dependency
|
|
29
28
|
name: rake
|
|
30
29
|
requirement: !ruby/object:Gem::Requirement
|
|
31
30
|
requirements:
|
|
32
31
|
- - "~>"
|
|
33
32
|
- !ruby/object:Gem::Version
|
|
34
|
-
version:
|
|
33
|
+
version: 12.3.3
|
|
35
34
|
type: :development
|
|
36
35
|
prerelease: false
|
|
37
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
37
|
requirements:
|
|
39
38
|
- - "~>"
|
|
40
39
|
- !ruby/object:Gem::Version
|
|
41
|
-
version:
|
|
40
|
+
version: 12.3.3
|
|
42
41
|
- !ruby/object:Gem::Dependency
|
|
43
42
|
name: rspec
|
|
44
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -81,7 +80,6 @@ dependencies:
|
|
|
81
80
|
- - "~>"
|
|
82
81
|
- !ruby/object:Gem::Version
|
|
83
82
|
version: '2.0'
|
|
84
|
-
description:
|
|
85
83
|
email:
|
|
86
84
|
- xavierholt@gmail.com
|
|
87
85
|
executables:
|
|
@@ -109,7 +107,6 @@ homepage: https://github.com/xavierholt/twemproxy_exporter
|
|
|
109
107
|
licenses:
|
|
110
108
|
- Apache-2.0
|
|
111
109
|
metadata: {}
|
|
112
|
-
post_install_message:
|
|
113
110
|
rdoc_options: []
|
|
114
111
|
require_paths:
|
|
115
112
|
- lib
|
|
@@ -124,9 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
124
121
|
- !ruby/object:Gem::Version
|
|
125
122
|
version: '0'
|
|
126
123
|
requirements: []
|
|
127
|
-
|
|
128
|
-
rubygems_version: 2.6.8
|
|
129
|
-
signing_key:
|
|
124
|
+
rubygems_version: 3.6.9
|
|
130
125
|
specification_version: 4
|
|
131
126
|
summary: A Prometheus exporter for Twemproxy / Nutcracker.
|
|
132
127
|
test_files: []
|