-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Metricbeat] Move statsd metricbeat module to GA #16447
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
976b7d9
Update docs
9146e6f
Update docs
05e3ebf
Add system test
7713b12
Update changelog
a9afea3
Fix: missing options
33c213b
Fix docs, extract development section to README
3618351
Fix: double section
90e6607
Merge branch 'master' into 14280-statsd-ga
mtojek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 was deleted.
Oops, something went wrong.
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,79 @@ | ||
The Statsd module is a Metricbeat module which opens a UDP port and listens for statsd metrics. | ||
[role="xpack"] | ||
== Statsd module | ||
|
||
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] | ||
=== Configuration options | ||
|
||
This module has some configuration options for controlling its behavior. The | ||
following example shows all configuration options. | ||
|
||
[source,yaml] | ||
---- | ||
- module: statsd | ||
metricsets: ["server"] | ||
host: "localhost" | ||
port: "8125" | ||
#ttl: "30s" | ||
---- | ||
|
||
This module also supports the | ||
<<module-standard-options-{modulename},standard configuration options>> | ||
described later. | ||
|
||
*`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. | ||
|
||
include::{docdir}/metricbeat-options.asciidoc[] | ||
|
||
[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. | ||
|
||
[float] | ||
=== Development | ||
|
||
Run metricbeat locally with configured `statsd` module. Use favorite statsd client to emit metrics, e.g.: | ||
|
||
[source,shell script] | ||
---- | ||
$ npm install statsd-client | ||
$ node | ||
---- | ||
|
||
Emit some metrics: | ||
|
||
[source,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
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) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think development notes should be in a
README.md
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.