Skip to content

Commit

Permalink
[Metricbeat] Add STAN (NATS streaming) module (#14839)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrsMark authored Dec 13, 2019
1 parent fb4dd37 commit 10c741a
Show file tree
Hide file tree
Showing 47 changed files with 5,564 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix timezone parsing in haproxy pipeline. {pull}14755[14755]
- Add module for ActiveMQ. {pull}14840[14840]
- Add dashboards for the ActiveMQ Filebeat module. {pull}14880[14880]
- Add STAN Metricbeat module. {pull}14839[14839]

*Heartbeat*
- Add non-privileged icmp on linux and darwin(mac). {pull}13795[13795] {issue}11498[11498]
Expand Down
13 changes: 7 additions & 6 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ func GoTest(ctx context.Context, params GoTestArgs) error {
fmt.Println(">> go test:", params.TestName, "Testing")

// Build args list to Go.
args := []string{"test", "-v"}
args := []string{"test"}
if mg.Verbose() {
args = append(args, "-v")
}
if params.Race {
args = append(args, "-race")
}
Expand All @@ -123,9 +126,7 @@ func GoTest(ctx context.Context, params GoTestArgs) error {
// Wire up the outputs.
bufferOutput := new(bytes.Buffer)
outputs := []io.Writer{bufferOutput}
if mg.Verbose() {
outputs = append(outputs, os.Stdout)
}

if params.OutputFile != "" {
fileOutput, err := os.Create(createDir(params.OutputFile))
if err != nil {
Expand All @@ -135,8 +136,8 @@ func GoTest(ctx context.Context, params GoTestArgs) error {
outputs = append(outputs, fileOutput)
}
output := io.MultiWriter(outputs...)
goTest.Stdout = output
goTest.Stderr = output
goTest.Stdout = io.MultiWriter(output, os.Stdout)
goTest.Stderr = io.MultiWriter(output, os.Stderr)

// Execute 'go test' and measure duration.
start := time.Now()
Expand Down
256 changes: 256 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ grouped in the following categories:
* <<exported-fields-rabbitmq>>
* <<exported-fields-redis>>
* <<exported-fields-sql>>
* <<exported-fields-stan>>
* <<exported-fields-statsd>>
* <<exported-fields-system>>
* <<exported-fields-tomcat>>
Expand Down Expand Up @@ -29518,6 +29519,261 @@ type: object
--
[[exported-fields-stan]]
== Stan fields
stan Module
[float]
=== stan
`stan` contains statistics that were read from Nats Streaming server (STAN)
*`stan.server.id`*::
+
--
The server ID
type: keyword
--
*`stan.cluster.id`*::
+
--
The cluster ID
type: keyword
--
[float]
=== channels
Contains stan / nats streaming/serverz endpoint metrics
*`stan.channels.name`*::
+
--
The name of the STAN streaming channel
type: keyword
--
*`stan.channels.messages`*::
+
--
The number of STAN streaming messages
type: long
--
*`stan.channels.bytes`*::
+
--
The number of STAN bytes in the channel
type: long
--
*`stan.channels.first_seq`*::
+
--
First sequence number stored in the channel. If first_seq > min([seq in subscriptions]) data loss has possibly occurred
type: long
--
*`stan.channels.last_seq`*::
+
--
Last sequence number stored in the channel
type: long
--
*`stan.channels.depth`*::
+
--
Queue depth based upon current sequence number and highest reported subscriber sequence number
type: long
--
[float]
=== stats
Contains only high-level stan / nats streaming server related metrics
*`stan.stats.state`*::
+
--
The cluster / streaming configuration state (STANDALONE, CLUSTERED)
type: keyword
--
*`stan.stats.role`*::
+
--
If clustered, role of this node in the cluster (Leader, Follower, Candidate)
type: keyword
--
*`stan.stats.clients`*::
+
--
The number of STAN clients
type: integer
--
*`stan.stats.subscriptions`*::
+
--
The number of STAN streaming subscriptions
type: integer
--
*`stan.stats.channels`*::
+
--
The number of STAN channels
type: integer
--
*`stan.stats.messages`*::
+
--
Number of messages across all STAN queues
type: long
--
*`stan.stats.bytes`*::
+
--
Number of bytes consumed across all STAN queues
type: long
--
[float]
=== subscriptions
Contains stan / nats streaming/serverz endpoint subscription metrics
*`stan.subscriptions.id`*::
+
--
The name of the STAN channel subscription (client_id)
type: keyword
--
*`stan.subscriptions.channel`*::
+
--
The name of the STAN channel the subscription is associated with
type: keyword
--
*`stan.subscriptions.queue`*::
+
--
The name of the NATS queue that the STAN channel subscription is associated with, if any
type: keyword
--
*`stan.subscriptions.last_sent`*::
+
--
Last known sequence number of the subscription that was acked
type: long
--
*`stan.subscriptions.pending`*::
+
--
Number of pending messages from / to the subscriber
type: long
--
*`stan.subscriptions.offline`*::
+
--
Is the subscriber marked as offline?
type: boolean
--
*`stan.subscriptions.stalled`*::
+
--
Is the subscriber known to be stalled?
type: boolean
--
[[exported-fields-statsd]]
== Statsd fields
Expand Down
55 changes: 55 additions & 0 deletions metricbeat/docs/modules/stan.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-module-stan]]
[role="xpack"]
== Stan module

beta[]

This is the STAN module. The STAN module uses https://github.com/nats-io/nats-streaming-server/blob/master/server/monitor.go[STAN monitoring server APIs] to collect metrics.

The default metricsets are `channels`, `stats` and `subscriptions`.

[float]
=== Compatibility

The STAN module is tested with STAN 0.15.1.


[float]
=== Example configuration

The Stan module supports the standard configuration options that are described
in <<configuration-metricbeat>>. Here is an example configuration:

[source,yaml]
----
metricbeat.modules:
- module: stan
metricsets: ["stats", "channels", "subscriptions"]
period: 60s
hosts: ["localhost:8222"]
#stats.metrics_path: "/streaming/serverz"
#channels.metrics_path: "/streaming/channelsz"
#subscriptions.metrics_path: "/streaming/channelsz" # we retrieve streaming subscriptions with a detailed query param to the channelsz endpoint
----

[float]
=== Metricsets

The following metricsets are available:

* <<metricbeat-metricset-stan-channels,channels>>

* <<metricbeat-metricset-stan-stats,stats>>

* <<metricbeat-metricset-stan-subscriptions,subscriptions>>

include::stan/channels.asciidoc[]

include::stan/stats.asciidoc[]

include::stan/subscriptions.asciidoc[]

24 changes: 24 additions & 0 deletions metricbeat/docs/modules/stan/channels.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-metricset-stan-channels]]
=== Stan channels metricset

beta[]

include::../../../../x-pack/metricbeat/module/stan/channels/_meta/docs.asciidoc[]

This is a default metricset. If the host module is unconfigured, this metricset is enabled by default.

==== Fields

For a description of each field in the metricset, see the
<<exported-fields-stan,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../../x-pack/metricbeat/module/stan/channels/_meta/data.json[]
----
Loading

0 comments on commit 10c741a

Please sign in to comment.