forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Metricbeat] Move statsd metricbeat module to GA (elastic#16447)
* Update docs * Add system test * Update changelog (cherry picked from commit c6701dd)
- Loading branch information
Showing
11 changed files
with
139 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,32 @@ | ||
For manual testing and development of this module, start metricbeat with the standard configuration for the module: | ||
### Development | ||
|
||
``` | ||
------------------------------------------------------------------------------ | ||
Run metricbeat locally with configured `statsd` module: | ||
|
||
```yaml | ||
- module: statsd | ||
metricsets: ["server"] | ||
host: "localhost" | ||
port: "8125" | ||
enabled: true | ||
#ttl: "30s" | ||
------------------------------------------------------------------------------ | ||
``` | ||
|
||
Look for a log line to this effect: | ||
``` | ||
Started listening for UDP on: 127.0.0.1:8125 | ||
``` | ||
|
||
Use favorite statsd client to emit metrics, e.g.: | ||
|
||
then use a statsd client to test the features. In an empty directory do the following: | ||
|
||
``` | ||
```bash | ||
$ npm install statsd-client | ||
$ node | ||
> var SDC = require('statsd-client'), | ||
sdc = new SDC({host: 'localhost', port: 8125}); | ||
``` | ||
|
||
> sdc.increment('systemname.subsystem.value'); // Increment by one | ||
> sdc.gauge('what.you.gauge', 100); | ||
> sdc.gaugeDelta('what.you.gauge', -70); // Will now count 50 | ||
> sdc.gauge('gauge.with.tags', 100, {foo: 'bar'}); | ||
> sdc.set('set.with.tags', 100, {foo: 'bar'}); | ||
> sdc.set('set.with.tags', 200, {foo: 'bar'}); | ||
> sdc.set('set.with.tags', 100, {foo: 'baz'}); | ||
.... | ||
Emit some metrics: | ||
|
||
<CTRL+D> | ||
```javascript | ||
let SDC = require('statsd-client'), sdc = new SDC({host: 'localhost', port: 8125}); | ||
sdc.increment('systemname.subsystem.value'); | ||
sdc.gauge('what.you.gauge', 100); | ||
sdc.gaugeDelta('what.you.gauge', -70); | ||
sdc.gauge('gauge.with.tags', 100, {foo: 'bar'}); | ||
sdc.set('set.with.tags', 100, {foo: 'bar'}); | ||
sdc.set('set.with.tags', 200, {foo: 'bar'}); | ||
sdc.set('set.with.tags', 100, {foo: 'baz'}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,35 @@ | ||
The Statsd module is a Metricbeat module which opens a UDP port and listens for statsd metrics. | ||
The `statsd` module is a Metricbeat module which spawns a UDP server and listens for metrics in StatsD compatible | ||
format. | ||
|
||
[float] | ||
=== Metric types | ||
|
||
The module supports the following types of metrics: | ||
|
||
*Counter (c)*:: Measurement which accumulates over period of time until flushed (value set to 0). | ||
|
||
*Gauge (g)*:: Measurement which can increase, decrease or be set to a value. | ||
|
||
*Timer (ms)*:: Time measurement (in milliseconds) of an event. | ||
|
||
*Histogram (h)*:: Time measurement, alias for timer. | ||
|
||
*Set (s)*:: Measurement which counts unique occurrences until flushed (value set to 0). | ||
|
||
[float] | ||
=== Module-specific configuration notes | ||
|
||
The `statsd` module has these additional config options: | ||
|
||
*`ttl`*:: It defines how long a metric will be reported after it was last recorded. | ||
Irrespective of the given ttl, metrics will be reported at least once. | ||
A ttl of zero means metrics will never expire. | ||
|
||
[float] | ||
=== Metricsets | ||
|
||
Currently, there is only `server` metricset in `statsd` module. | ||
|
||
[float] | ||
==== `server` | ||
The metricset collects metric data sent using UDP and publishes them under the `statsd` prefix. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 2 additions & 16 deletions
18
x-pack/metricbeat/module/statsd/server/_meta/docs.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,3 @@ | ||
This is the server metricset of the statsd module. | ||
|
||
Events sent to the stats endpoint will be put by default under the `statsd` prefix. | ||
|
||
_ttl_ defines how long a metric will be reported after it was last recorded. | ||
Irrespective of the given ttl, metrics will be reported at least once. | ||
A ttl of zero means metrics will never expire. | ||
|
||
["source","yaml",subs="attributes"] | ||
------------------------------------------------------------------------------ | ||
- module: statsd | ||
metricsets: ["server"] | ||
host: "localhost" | ||
port: "8125" | ||
#ttl: "30s" | ||
------------------------------------------------------------------------------ | ||
[role="xpack"] | ||
|
||
This is the `server` metricset of the `statsd` module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
- release: beta | ||
- release: ga |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
import socket | ||
import sys | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) | ||
from xpack_metricbeat import XPackTest, metricbeat | ||
|
||
STATSD_HOST = '127.0.0.1' | ||
STATSD_PORT = 8125 | ||
|
||
METRIC_MESSAGE = bytes('metric1:777.0|g|#k1:v1,k2:v2', 'utf-8') | ||
|
||
|
||
class Test(XPackTest): | ||
|
||
def test_server(self): | ||
""" | ||
statsd server metricset test | ||
""" | ||
|
||
# Start the application | ||
self.render_config_template(modules=[{ | ||
"name": "statsd", | ||
"metricsets": ["server"], | ||
"period": "5s", | ||
"host": STATSD_HOST, | ||
"port": STATSD_PORT, | ||
}]) | ||
proc = self.start_beat() | ||
self.wait_until(lambda: self.log_contains("Started listening for UDP")) | ||
|
||
# Send UDP packet with metric | ||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
sock.sendto(METRIC_MESSAGE, (STATSD_HOST, STATSD_PORT)) | ||
sock.close() | ||
|
||
self.wait_until(lambda: self.output_lines() > 0) | ||
proc.check_kill_and_wait() | ||
self.assert_no_logged_warnings(replace='use of closed network connection') | ||
|
||
# Verify output | ||
output = self.read_output_json() | ||
self.assertGreater(len(output), 0) | ||
evt = output[0] | ||
assert evt["statsd"]["metric1"]["value"] == 777 | ||
self.assert_fields_are_documented(evt) |