rules: Support native histograms
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
parent
3c2ea91a83
commit
53a5071a72
|
@ -31,6 +31,7 @@ import (
|
|||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
|
||||
"github.com/prometheus/prometheus/model/histogram"
|
||||
"github.com/prometheus/prometheus/model/labels"
|
||||
"github.com/prometheus/prometheus/model/rulefmt"
|
||||
"github.com/prometheus/prometheus/model/timestamp"
|
||||
|
@ -668,7 +669,16 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) {
|
|||
}()
|
||||
|
||||
for _, s := range vector {
|
||||
if _, err := app.Append(0, s.Metric, s.T, s.V); err != nil {
|
||||
if s.H != nil {
|
||||
// We assume that all native histogram results are gauge histograms.
|
||||
// TODO(codesome): once PromQL can give the counter reset info, remove this assumption.
|
||||
s.H.CounterResetHint = histogram.GaugeType
|
||||
_, err = app.AppendHistogram(0, s.Metric, s.T, nil, s.H)
|
||||
} else {
|
||||
_, err = app.Append(0, s.Metric, s.T, s.V)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
rule.SetHealth(HealthBad)
|
||||
rule.SetLastError(err)
|
||||
sp.SetStatus(codes.Error, err.Error())
|
||||
|
|
Loading…
Reference in New Issue