Skip to content

Commit

Permalink
fix(mimirtool): Make remote-read actually return data
Browse files Browse the repository at this point in the history
Since #9156 probably, all the remote read commands return no data

I added a missing error return using `timeseries.Err()` and got this error: `mimirtool: error: chunkedReader: message size exceeded the limit 0 bytes; got: 361 bytes, try --help`
which lead me to find that we need to pass in `ChunkedReadLimit` on the client

I set it at a default 1 MiB and configurable through a flag
  • Loading branch information
julienduchesne committed Dec 19, 2024
1 parent aeff3be commit dd418f9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/mimirtool/commands/remote_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"text/tabwriter"
"time"
Expand Down Expand Up @@ -46,9 +47,10 @@ type RemoteReadCommand struct {
readTimeout time.Duration
tsdbPath string

selector string
from string
to string
selector string
from string
to string
readSizeLimit uint64
}

func (c *RemoteReadCommand) Register(app *kingpin.Application, envVars EnvVarNames) {
Expand Down Expand Up @@ -88,6 +90,9 @@ func (c *RemoteReadCommand) Register(app *kingpin.Application, envVars EnvVarNam
cmd.Flag("to", "End of the time window to select metrics.").
Default(now.Format(time.RFC3339)).
StringVar(&c.to)
cmd.Flag("read-size-limit", "Maximum number of bytes to read.").
Default(strconv.Itoa(int(math.Pow(1024, 2)))). // 1MiB
Uint64Var(&c.readSizeLimit)
}

exportCmd.Flag("tsdb-path", "Path to the folder where to store the TSDB blocks, if not set a new directory in $TEMP is created.").
Expand Down Expand Up @@ -200,6 +205,7 @@ func (c *RemoteReadCommand) readClient() (remote.ReadClient, error) {
Password: config_util.Secret(c.apiKey),
},
},
ChunkedReadLimit: c.readSizeLimit,
Headers: map[string]string{
"User-Agent": client.UserAgent(),
},
Expand Down Expand Up @@ -315,6 +321,10 @@ func (c *RemoteReadCommand) dump(_ *kingpin.ParseContext) error {
}
}

if err := timeseries.Err(); err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit dd418f9

Please sign in to comment.