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

add metric for max_conns of upstream servers #201

Merged
merged 5 commits into from
Sep 23, 2021
Merged

add metric for max_conns of upstream servers #201

merged 5 commits into from
Sep 23, 2021

Conversation

byoda
Copy link

@byoda byoda commented Jun 23, 2021

Proposed changes

This adds a metric called 'limit' for upstream HTTP and TCP/UDP servers representing the max_conns parameter for the upstream server.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING guide
  • I have proven my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have ensured the README is up to date
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch on my own fork

collector/nginx_plus.go Outdated Show resolved Hide resolved
@lucacome lucacome added the enhancement Pull requests for new features/feature enhancements label Jul 2, 2021
@pleshakov pleshakov self-requested a review July 7, 2021 21:11
@@ -292,6 +293,7 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
streamUpstreamServerMetrics: map[string]*prometheus.Desc{
"state": newStreamUpstreamServerMetric(namespace, "state", "Current state", streamUpstreamServerVariableLabelNames, constLabels),
"active": newStreamUpstreamServerMetric(namespace, "active", "Active connections", streamUpstreamServerVariableLabelNames, constLabels),
"limit": newStreamUpstreamServerMetric(namespace, "limit", "Limit for connections", streamUpstreamServerVariableLabelNames, constLabels),
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @StevenHessing Thanks for the PR!

Could you possibly make the following changes for consistency? (here and for the stream metrics and the doc page) In the other metrics, we basically reuse the names that are in the NGINX Plus API, so the new metric stands out.

(the code will also need to be reformatted after applying the suggestion)

Suggested change
"limit": newStreamUpstreamServerMetric(namespace, "limit", "Limit for connections", streamUpstreamServerVariableLabelNames, constLabels),
"max_conns": newStreamUpstreamServerMetric(namespace, "max_conns", "Max_conns limit for connections", streamUpstreamServerVariableLabelNames, constLabels),

Copy link
Author

Choose a reason for hiding this comment

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

I have considered that. I settled on limit because that is what is shown in the Nginx+ dashboard and allows users to correlate this metric with what they see in the dashboard. The max_conns however is what is in the API and in the nginx upstream configuration. Please confirm what you prefer and I'll make any change necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense.

However, let's make sure we document that the limit still reflects the max_conns parameter. Additionally, better to mention that 0 means no limit.

Could you update the doc string to the following?
"Limit for connections which corresponds to the max_conns parameter of the upstream server. Zero value means there is no limit"

Copy link
Author

Choose a reason for hiding this comment

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

I have updated the docstrings

Here is a Grafana formula we use for our systems:
topk(8,sum by (upstream) (nginxplus_upstream_server_active{env="$environment", site="$site"}) / sum by (upstream) (nginxplus_upstream_server_limit{env="$environment", site="$site"}))

Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

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

Hi @StevenHessing
Thanks for the update 👍 . Just small consistency suggestions for docs.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Co-authored-by: Michael Pleshakov <pleshakov@users.noreply.github.com>
@lucacome lucacome enabled auto-merge (squash) September 23, 2021 18:00
@lucacome
Copy link
Member

Merging this, thanks @StevenHessing !

@lucacome lucacome merged commit bf1c2c9 into nginxinc:master Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Pull requests for new features/feature enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants