mirror of https://github.com/grafana/loki
Validate labels in the distributor. (#251)
Also, make ErrOutOfOrder a HTTP 4xx error and continue to append even when we encourter an out of order entry. Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>pull/268/head
parent
071ea04240
commit
ab4c5bebab
@ -0,0 +1,24 @@ |
||||
package util |
||||
|
||||
import ( |
||||
"github.com/cortexproject/cortex/pkg/ingester/client" |
||||
"github.com/cortexproject/cortex/pkg/util/wire" |
||||
"github.com/grafana/loki/pkg/parser" |
||||
) |
||||
|
||||
// ToClientLabels parses the labels and converts them to the Cortex type.
|
||||
func ToClientLabels(labels string) ([]client.LabelPair, error) { |
||||
ls, err := parser.Labels(labels) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
pairs := make([]client.LabelPair, 0, len(ls)) |
||||
for i := 0; i < len(ls); i++ { |
||||
pairs = append(pairs, client.LabelPair{ |
||||
Name: wire.Bytes(ls[i].Name), |
||||
Value: wire.Bytes(ls[i].Value), |
||||
}) |
||||
} |
||||
return pairs, nil |
||||
} |
||||
Loading…
Reference in new issue