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

introduce metrics for object discovery #24

Merged
merged 3 commits into from
Jun 21, 2022
Merged

introduce metrics for object discovery #24

merged 3 commits into from
Jun 21, 2022

Conversation

rlankfo
Copy link
Member

@rlankfo rlankfo commented Jun 16, 2022

This is a start on collecting some metrics for object discovery; currently only covers duration and total counts.

@rlankfo rlankfo requested a review from marctc June 16, 2022 02:33
vsphere/endpoint.go Show resolved Hide resolved
m.datacenters = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "vmx",
Subsystem: "discovery",
Name: "datacenter_count",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename this to datacenter_total in case that we change to a counter?

Copy link
Member Author

Choose a reason for hiding this comment

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

See the above comment. datacenter_total seems like a good name for a metric that increments each time we discover a datacenter (even if it's the same datacenters each time). In that case, I'd need to decide what to name the metrics for last discovery totals only.

Help: "Count of datastores discovered during last object discovery.",
})

m.duration = prometheus.NewHistogram(prometheus.HistogramOpts{
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also add histograms/timers to count the time than different getObjects methods take?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is a good idea 👍

m.duration = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: "vmx",
Subsystem: "discovery",
Name: "duration",
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 a best practice here usually is add the unit (is it seconds? or millis?)

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be seconds, I'll update this.

// create http server
topMux := http.NewServeMux()
topMux.Handle(cfg.TelemetryPath, newHandler(log.With(logger, "component", "handler"), registry))
if cfg.EnableMetaMetrics {
topMux.Handle("/-/metrics", newHandler(log.With(logger, "component", "meta_handler"), mReg))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a common practice? why not expose the meta metrics in the same endpoint/registry?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this is common practice, I was on the fence about this. The reason I decided to move this to a different endpoint is the case we have customers testing internally, they may not be comfortable forwarding their vsphere metrics back to Grafana cloud for us to analyze as labels will likely eventually contain things like hostnames. The alternative could be to use relabel_configs which drop vsphere_* metrics and only send us over the meta metrics.

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 using another registry it's fine but we can use the same handler: https://github.com/prometheus/node_exporter/blob/master/node_exporter.go#L136

Copy link
Contributor

Choose a reason for hiding this comment

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

they may not be comfortable forwarding their vsphere metrics back to Grafana cloud for us to analyze as labels will likely eventually contain things like hostnames

Integration code could have different behavior but I think exporter should export meta metrics in the same handler

@CLAassistant
Copy link

CLAassistant commented Jun 16, 2022

CLA assistant check
All committers have signed the CLA.

@rlankfo rlankfo merged commit 6e09fd3 into main Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants