Log throughput and total bytes human readable. (#2751)

pull/2651/head
Karsten Jeschkies 5 years ago committed by GitHub
parent c394ce9462
commit 55c768bf8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      pkg/logql/metrics.go
  2. 2
      pkg/logql/metrics_test.go

@ -2,9 +2,11 @@ package logql
import (
"context"
"strings"
"time"
"github.com/cortexproject/cortex/pkg/util"
"github.com/dustin/go-humanize"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
@ -87,8 +89,8 @@ func RecordMetrics(ctx context.Context, p Params, status string, stats stats.Res
"step", p.Step(),
"duration", time.Duration(int64(stats.Summary.ExecTime*float64(time.Second))),
"status", status,
"throughput_mb", float64(stats.Summary.BytesProcessedPerSecond)/1e6,
"total_bytes_mb", float64(stats.Summary.TotalBytesProcessed)/1e6,
"throughput", strings.Replace(humanize.Bytes(uint64(stats.Summary.BytesProcessedPerSecond)), " ", "", 1),
"total_bytes", strings.Replace(humanize.Bytes(uint64(stats.Summary.TotalBytesProcessed)), " ", "", 1),
)
bytesPerSecond.WithLabelValues(status, queryType, rt, latencyType).

@ -72,7 +72,7 @@ func TestLogSlowQuery(t *testing.T) {
})
require.Equal(t,
fmt.Sprintf(
"level=info org_id=foo traceID=%s latency=slow query=\"{foo=\\\"bar\\\"} |= \\\"buzz\\\"\" query_type=filter range_type=range length=1h0m0s step=1m0s duration=25.25s status=200 throughput_mb=0.1 total_bytes_mb=0.1\n",
"level=info org_id=foo traceID=%s latency=slow query=\"{foo=\\\"bar\\\"} |= \\\"buzz\\\"\" query_type=filter range_type=range length=1h0m0s step=1m0s duration=25.25s status=200 throughput=100kB total_bytes=100kB\n",
sp.Context().(jaeger.SpanContext).SpanID().String(),
),
buf.String())

Loading…
Cancel
Save