-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 Monitoring Input Plugin #3674
Conversation
Signed-off-by: Levente Kurusa <levex@linux.com>
Now using a custom HTTP transport.
Rename "nats" metric to "nats_varz" to allow for other metrics to be returned in future versions of the plugin.
- include all interesting metrics from `/varz` endpoint - calculate uptime in a more correct way (avoiding test hack) - renamed "cpu_usage" to "cpu" to align with upstream and the "mem" metric.
Thanks @mjs for taking this over! |
plugins/inputs/nats/nats.go
Outdated
} | ||
url.Path = path.Join(url.Path, "varz") | ||
|
||
client := n.createHTTPClient() |
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.
Only create a new http client once and reuse each gather.
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.
Done
plugins/inputs/nats/nats.go
Outdated
"routes": stats.Routes, | ||
"remotes": stats.Remotes, | ||
}, | ||
map[string]string{"nats_server": n.Server}, |
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.
Just call this server, this avoids stutter with measurement name.
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.
Done
plugins/inputs/nats/nats.go
Outdated
return err | ||
} | ||
|
||
acc.AddFields("nats_varz", |
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.
What do you think about just calling this nats? Adding varz could be useful if we anticipate other measurements but is otherwise unneeded IMO.
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.
Ha! It was called nats
originally but on #3186 you suggested using nats_vars
:)
Some of the other measurements that NATS offers through other monitoring endpoints could be useful to expose at some stage (e.g detailed connection & subscription metrics) but right now it's just the high level metrics that are being exposed and there's no need to include "varz" in the name for those.
I'm happy to change it back to just nats
. We can add suffixes for the more detailed stuff.
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 guess this probably means it doesn't matter much, lets just go with what we have.
if timeout == time.Duration(0) { | ||
timeout = 5 * time.Second | ||
} | ||
return &http.Client{ |
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.
Create a new transport to avoid using the default one, all it needs set is Proxy: http.ProxyFromEnvironment
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.
Done
Include the NATS server URL as a tag to allow multiple instances of the nats input plugin to be distinguished.
- Don't use the default Transport - Avoid creating a http.Client each gather
... instead of "nats_varz".
@danielnelson All feedback addressed. PTAL. |
This plugin gathers metrics a NATS server monitoring endpoint. Currently, only the
/varz
endpoint is used. See https://nats.io/documentation/server/gnatsd-monitoring/ for more information.Note that this is a continuation of #3186. The original author isn't working on that PR any more.
Required for all PRs: