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

Negative histogram values are planned? #9

Open
Allineer opened this issue May 12, 2020 · 6 comments
Open

Negative histogram values are planned? #9

Allineer opened this issue May 12, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@Allineer
Copy link

Article: https://medium.com/@valyala/improving-histogram-usability-for-prometheus-and-grafana-bc7e5df0e350

Histogram covers values in the following range: [10-⁹…10¹⁸]

But https://github.com/VictoriaMetrics/metrics/blob/master/histogram.go#L85:

	if math.IsNaN(v) || v < 0 {
		// Skip NaNs and negative values.
		return
	}

Are negative values not yet supported or this restriction will be permanent?
Thanks.

@valyala valyala added the enhancement New feature or request label May 19, 2020
@valyala
Copy link
Contributor

valyala commented May 19, 2020

It is likely this restriction will be permanent, since the most frequently used values for histograms - response times and sizes - are non-negative. There are the following possible workarounds for negative values:

  • To pass absolute values to histograms
  • To shift the value range to positive values by subtracting the low end of the initial range from each value before putting it into histogram

BTW, could you share the use case for negative histogram values?

@Allineer
Copy link
Author

Allineer commented May 20, 2020

@valyala,

We have sensors that transmit deviations of the measurement result from the norm.
Deviations can be in both directions and processing only their absolute values ​​is not enough - we tried this.
We also tried to use two histograms - one for positive deviations, and the second for negative deviations in absolute form.

In both cases, we have lost the information content (информативность).

@valyala
Copy link
Contributor

valyala commented May 21, 2020

Now I see your case. I need to think about how to extend histogram values into negative range. In theory it should be backwards compatible, since buckets for negative values don't intersect with buckets for positive values.

@jareks
Copy link

jareks commented Jul 16, 2021

Any news on this one?

@ashtuchkin
Copy link

This would've been very handy for my use case - I'm trying to get a distribution of ∆t-s which can be both positive and negative, with ~zero expected mean.

If I'd use two metrics, one for positive values and one for negative - can I plot them in a reasonable way on a single chart?

@Joshuaalbert
Copy link

Having suffered from this problem for some time, I'm happy to find a thread that fights to get this feature. (It shouldn't even be considered a feature as far as I'm concerne). We have the same use case as @ashtuchkin, relative values against some other metrics in our system. Also, philosophically speaking, histograms are empirical representations of distributions, and not all distributions have strictly positive support. It seems arbitrary to enforce only strictly positive support is relevant.

Also, from an implementation perspective, can you explain why having negative boundaries even causes a problem? Are you using some kind of unsigned float to represent data? Why would you do that? Surely the observation that most metrics are positive is not enough to generate a requirement that inherently disallows negative numbers. Quite perplexed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants