Skip to content

Error querying Prometheus: bad_data: cannot parse "" to a valid timestamp #801

Closed
@kayrosik

Description

@kayrosik

This is part of my function QueryRange:

	start := time.Now()
	end := now.Add(time.Duration(-config.Prometheus.MetricsTimeRange) * time.Minute)
        resolution := math.Max(math.Floor(end.Sub(start).Seconds()/250), 1)
	step := time.Duration(resolution * 1e9)

	v1api := v1.NewAPI(client)
	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
	defer cancel()
	r := v1.Range{
		Start: start,
		End:   end,
		Step:  step,
	}
	result, warnings, err := v1api.QueryRange(ctx, metric, r)

I use trickster + prometheus(Thanos).
When I try to call the function, I get:
Error querying Prometheus: bad_data: cannot parse "" to a valid timestamp

And I can't understand why it can be (

I change DoGetFallback function (always HTTP-Get):

	resp, body, warnings, err := h.Do(ctx, req)
	u.RawQuery = args.Encode()
	req, err = http.NewRequest(http.MethodGet, u.String(), nil)
	if err != nil {
		return nil, nil, warnings, err
	}
	return h.Do(ctx, req)

And it works! The problem is POST-request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions