Skip to content

feat(inputs.prometheus): Add new internal stats on Prometheus gathers#18944

Open
nlgotz wants to merge 3 commits into
influxdata:masterfrom
nlgotz:prom-internal-gather-stats
Open

feat(inputs.prometheus): Add new internal stats on Prometheus gathers#18944
nlgotz wants to merge 3 commits into
influxdata:masterfrom
nlgotz:prom-internal-gather-stats

Conversation

@nlgotz
Copy link
Copy Markdown

@nlgotz nlgotz commented May 19, 2026

Summary

Adds 2 new internal metrics to the Prometheus input plugin.

  • connection_status sets the value to either 0 (connection failed) or 1 (connection succeeded).
  • gathers_total which has a status tag of either success or failure that increments on each gather.

Checklist

Related issues

resolves #18943

@telegraf-tiger
Copy link
Copy Markdown
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger telegraf-tiger Bot added area/prometheus feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels May 19, 2026
@nlgotz
Copy link
Copy Markdown
Author

nlgotz commented May 19, 2026

!signed-cla

Copy link
Copy Markdown
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @nlgotz! Two comments from my side...

Comment thread plugins/inputs/prometheus/prometheus.go Outdated
Comment on lines +535 to +538
urlStr := u.url.String()
connectStat := selfstat.Register("prometheus", "connection_status", map[string]string{"url": urlStr})
gatherSuccess := selfstat.Register("prometheus", "gathers_total", map[string]string{"url": urlStr, "status": "success"})
gatherFailure := selfstat.Register("prometheus", "gathers_total", map[string]string{"url": urlStr, "status": "failure"})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will strip all global tags (e.g. alias). Please implement TSD-011 instead. See `ouputs.influxdb for an example...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will work on that. I was using the inputs.gnmi as a reference

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated to follow TSD-011

Comment thread plugins/inputs/prometheus/prometheus.go Outdated
Comment on lines +537 to +538
gatherSuccess := selfstat.Register("prometheus", "gathers_total", map[string]string{"url": urlStr, "status": "success"})
gatherFailure := selfstat.Register("prometheus", "gathers_total", map[string]string{"url": urlStr, "status": "failure"})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see how this is better than using the existing statistics and enable per_plugin in the internal input plugin...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

When using the per_plugin it still groups all of the URLs together into a single instance which makes it harder when using service discovery (in our case Consul) to determine which url's are working/not working.

@srebhan srebhan self-assigned this May 20, 2026
@telegraf-tiger
Copy link
Copy Markdown
Contributor

@nlgotz nlgotz requested a review from srebhan May 22, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/prometheus feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[inputs.prometheus] Connection Status internal metric

2 participants