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 Monitoring Input Plugin #3674

Merged
merged 9 commits into from
Jan 26, 2018
Merged

Conversation

mjs
Copy link
Contributor

@mjs mjs commented Jan 16, 2018

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:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

levex and others added 6 commits January 16, 2018 11:28
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.
@mjs mjs mentioned this pull request Jan 16, 2018
3 tasks
@levex
Copy link

levex commented Jan 16, 2018

Thanks @mjs for taking this over!

@danielnelson danielnelson added this to the 1.6.0 milestone Jan 16, 2018
}
url.Path = path.Join(url.Path, "varz")

client := n.createHTTPClient()
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"routes": stats.Routes,
"remotes": stats.Remotes,
},
map[string]string{"nats_server": n.Server},
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return err
}

acc.AddFields("nats_varz",
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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{
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

mjs added 2 commits January 22, 2018 00:12
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
@mjs
Copy link
Contributor Author

mjs commented Jan 21, 2018

@danielnelson All feedback addressed. PTAL.

@danielnelson danielnelson merged commit fb947e8 into influxdata:master Jan 26, 2018
@mjs mjs deleted the nats-collector branch January 28, 2018 11:14
maxunt pushed a commit that referenced this pull request Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants