diff --git a/tsdb/points.go b/tsdb/points.go index 9a3c97472ee..b8960b6c745 100644 --- a/tsdb/points.go +++ b/tsdb/points.go @@ -62,12 +62,22 @@ var escapeCodes = map[byte][]byte{ '=': []byte(`\=`), } +var escapeCodesFields = map[byte][]byte{ + ',': []byte(`\,`), +} + var escapeCodesStr = map[string]string{} +var escapeCodesStrFields = map[string]string{} + func init() { for k, v := range escapeCodes { escapeCodesStr[string(k)] = string(v) } + + for k, v := range escapeCodesFields { + escapeCodesStrFields[string(k)] = string(v) + } } func ParsePointsString(buf string) ([]Point, error) { @@ -625,6 +635,13 @@ func escapeString(in string) string { return in } +func escapeStringFields(in string) string { + for b, esc := range escapeCodesStrFields { + in = strings.Replace(in, b, esc, -1) + } + return in +} + func unescape(in []byte) []byte { for b, esc := range escapeCodes { in = bytes.Replace(in, esc, []byte{b}, -1) @@ -941,7 +958,7 @@ func (p Fields) MarshalBinary() []byte { b = append(b, t...) case string: b = append(b, '"') - b = append(b, []byte(t)...) + b = append(b, []byte(escapeStringFields(t))...) b = append(b, '"') case nil: // skip