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

Fixes #191: crash on empty metric name #192

Merged
merged 4 commits into from
Mar 26, 2019
Merged

Conversation

ivanizag
Copy link
Contributor

Avoids crashing when escaping empty metric names.
The metrics are ignored and a message is logged.

@matthiasr

Copy link
Contributor

@matthiasr matthiasr left a comment

Choose a reason for hiding this comment

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

Thank you! This looks great so far, I only have a few requests for improving the observability of this case.

exporter.go Outdated
@@ -333,6 +333,10 @@ func (b *Exporter) handleEvent(event Event) {
metricName := ""
prometheusLabels := event.Labels()
if present {
if mapping.Name == "" {
log.Debugf("The mapping for match \"%v\" generates an empty metric name.", mapping.Match)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also add a metric to track this. On line 255 we are already (mis)using the eventStats counter to track negative increments, but I think it would be better if you set up a new metric vector for event errors, and also changed the negative-counter to use it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, please also add event.MetricName() to the log line, this will make it much easier to track down what input causes this.

@ivanizag
Copy link
Contributor Author

This should be it. Tests for the telemetry counters could be cleaner but I don't know a way to reset them between tests.

Signed-off-by: Ivan Izaguirre <[email protected]>
@matthiasr
Copy link
Contributor

Wonderful, thank you very much!

@matthiasr matthiasr merged commit 035a309 into prometheus:master Mar 26, 2019
matthiasr pushed a commit that referenced this pull request Mar 26, 2019
add note about the metric change.
matthiasr pushed a commit that referenced this pull request May 15, 2019
* [CHANGE] Do not run as root in the Docker container by default ([#202](#202))
* [FEATURE] Add metric for count of events by action ([#193](#193))
* [FEATURE] Add metric for count of distinct metric names ([#200](#200))
* [FEATURE] Add UNIX socket listener support ([#199](#199))
* [FEATURE] Accept Datadog [distributions](https://docs.datadoghq.com/graphing/metrics/distributions/) ([#211](#211))
* [ENHANCEMENT] Add a health check to the Docker container ([#182](#182))
* [ENHANCEMENT] Allow inconsistent label sets ([#194](#194))
* [ENHANCEMENT] Speed up sanitization of metric names ([#197](#197))
* [ENHANCEMENT] Enable pprof endpoints ([#205](#205))
* [ENHANCEMENT] DogStatsD tag parsing is faster ([#210](#210))
* [ENHANCEMENT] Cache mapped metrics ([#198](#198))
* [BUGFIX] Fix panic if a mapping resulted in an empty name ([#192](#192))
* [BUGFIX] Ensure that there are always default quantiles if using summaries ([#212](#212))
* [BUGFIX] Prevent ingesting conflicting metric types that would make scraping fail ([#213](#213))

With #192, the count of events rejected because of negative counter increments has moved into the `statsd_exporter_events_error_total` metric, instead of being lumped in with the different kinds of successful events.

Signed-off-by: Matthias Rampke <[email protected]>
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.

2 participants