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

Nginx Plus stats #2405

Closed
wants to merge 4 commits into from
Closed

Nginx Plus stats #2405

wants to merge 4 commits into from

Conversation

mplonka
Copy link

@mplonka mplonka commented Feb 14, 2017

Retrieves Nginx Plus stats from "stats" module.

@sparrc sparrc added this to the 1.3.0 milestone Feb 14, 2017
@phemmer
Copy link
Contributor

phemmer commented Feb 14, 2017

Just my own $0.02: The vast majority of the code seems to be mapping of data structures. What fields to look for in the nginx output, and then what fields to pass on, and how to name them.
I would encourage a more programmatic approach. I've been bitten by several plugins in telegraf that use hard-coded field mappings because either a new version of the software was released and telegraf hadn't been updated to support the fields, or the plugin author didn't think the fields were useful.

Also what about merging some of the measurements together, such as nginx.requests, nginx.ssl, nginx.connections and nginx.processes. This way were not overwhelming the user with a bunch of micro-measurements. For some of them they should be kept separate, because there are multiple series (tag permutations), but for the 4 mentioned, there's only one series in all of them.

But again, this is just my personal thoughts. I'm not a maintainer, so they should not be construed as requirements. :-)

@mplonka
Copy link
Author

mplonka commented Feb 14, 2017

Thanks for your comments, PHemmer. I'm happy to modify the code to make it more consistent with other plugins and simplify this data mapping there. Is there any reference plugin that I should use as a reference?

@danielnelson danielnelson modified the milestones: 1.4.0, 1.3.0 Apr 13, 2017
@poblahblahblah
Copy link
Contributor

Hello,

We would like to see nginx+ monitoring in telegraf. What needs to be done to get this revived and merged in? Is there a good reference plugin I can look at to address the comments @phemmer had? Do the telegraf maintainers preferences mirror those comments?

Copy link
Contributor

@danielnelson danielnelson left a comment

Choose a reason for hiding this comment

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

I'm a little more open to this style of parsing, though I agree it would be nice for it to be less code. I think a good first step would be to extract and reuse some of anonymous structs. This might open things up for using more helper functions. I'll comment on some lines where I see this in the code.

The other thing I would like to see is for this to become a standalone plugin since it doesn't really share much code with the nginx plugin, scraps a different plugin, and provides completely different points.

Bytes int64 `json:"bytes"`
ResponsesWritten int64 `json:"responses_written"`
BytesWritten int64 `json:"bytes_written"`
} `json:"bypass"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to see all of the anonymous structs here that have responses and bytes using a shared stuct.

Responses4xx int64 `json:"4xx"`
Responses5xx int64 `json:"5xx"`
Total int64 `json:"total"`
} `json:"responses"`
Copy link
Contributor

Choose a reason for hiding this comment

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

The Responses struct here could probably be extracted to a named struct.

Fails int64 `json:"fails"`
Unhealthy int64 `json:"unhealthy"`
LastPassed *bool `json:"last_passed"`
} `json:"health_checks"`
Copy link
Contributor

Choose a reason for hiding this comment

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

The HealthCheck struct also appears in another location.


func (s *Status) gatherProcessesMetrics(tags map[string]string, acc telegraf.Accumulator) {
acc.AddFields(
"nginx.processes",
Copy link
Contributor

Choose a reason for hiding this comment

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

Anywhere we are using dotted notation should either use snake_case or in some cases the subitems should become tags. I think in this PR all should become snake_case.

This applies to measurement names and field names throughout the pull request.

5. http://web.archive.org/web/20150414043916/http://nginx.org/en/docs/http/ngx_http_status_module.html
6. http://web.archive.org/web/20150918163811/http://nginx.org/en/docs/http/ngx_http_status_module.html
7. http://web.archive.org/web/20161107221028/http://nginx.org/en/docs/http/ngx_http_status_module.html
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment would go into the new nginxplus README

@mplonka
Copy link
Author

mplonka commented Jul 20, 2017

Hi @danielnelson. Thanks for the review. Please let me know if this one looks better.

Copy link
Contributor

@danielnelson danielnelson left a comment

Choose a reason for hiding this comment

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

Looks good, but would still like to see it as a new plugin.

Sessions3xx int64 `json:"3xx"`
Sessions4xx int64 `json:"4xx"`
Sessions5xx int64 `json:"5xx"`
} `json:"sessions"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be a HttpResponsesStats

Copy link
Author

Choose a reason for hiding this comment

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

100%
Renaming this struct to make the name still meaningful in this context

Current int `json:"current"`
} `json:"requests"`

ServerZones map[string]struct { // added in version 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be a pointer since it is not in version 1?

Copy link
Author

Choose a reason for hiding this comment

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

It's completely absent from version 1

} `json:"queue"`
} `json:"upstreams"`

Caches map[string]struct { // added in version 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be a pointer since it is not in version 1?

Copy link
Author

Choose a reason for hiding this comment

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

Same as above: absent from version 1


- [version 6](http://web.archive.org/web/20150918163811/http://nginx.org/en/docs/http/ngx_http_status_module.html)

- [version 7](http://web.archive.org/web/20161107221028/http://nginx.org/en/docs/http/ngx_http_status_module.html)
Copy link
Contributor

Choose a reason for hiding this comment

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

How does someone know what version they have? Does this plugin support all versions?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably cover all the version by linking to https://nginx.org/en/docs/http/ngx_http_status_module.html#compatibility

Copy link
Author

Choose a reason for hiding this comment

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

The plugin supports all versions. Version is sent in the very first attribute.

@mplonka
Copy link
Author

mplonka commented Jul 21, 2017

I do not have strong views on adding Nginx Plus support to this plugin or creating separate one. Keeping it here seems more intuitive for Nginx Plus users though.

@danielnelson
Copy link
Contributor

Please make it a new plugin nginxplus. The reason for this is that it has unique setup and format from the regular nginx so there is little to gain from combining them.

@danielnelson danielnelson modified the milestones: 1.4.0, 1.5.0 Aug 14, 2017
@poblahblahblah
Copy link
Contributor

Hey @mplonka - can I help in any way get this plugin separated out into a separate plugin?

@danielnelson danielnelson added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Aug 24, 2017
@poblahblahblah
Copy link
Contributor

Hello,

Is there anything I can do to get this separated out into a separate plugin?

@danielnelson
Copy link
Contributor

@poblahblahblah Could you fork @mplonka's code and update the plugin per the review?

@poblahblahblah
Copy link
Contributor

@danielnelson Would you like these two plugins to be completely separate? It looks like the current way it's written the nginxplus plugin use a number of functions from the nginx plugin. I can separate these completely or I can just import the existing nginx plugin into nginxplus.

Any guidance would be appreciated :)

@danielnelson
Copy link
Contributor

I think they should probably be completely independent. I didn't see much shared code, is there something specific you are looking at?

@danielnelson
Copy link
Contributor

Added in #3214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin new plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants