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

[pull] master from netdata:master #246

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [**Next release**](https://github.com/netdata/netdata/tree/HEAD)

[Full Changelog](https://github.com/netdata/netdata/compare/v2.1.0...HEAD)

**Merged pull requests:**

- Regenerate integrations docs [\#19254](https://github.com/netdata/netdata/pull/19254) ([netdatabot](https://github.com/netdatabot))
- docs: fix nats metadata suffix [\#19253](https://github.com/netdata/netdata/pull/19253) ([ilyam8](https://github.com/ilyam8))
- feat\(go.d\): add NATS collector [\#19252](https://github.com/netdata/netdata/pull/19252) ([ilyam8](https://github.com/ilyam8))

## [v2.1.0](https://github.com/netdata/netdata/tree/v2.1.0) (2024-12-19)

[Full Changelog](https://github.com/netdata/netdata/compare/v2.0.3...v2.1.0)
Expand Down Expand Up @@ -448,9 +458,6 @@
- Update windows documentation [\#18703](https://github.com/netdata/netdata/pull/18703) ([Ancairon](https://github.com/Ancairon))
- Detect when swap is disabled when agent is running [\#18702](https://github.com/netdata/netdata/pull/18702) ([stelfrag](https://github.com/stelfrag))
- Bump golang.org/x/net from 0.29.0 to 0.30.0 in /src/go [\#18701](https://github.com/netdata/netdata/pull/18701) ([dependabot[bot]](https://github.com/apps/dependabot))
- Load chart labels on demand [\#18699](https://github.com/netdata/netdata/pull/18699) ([stelfrag](https://github.com/stelfrag))
- Add hyper-v metrics [\#18697](https://github.com/netdata/netdata/pull/18697) ([stelfrag](https://github.com/stelfrag))
- fix system-info disk space in LXC [\#18696](https://github.com/netdata/netdata/pull/18696) ([ilyam8](https://github.com/ilyam8))

## [v1.47.5](https://github.com/netdata/netdata/tree/v1.47.5) (2024-10-24)

Expand Down
2 changes: 1 addition & 1 deletion packaging/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.1.0
v2.1.0-4-nightly
2 changes: 2 additions & 0 deletions src/collectors/COLLECTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ If you don't see the app/service you'd like to monitor in this list:

- [MQTT Blackbox](https://github.com/netdata/netdata/blob/master/src/go/plugin/go.d/collector/prometheus/integrations/mqtt_blackbox.md)

- [NATS](https://github.com/netdata/netdata/blob/master/src/go/plugin/go.d/collector/nats/integrations/nats.md)

- [RabbitMQ](https://github.com/netdata/netdata/blob/master/src/go/plugin/go.d/collector/rabbitmq/integrations/rabbitmq.md)

- [Redis Queue](https://github.com/netdata/netdata/blob/master/src/go/plugin/go.d/collector/prometheus/integrations/redis_queue.md)
Expand Down
9 changes: 5 additions & 4 deletions src/go/plugin/go.d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

All capabilities are set automatically during Netdata installation using the [official installation method](/packaging/installer/methods/kickstart.md).

| Capability | Required by |
|:--------------------|:-------------------------------------------------------------------------------------------------------:|
| Capability | Required by |
|:--------------------|:---------------------------------------------------------------------------------------------------------:|
| CAP_NET_RAW | [Ping](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/ping#readme) |
| CAP_NET_ADMIN | [Wireguard](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/wireguard#readme) |
| CAP_DAC_READ_SEARCH | [Filecheck](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/filecheck#readme) |
Expand All @@ -25,8 +25,8 @@ All capabilities are set automatically during Netdata installation using the [of
<details>
<summary>Data Collection Modules</summary>

| Name | Monitors |
|:-------------------------------------------------------------------------------------------------------------------|:-----------------------------:|
| Name | Monitors |
|:---------------------------------------------------------------------------------------------------------------------|:-----------------------------:|
| [adaptec_raid](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/adaptecraid) | Adaptec Hardware RAID |
| [activemq](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/activemq) | ActiveMQ |
| [ap](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/ap) | Wireless AP |
Expand Down Expand Up @@ -84,6 +84,7 @@ All capabilities are set automatically during Netdata installation using the [of
| [mongoDB](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/mongodb) | MongoDB |
| [monit](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/monit) | Monit |
| [mysql](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/mysql) | MySQL |
| [nats](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/nats) | NATS |
| [nginx](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/nginx) | NGINX |
| [nginxplus](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/nginxplus) | NGINX Plus |
| [nginxunit](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/collector/nginxunit) | NGINX Unit |
Expand Down
1 change: 1 addition & 0 deletions src/go/plugin/go.d/collector/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
_ "github.com/netdata/netdata/go/plugins/plugin/go.d/collector/mongodb"
_ "github.com/netdata/netdata/go/plugins/plugin/go.d/collector/monit"
_ "github.com/netdata/netdata/go/plugins/plugin/go.d/collector/mysql"
_ "github.com/netdata/netdata/go/plugins/plugin/go.d/collector/nats"
_ "github.com/netdata/netdata/go/plugins/plugin/go.d/collector/nginx"
_ "github.com/netdata/netdata/go/plugins/plugin/go.d/collector/nginxplus"
_ "github.com/netdata/netdata/go/plugins/plugin/go.d/collector/nginxunit"
Expand Down
1 change: 1 addition & 0 deletions src/go/plugin/go.d/collector/nats/README.md
161 changes: 161 additions & 0 deletions src/go/plugin/go.d/collector/nats/charts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// SPDX-License-Identifier: GPL-3.0-or-later

package nats

import (
"fmt"

"github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
)

const (
prioServerTraffic = module.Priority + iota
prioServerMessages
prioServerConnectionsCurrent
prioServerConnectionsRate
prioHttpEndpointRequests
prioServerHealthProbeStatus
prioServerCpuUsage
prioServerMemoryUsage
prioServerUptime
)

var serverCharts = func() module.Charts {
charts := module.Charts{
chartServerConnectionsCurrent.Copy(),
chartServerConnectionsRate.Copy(),
chartServerTraffic.Copy(),
chartServerMessages.Copy(),
chartServerHealthProbeStatus.Copy(),
chartServerCpuUsage.Copy(),
chartServerMemUsage.Copy(),
chartServerUptime.Copy(),
}
charts = append(charts, httpEndpointCharts()...)
return charts
}()

var (
chartServerTraffic = module.Chart{
ID: "server_traffic",
Title: "Server Traffic",
Units: "bytes/s",
Fam: "traffic",
Ctx: "nats.server_traffic",
Priority: prioServerTraffic,
Type: module.Area,
Dims: module.Dims{
{ID: "in_bytes", Name: "in", Algo: module.Incremental},
{ID: "out_bytes", Name: "out", Mul: -1, Algo: module.Incremental},
},
}
chartServerMessages = module.Chart{
ID: "server_messages",
Title: "Server Messages",
Units: "messages/s",
Fam: "traffic",
Ctx: "nats.server_messages",
Priority: prioServerMessages,
Dims: module.Dims{
{ID: "in_msgs", Name: "in", Algo: module.Incremental},
{ID: "out_msgs", Name: "out", Mul: -1, Algo: module.Incremental},
},
}
chartServerConnectionsCurrent = module.Chart{
ID: "server_connections_current",
Title: "Server Current Connections",
Units: "connections",
Fam: "connections",
Ctx: "nats.server_connections_current",
Priority: prioServerConnectionsCurrent,
Dims: module.Dims{
{ID: "connections", Name: "active"},
},
}
chartServerConnectionsRate = module.Chart{
ID: "server_connections_rate",
Title: "Server Connections",
Units: "connections/s",
Fam: "connections",
Ctx: "nats.server_connections_rate",
Priority: prioServerConnectionsRate,
Dims: module.Dims{
{ID: "total_connections", Name: "connections", Algo: module.Incremental},
},
}
chartServerHealthProbeStatus = module.Chart{
ID: "server_health_probe_status",
Title: "Server Health Probe Status",
Units: "status",
Fam: "health",
Ctx: "nats.server_health_probe_status",
Priority: prioServerHealthProbeStatus,
Dims: module.Dims{
{ID: "healthz_status_ok", Name: "ok"},
{ID: "healthz_status_error", Name: "error"},
},
}
chartServerCpuUsage = module.Chart{
ID: "server_cpu_usage",
Title: "Server CPU Usage",
Units: "percent",
Fam: "rusage",
Ctx: "nats.server_cpu_usage",
Priority: prioServerCpuUsage,
Type: module.Area,
Dims: module.Dims{
{ID: "cpu", Name: "used"},
},
}
chartServerMemUsage = module.Chart{
ID: "server_mem_usage",
Title: "Server Memory Usage",
Units: "bytes",
Fam: "rusage",
Ctx: "nats.server_mem_usage",
Priority: prioServerMemoryUsage,
Type: module.Area,
Dims: module.Dims{
{ID: "mem", Name: "used"},
},
}
chartServerUptime = module.Chart{
ID: "server_uptime",
Title: "Server Uptime",
Units: "seconds",
Fam: "uptime",
Ctx: "nats.server_uptime",
Priority: prioServerUptime,
Dims: module.Dims{
{ID: "uptime", Name: "uptime"},
},
}
)

func httpEndpointCharts() module.Charts {
var charts module.Charts
for _, path := range httpEndpoints {
chart := httpEndpointRequestsChartTmpl.Copy()
chart.ID = fmt.Sprintf(chart.ID, path)
chart.Labels = []module.Label{
{Key: "http_endpoint", Value: path},
}
for _, dim := range chart.Dims {
dim.ID = fmt.Sprintf(dim.ID, path)
}
charts = append(charts, chart)
}
return charts
}

var httpEndpointRequestsChartTmpl = module.Chart{
ID: "http_endpoint_%s_requests",
Title: "HTTP Endpoint Requests",
Units: "requests/s",
Fam: "http requests",
Ctx: "nats.http_endpoint_requests",
Priority: prioHttpEndpointRequests,
Dims: module.Dims{
{ID: "http_endpoint_%s_req", Name: "requests", Algo: module.Incremental},
},
}
85 changes: 85 additions & 0 deletions src/go/plugin/go.d/collector/nats/collect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// SPDX-License-Identifier: GPL-3.0-or-later

package nats

import (
"fmt"
"net/http"

"github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/metrix"
"github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/web"
)

const (
urlPathVarz = "/varz"
urlPathHealthz = "/healthz"
)

func (c *Collector) collect() (map[string]int64, error) {
mx := make(map[string]int64)

if err := c.collectVarz(mx); err != nil {
return nil, err
}
if err := c.collectHealthz(mx); err != nil {
return nil, err
}

return mx, nil
}

func (c *Collector) collectVarz(mx map[string]int64) error {
// https://docs.nats.io/running-a-nats-service/nats_admin/monitoring#general-information
req, err := web.NewHTTPRequestWithPath(c.RequestConfig, urlPathVarz)
if err != nil {
return err
}

var resp varzResponse
if err := web.DoHTTP(c.httpClient).RequestJSON(req, &resp); err != nil {
return err
}

mx["uptime"] = int64(resp.Now.Sub(resp.Start).Seconds())
mx["in_msgs"] = resp.InMsgs
mx["out_msgs"] = resp.OutMsgs
mx["in_bytes"] = resp.InBytes
mx["out_bytes"] = resp.OutBytes
mx["slow_consumers"] = resp.SlowConsumers
mx["subscriptions"] = int64(resp.Subscriptions)
mx["connections"] = int64(resp.Connections)
mx["total_connections"] = int64(resp.TotalConnections)
mx["routes"] = int64(resp.Routes)
mx["remotes"] = int64(resp.Remotes)
mx["cpu"] = int64(resp.CPU)
mx["mem"] = resp.Mem

for _, path := range httpEndpoints {
v := resp.HTTPReqStats[path]
mx[fmt.Sprintf("http_endpoint_%s_req", path)] = int64(v)
}

return nil
}

func (c *Collector) collectHealthz(mx map[string]int64) error {
// https://docs.nats.io/running-a-nats-service/nats_admin/monitoring#health
req, err := web.NewHTTPRequestWithPath(c.RequestConfig, urlPathHealthz)
if err != nil {
return err
}

var resp healthzResponse
client := web.DoHTTP(c.httpClient).OnNokCode(func(resp *http.Response) (bool, error) { return true, nil })
if err := client.RequestJSON(req, &resp); err != nil {
return err
}
if resp.Status == nil {
return fmt.Errorf("healthz response missing status")
}

mx["healthz_status_ok"] = metrix.Bool(*resp.Status == "ok")
mx["healthz_status_error"] = metrix.Bool(*resp.Status != "ok")

return nil
}
Loading
Loading