Skip to content

Commit

Permalink
Log throughput and total bytes human readable. (#2751)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeschkies authored Nov 4, 2020
1 parent c394ce9 commit 55c768b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pkg/logql/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion pkg/logql/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 55c768b

Please sign in to comment.