-
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
Nginx Plus stats #2405
Nginx Plus stats #2405
Conversation
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. Also what about merging some of the measurements together, such as But again, this is just my personal thoughts. I'm not a maintainer, so they should not be construed as requirements. :-) |
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? |
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? |
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'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.
plugins/inputs/nginx/nginxplus.go
Outdated
Bytes int64 `json:"bytes"` | ||
ResponsesWritten int64 `json:"responses_written"` | ||
BytesWritten int64 `json:"bytes_written"` | ||
} `json:"bypass"` |
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'd like to see all of the anonymous structs here that have responses and bytes using a shared stuct.
plugins/inputs/nginx/nginxplus.go
Outdated
Responses4xx int64 `json:"4xx"` | ||
Responses5xx int64 `json:"5xx"` | ||
Total int64 `json:"total"` | ||
} `json:"responses"` |
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.
The Responses struct here could probably be extracted to a named struct.
plugins/inputs/nginx/nginxplus.go
Outdated
Fails int64 `json:"fails"` | ||
Unhealthy int64 `json:"unhealthy"` | ||
LastPassed *bool `json:"last_passed"` | ||
} `json:"health_checks"` |
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.
The HealthCheck struct also appears in another location.
plugins/inputs/nginx/nginxplus.go
Outdated
|
||
func (s *Status) gatherProcessesMetrics(tags map[string]string, acc telegraf.Accumulator) { | ||
acc.AddFields( | ||
"nginx.processes", |
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.
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.
plugins/inputs/nginx/nginxplus.go
Outdated
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 | ||
*/ |
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.
This comment would go into the new nginxplus README
Hi @danielnelson. Thanks for the review. Please let me know if this one looks better. |
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.
Looks good, but would still like to see it as a new plugin.
plugins/inputs/nginx/nginxplus.go
Outdated
Sessions3xx int64 `json:"3xx"` | ||
Sessions4xx int64 `json:"4xx"` | ||
Sessions5xx int64 `json:"5xx"` | ||
} `json:"sessions"` |
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 think this can be a HttpResponsesStats
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.
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 |
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.
Does this need to be a pointer since it is not in version 1?
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.
It's completely absent from version 1
} `json:"queue"` | ||
} `json:"upstreams"` | ||
|
||
Caches map[string]struct { // added in version 2 |
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.
Does this need to be a pointer since it is not in version 1?
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.
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) |
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.
How does someone know what version they have? Does this plugin support all versions?
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.
We can probably cover all the version by linking to https://nginx.org/en/docs/http/ngx_http_status_module.html#compatibility
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.
The plugin supports all versions. Version is sent in the very first attribute.
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. |
Please make it a new plugin |
Hey @mplonka - can I help in any way get this plugin separated out into a separate plugin? |
Hello, Is there anything I can do to get this separated out into a separate plugin? |
@poblahblahblah Could you fork @mplonka's code and update the plugin per the review? |
@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 :) |
I think they should probably be completely independent. I didn't see much shared code, is there something specific you are looking at? |
Added in #3214 |
Retrieves Nginx Plus stats from "stats" module.