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

NET-10124: Add metrics endpoint and labels to sync catalog deployment #4212

Merged
merged 2 commits into from
Aug 29, 2024

Conversation

NiniOak
Copy link
Contributor

@NiniOak NiniOak commented Jul 26, 2024

Changes proposed in this PR

  • Add metrics endpoints to scrape metrics from sync catalog deployment
  • Add labels to monitor register, deregistered and errors syncing K8s services to Consul

How I've tested this PR

How I expect reviewers to test this PR

Checklist

@NiniOak NiniOak added backport/1.2.x This release branch is no longer active. backport/1.3.x backport/1.4.x backport/1.5.x pr/no-changelog PR does not need a corresponding .changelog entry labels Jul 26, 2024
@NiniOak NiniOak requested review from a team, jm96441n and wangxinyi7 and removed request for a team August 2, 2024 02:01
@NiniOak NiniOak marked this pull request as ready for review August 12, 2024 21:01
@NiniOak NiniOak removed the pr/no-changelog PR does not need a corresponding .changelog entry label Aug 12, 2024

if c.prometheusSink == nil {
c.logger.Error("Prometheus sink not initialized, metrics cannot be displayed")
c.prometheusSink = &prometheus.PrometheusSink{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need this to not throw a nil pointer error. Happy to remove

Copy link
Member

Choose a reason for hiding this comment

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

will this condition ever not be nil? the default for a pointer field is nil and I don't see where we're setting this so I'd assume we always fall into this block right?

Copy link
Contributor Author

@NiniOak NiniOak Aug 20, 2024

Choose a reason for hiding this comment

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

We set this value on L522, there was was nil pointer errors in testing so I put this there, I'll remove it cos it's not a condition I see us hitting in production.

Copy link
Member

Choose a reason for hiding this comment

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

oh nah I think it's a valid check, what I mean is there ever a case where this would actually be set? to me it seems like this will always be nil and need to be set

Copy link
Contributor Author

@NiniOak NiniOak Aug 20, 2024

Choose a reason for hiding this comment

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

No it won't be nil, recordMetrics() returns prometheus.PrometheusSink which we assign to this field. So c.prometheusSink value will only be nil if recordMetrics() returns an error(as we just log create metrics sink error and continue running feature). Let's chat if you need further explanation

@NiniOak NiniOak added pr/no-backport signals that a PR will not contain a backport label and removed backport/1.5.x labels Aug 20, 2024
}

// authorizeMiddleware validates the token and returns http handler.
func (c *Command) authorizeMiddleware() func(http.Handler) http.Handler {
Copy link
Member

Choose a reason for hiding this comment

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

is this doing anything yet or is this a placeholder for when we implement auth?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a placeholder for now

Copy link
Member

@nathancoleman nathancoleman left a comment

Choose a reason for hiding this comment

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

Some thoughts just looking through the code. Spending some time this afternoon tinkering with the new metrics in Grafana. Exciting stuff, great work!

.changelog/4212.txt Outdated Show resolved Hide resolved
charts/consul/templates/sync-catalog-deployment.yaml Outdated Show resolved Hide resolved
control-plane/catalog/to-k8s/sink.go Outdated Show resolved Hide resolved
control-plane/catalog/to-k8s/sink.go Outdated Show resolved Hide resolved
control-plane/catalog/to-consul/syncer.go Outdated Show resolved Hide resolved
control-plane/catalog/to-consul/syncer.go Outdated Show resolved Hide resolved
control-plane/catalog/to-consul/syncer.go Show resolved Hide resolved
control-plane/subcommand/common/metrics_util.go Outdated Show resolved Hide resolved
@NiniOak NiniOak merged commit a02fd53 into main Aug 29, 2024
50 checks passed
@NiniOak NiniOak deleted the NET-10361 branch August 29, 2024 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/no-backport signals that a PR will not contain a backport label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants