Skip to content
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

Nats module improvements #22445

Merged
merged 20 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Map cloud data filed `cloud.account.id` to azure subscription. {pull}21483[21483] {issue}21381[21381]
- Move s3_daily_storage and s3_request metricsets to use cloudwatch input. {pull}21703[21703]
- Duplicate system.process.cmdline field with process.command_line ECS field name. {pull}22325[22325]
- Add connection and route details for nats metricbeat module. {pull}22445[22445]

*Packetbeat*

Expand Down
222 changes: 222 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35491,6 +35491,120 @@ type: integer

--

*`nats.connections.name`*::
+
--
The name of the connection


type: keyword

--

*`nats.connections.subscriptions`*::
+
--
The number of subscriptions in this connection


type: integer

--

*`nats.connections.pending_bytes`*::
+
--
The number of pending bytes of this connection


type: long

format: bytes

--

*`nats.connections.uptime`*::
+
--
The period the connection is up (sec)


type: long

format: duration

--

*`nats.connections.idle_time`*::
+
--
The period the connection is idle (sec)


type: long

format: duration

--

[float]
=== in

The amount of incoming data



*`nats.connections.in.messages`*::
+
--
The amount of incoming messages


type: long

--

*`nats.connections.in.bytes`*::
+
--
The amount of incoming bytes


type: long

format: bytes

--

[float]
=== out

The amount of outgoing data



*`nats.connections.out.messages`*::
+
--
The amount of outgoing messages


type: long

--

*`nats.connections.out.bytes`*::
+
--
The amount of outgoing bytes


type: long

format: bytes

--

[float]
=== routes

Expand All @@ -35508,6 +35622,114 @@ type: integer

--

*`nats.routes.subscriptions`*::
+
--
The number of subscriptions in this connection


type: integer

--

*`nats.routes.remote_id`*::
+
--
The remote id on which the route is connected to


type: keyword

--

*`nats.routes.pending_size`*::
+
--
The number of pending routes


type: long

--

*`nats.routes.port`*::
+
--
The port of the route


type: integer

--

*`nats.routes.ip`*::
+
--
The ip of the route


type: ip

--

[float]
=== in

The amount of incoming data



*`nats.routes.in.messages`*::
+
--
The amount of incoming messages


type: long

--

*`nats.routes.in.bytes`*::
+
--
The amount of incoming bytes


type: long

format: bytes

--

[float]
=== out

The amount of outgoing data



*`nats.routes.out.messages`*::
+
--
The amount of outgoing messages


type: long

--

*`nats.routes.out.bytes`*::
+
--
The amount of outgoing bytes


type: long

format: bytes

--

[float]
=== stats

Expand Down
7 changes: 7 additions & 0 deletions metricbeat/module/nats/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
ARG NATS_VERSION=2.0.4
FROM nats:$NATS_VERSION

# build stage
FROM golang:1.13-alpine3.11 AS build-env
RUN apk --no-cache add build-base git mercurial gcc
RUN cd src && go get -d github.com/nats-io/nats.go/
RUN cd src/github.com/nats-io/nats.go/examples/nats-bench && git checkout tags/v1.10.0 && go build .

# create an enhanced container with nc command available since nats is based
# on scratch image making healthcheck impossible
FROM alpine:latest
COPY --from=0 / /opt/nats
COPY --from=build-env /go/src/github.com/nats-io/nats.go/examples/nats-bench/nats-bench /nats-bench
COPY run.sh /run.sh
# Expose client, management, and cluster ports
EXPOSE 4222 8222 6222
Expand Down
16 changes: 14 additions & 2 deletions metricbeat/module/nats/_meta/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@

# NATS 2.X
if [ -x /opt/nats/nats-server ]; then
exec /opt/nats/nats-server -c /opt/nats/nats-server.conf
if [[ -z "${ROUTES}" ]]; then
exec /opt/nats/nats-server --cluster nats://0.0.0.0:6222 --http_port 8222 --port 4222
else
(/opt/nats/nats-server --cluster nats://0.0.0.0:6222 --http_port 8222 --port 4222 --routes nats://nats:6222) &
sleep 2
while true; do /nats-bench -np 1 -n 100000000 -ms 16 foo; done
fi
fi

# NATS 1.X
if [ -x /opt/nats/gnatsd ]; then
exec /opt/nats/gnatsd -c /opt/nats/gnatsd.conf
if [[ -z "${ROUTES}" ]]; then
ChrsMark marked this conversation as resolved.
Show resolved Hide resolved
exec /opt/nats/gnatsd --cluster nats://0.0.0.0:6222 --http_port 8222 --port 4222
else
(/opt/nats/gnatsd --cluster nats://0.0.0.0:6222 --http_port 8222 --port 4222 --routes nats://nats:6222) &
sleep 2
while true; do /nats-bench -np 1 -n 100000000 -ms 16 foo; done
ChrsMark marked this conversation as resolved.
Show resolved Hide resolved
fi
fi

echo "Couldn't find the nats server binary"
Expand Down
19 changes: 16 additions & 3 deletions metricbeat/module/nats/connections/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,26 @@
"name":"connections",
"rtt":44269
},
"nats":{
"nats": {
"server": {
"id": "bUAdpRFtMWddIBWw80Yd9D",
"time": "2018-12-28T12:33:53.026865597Z"
},
"connections":{
"total": 10
"connections": {
"idle_time": 0,
"in": {
"bytes": 678867264,
"messages": 42429204
},
"name": "NATS Benchmark",
"out": {
"bytes": 0,
"messages": 0
},
"pending_bytes": 0,
"subscriptions": 0,
"total": 1,
"uptime": 29
}
},
"type":"metricsets"
Expand Down
51 changes: 51 additions & 0 deletions metricbeat/module/nats/connections/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,54 @@
type: integer
description: >
The number of currently active clients
- name: name
type: keyword
description: >
The name of the connection
- name: subscriptions
type: integer
description: >
The number of subscriptions in this connection
- name: pending_bytes
type: long
format: bytes
description: >
The number of pending bytes of this connection
- name: uptime
type: long
format: duration
description: >
The period the connection is up (sec)
- name: idle_time
type: long
format: duration
description: >
The period the connection is idle (sec)
- name: in
type: group
description: >
The amount of incoming data
fields:
- name: messages
type: long
description: >
The amount of incoming messages
- name: bytes
type: long
format: bytes
description: >
The amount of incoming bytes
- name: out
type: group
description: >
The amount of outgoing data
fields:
- name: messages
type: long
description: >
The amount of outgoing messages
- name: bytes
type: long
format: bytes
description: >
The amount of outgoing bytes
Loading