sensu-extensions-statsd 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -22
- data/README.md +44 -12
- data/lib/sensu/extensions/statsd.rb +63 -32
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f29a535c461792227243d4fb537d64d1caa4b6ce
|
4
|
+
data.tar.gz: 591c81f2cc090ff22f206395928a120fa72b376e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8308e1dfd68422cd8bf1ca99735a053dc7ae0b080852361cf86490d46f3cdb85cae364746605cb74917896b73f588199c5e5ee0bdd9caf4c61f203f98e81fc0
|
7
|
+
data.tar.gz: 41505c23361ae902a5874f12b8e8adabcd02339a92fdd09cb6800e6b0cfe9dd965fdc7ad13cc9c398e30af875743aef0924d548e848fad98bd6f83b25f8d672b
|
data/CHANGELOG.md
CHANGED
@@ -1,30 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
|
3
|
+
## [Unreleased](https://github.com/sensu-extensions/sensu-extensions-statsd/tree/HEAD)
|
4
4
|
|
5
|
-
|
5
|
+
[Full Changelog](https://github.com/sensu-extensions/sensu-extensions-statsd/compare/v0.0.1...HEAD)
|
6
6
|
|
7
|
-
|
7
|
+
**Merged pull requests:**
|
8
8
|
|
9
|
-
|
9
|
+
- Adhere to Etsy's specifications and behaviour [\#4](https://github.com/sensu-extensions/sensu-extensions-statsd/pull/4) ([portertech](https://github.com/portertech))
|
10
|
+
- Fix gauge implementation [\#3](https://github.com/sensu-extensions/sensu-extensions-statsd/pull/3) ([corro](https://github.com/corro))
|
10
11
|
|
11
|
-
|
12
|
+
## [v0.0.1](https://github.com/sensu-extensions/sensu-extensions-statsd/tree/v0.0.1) (2016-12-09)
|
12
13
|
|
13
|
-
### Changed
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
### Fixed
|
18
|
-
|
19
|
-
### Added
|
20
|
-
|
21
|
-
### Changed
|
22
|
-
|
23
|
-
## 0.0.1 - 2016-01-31
|
24
|
-
|
25
|
-
### Added
|
26
|
-
|
27
|
-
- Initial release.
|
28
|
-
|
29
|
-
[Unreleased]: https://github.com/sensu-extensions/sensu-extensions-template/compare/v1.0.0...HEAD
|
30
|
-
[1.0.0]: https://github.com/sensu-extensions/sensu-extensions-template/compare/v0.0.1...v1.0.0
|
15
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
@@ -5,10 +5,19 @@ creates a StatsD TCP & UDP listener, receives StatsD metrics, parses
|
|
5
5
|
them, and flushes them to the Graphite plaintext format for Sensu to
|
6
6
|
send to Graphite or another TSDB.
|
7
7
|
|
8
|
+
This StatsD implementation attempts to adhere to [Etsy's metric type
|
9
|
+
specifications](https://github.com/etsy/statsd/blob/master/docs/metric_types.md).
|
10
|
+
|
11
|
+
[![Build Status](https://travis-ci.org/sensu-extensions/sensu-extensions-statsd.svg?branch=master)](https://travis-ci.org/sensu/sensu-extensions-statsd)
|
12
|
+
|
8
13
|
## Installation
|
9
14
|
|
15
|
+
This extension requires Sensu version >= 0.26.
|
16
|
+
|
17
|
+
On a Sensu client machine.
|
18
|
+
|
10
19
|
```
|
11
|
-
sensu-install -e statsd
|
20
|
+
sensu-install -e statsd:1.0.0
|
12
21
|
```
|
13
22
|
|
14
23
|
Edit `/etc/sensu/conf.d/extensions.json` to load it.
|
@@ -17,12 +26,18 @@ Edit `/etc/sensu/conf.d/extensions.json` to load it.
|
|
17
26
|
{
|
18
27
|
"extensions": {
|
19
28
|
"statsd": {
|
20
|
-
"version": "0.0
|
29
|
+
"version": "1.0.0"
|
21
30
|
}
|
22
31
|
}
|
23
32
|
}
|
24
33
|
```
|
25
34
|
|
35
|
+
Restart the Sensu client.
|
36
|
+
|
37
|
+
``` shell
|
38
|
+
sudo service sensu-client restart
|
39
|
+
```
|
40
|
+
|
26
41
|
## Configuration
|
27
42
|
|
28
43
|
Edit `/etc/sensu/conf.d/statsd.json` to change its configuration.
|
@@ -35,14 +50,31 @@ Edit `/etc/sensu/conf.d/statsd.json` to change its configuration.
|
|
35
50
|
}
|
36
51
|
```
|
37
52
|
|
38
|
-
|
53
|
+
The following defaults make the integration behave like Etsy's StatsD
|
54
|
+
implementation.
|
55
|
+
|
56
|
+
|attribute|type|default|description|
|
39
57
|
|----|----|----|---|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
58
|
+
|bind|string|"127.0.0.1"|IP to bind the StatsD sockets to|
|
59
|
+
|port|integer|8125|Port to bind the StatsD sockets to|
|
60
|
+
|flush_interval|integer|10|The StatsD flush interval|
|
61
|
+
|send_interval|integer|30|How often Graphite metrics are sent to Sensu|
|
62
|
+
|percentile|integer|90|The percentile to calculate for StatsD metrics|
|
63
|
+
|add_client_prefix|boolean|true|If the Sensu client name should prefix the Graphite metric path|
|
64
|
+
|path_prefix|string|"statsd"|The optional Graphite metric path prefix (after client name)|
|
65
|
+
|add_path_prefix|boolean|true|If the path_prefix should be used|
|
66
|
+
|delete_gauges|boolean|false|If gauges that have not been updated should be deleted instead of flushed|
|
67
|
+
|delete_counters|boolean|false|If counters with a value of 0 should be deleted instead of flushed|
|
68
|
+
|delete_timers|boolean|false|If timers with a count of 0 should be deleted instead of flushed|
|
69
|
+
|reset_gauges|boolean|false|If gauges should be reset to 0 after flushing|
|
70
|
+
|reset_counters|boolean|true|If counters should be reset to 0 after flushing|
|
71
|
+
|reset_timers|boolean|true|If timers should be reset/cleared after flushing|
|
72
|
+
|handler|string|"graphite"|Handler to use for the Graphite metrics|
|
73
|
+
|
74
|
+
## Example
|
75
|
+
|
76
|
+
Test the StatsD TCP socket:
|
77
|
+
|
78
|
+
``` shell
|
79
|
+
echo "orders:1|c" | nc 127.0.0.1 8125
|
80
|
+
```
|
@@ -27,6 +27,12 @@ module Sensu
|
|
27
27
|
:flush_interval => 10,
|
28
28
|
:send_interval => 30,
|
29
29
|
:percentile => 90,
|
30
|
+
:delete_gauges => false,
|
31
|
+
:delete_counters => false,
|
32
|
+
:delete_timers => false,
|
33
|
+
:reset_gauges => false,
|
34
|
+
:reset_counters => true,
|
35
|
+
:reset_timers => true,
|
30
36
|
:add_client_prefix => true,
|
31
37
|
:path_prefix => "statsd",
|
32
38
|
:add_path_prefix => true,
|
@@ -71,6 +77,19 @@ module Sensu
|
|
71
77
|
|
72
78
|
private
|
73
79
|
|
80
|
+
def clean(hash, delete=false, reset=false)
|
81
|
+
if delete
|
82
|
+
hash.delete_if do |key, value|
|
83
|
+
value == 0 || value == []
|
84
|
+
end
|
85
|
+
end
|
86
|
+
if reset
|
87
|
+
hash.each do |key, value|
|
88
|
+
hash[key] = (value.is_a?(Array) ? [] : 0)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
74
93
|
def add_metric(*args)
|
75
94
|
value = args.pop
|
76
95
|
path = []
|
@@ -94,36 +113,42 @@ module Sensu
|
|
94
113
|
|
95
114
|
def flush!
|
96
115
|
@gauges.each do |name, value|
|
97
|
-
|
116
|
+
unless value == 0 && options[:delete_gauges]
|
117
|
+
add_metric("gauges", name, value)
|
118
|
+
end
|
98
119
|
end
|
99
|
-
@gauges
|
120
|
+
clean(@gauges, options[:delete_gauges], options[:reset_gauges])
|
100
121
|
@counters.each do |name, value|
|
101
|
-
|
122
|
+
unless value == 0 && options[:delete_counters]
|
123
|
+
add_metric("counters", name, value.to_i)
|
124
|
+
end
|
102
125
|
end
|
103
|
-
@counters
|
126
|
+
clean(@counters, options[:delete_counters], options[:reset_counters])
|
104
127
|
@timers.each do |name, values|
|
105
|
-
values.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
128
|
+
unless values.empty? && options[:delete_timers]
|
129
|
+
values.sort!
|
130
|
+
length = values.length
|
131
|
+
min = values.first || 0
|
132
|
+
max = values.last || 0
|
133
|
+
mean = min
|
134
|
+
max_at_threshold = min
|
135
|
+
percentile = options[:percentile]
|
136
|
+
if length > 1
|
137
|
+
threshold_index = ((100 - percentile) / 100.0) * length
|
138
|
+
threshold_count = length - threshold_index.round
|
139
|
+
valid_values = values.slice(0, threshold_count)
|
140
|
+
max_at_threshold = valid_values[-1]
|
141
|
+
sum = 0
|
142
|
+
valid_values.each { |v| sum += v }
|
143
|
+
mean = sum / valid_values.length
|
144
|
+
end
|
145
|
+
add_metric("timers", name, "lower", min)
|
146
|
+
add_metric("timers", name, "mean", mean)
|
147
|
+
add_metric("timers", name, "upper", max)
|
148
|
+
add_metric("timers", name, "upper_#{percentile}", max_at_threshold)
|
120
149
|
end
|
121
|
-
add_metric("timers", name, "lower", min)
|
122
|
-
add_metric("timers", name, "mean", mean)
|
123
|
-
add_metric("timers", name, "upper", max)
|
124
|
-
add_metric("timers", name, "upper_#{percentile}", max_at_threshold)
|
125
150
|
end
|
126
|
-
@timers
|
151
|
+
clean(@timers, options[:delete_timers], options[:reset_timers])
|
127
152
|
@logger.debug("flushed statsd metrics")
|
128
153
|
end
|
129
154
|
|
@@ -136,17 +161,23 @@ module Sensu
|
|
136
161
|
def setup_parser
|
137
162
|
parser = proc do |data|
|
138
163
|
begin
|
139
|
-
nv, type = data.strip.split("|")
|
140
|
-
name,
|
164
|
+
nv, type, raw_sample = data.strip.split("|")
|
165
|
+
name, raw_value = nv.split(":")
|
166
|
+
value = Float(raw_value)
|
167
|
+
sample = Float(raw_sample ? raw_sample.split("@").last : 1)
|
141
168
|
case type
|
142
169
|
when "g"
|
143
|
-
|
170
|
+
if raw_value.start_with?("+")
|
171
|
+
@gauges[name] += value
|
172
|
+
elsif raw_value.start_with?("-")
|
173
|
+
@gauges[name] -= value.abs
|
174
|
+
else
|
175
|
+
@gauges[name] = value
|
176
|
+
end
|
144
177
|
when /^c/, "m"
|
145
|
-
|
146
|
-
|
147
|
-
@
|
148
|
-
when "ms", "h"
|
149
|
-
@timers[name] << Float(value)
|
178
|
+
@counters[name] += value * (1 / sample)
|
179
|
+
when "ms", "h", "t"
|
180
|
+
@timers[name] << value * (1 / sample)
|
150
181
|
end
|
151
182
|
rescue => error
|
152
183
|
@logger.error("statsd parser error", :error => error.to_s)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-extensions-statsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Extensions and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-extension
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: github_changelog_generator
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Check extension to run a StatsD implementation
|
98
112
|
email:
|
99
113
|
- "<sensu-users@googlegroups.com>"
|