lib/storage: properly hanle regexp tag filters with dots, which can be converted to full string match filters.

For example `{label=~"foo\.bar"}` should be converted to `{label="foo.bar"}`. Previously it has was mistakenly conveted to `{label="foo\.bar"}` .
This could result in missing time series for such tag filters.
This commit is contained in:
Aliaksandr Valialkin 2021-02-14 23:34:13 +02:00
parent f85c2f052f
commit 9e3993c585
3 changed files with 5 additions and 2 deletions

View File

@ -10,6 +10,7 @@
* FEATURE: vmauth: add ability to route requests from a single user to multiple destinations depending on the requested paths. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1064 * FEATURE: vmauth: add ability to route requests from a single user to multiple destinations depending on the requested paths. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1064
* FEATURE: remove dependency on external programs such as `cat`, `grep` and `cut` when detecting cpu and memory limits inside Docker or LXC container. * FEATURE: remove dependency on external programs such as `cat`, `grep` and `cut` when detecting cpu and memory limits inside Docker or LXC container.
* BUGFIX: properly convert regexp tag filters containing escaped dots to non-regexp tag filters. For example, `{foo=~"bar\.baz"}` should be converted to `{foo="bar.baz"}`. Previously it was incorrectly converted to `{foo="bar\.baz"}`, which could result in missing time series for this tag filter.
* BUGFIX: do not spam error logs when discovering Docker Swarm targets without dedicated IP. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1028 . * BUGFIX: do not spam error logs when discovering Docker Swarm targets without dedicated IP. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1028 .
* BUGFIX: properly embed timezone data into VictoriaMetrics apps. This should fix `-loggerTimezone` usage inside Docker containers. * BUGFIX: properly embed timezone data into VictoriaMetrics apps. This should fix `-loggerTimezone` usage inside Docker containers.
* BUGFIX: properly build Docker images for non-amd64 architectures (arm, arm64, ppc64le, 386) on [Docker hub](https://hub.docker.com/u/victoriametrics/). Previously these images were incorrectly based on amd64 base image, so they didn't work. * BUGFIX: properly build Docker images for non-amd64 architectures (arm, arm64, ppc64le, 386) on [Docker hub](https://hub.docker.com/u/victoriametrics/). Previously these images were incorrectly based on amd64 base image, so they didn't work.

View File

@ -49,7 +49,7 @@ func convertToCompositeTagFilters(tfs *TagFilters) *TagFilters {
} }
continue continue
} }
if string(tf.key) == "__graphite__" { if string(tf.key) == "__graphite__" || bytes.Equal(tf.key, graphiteReverseTagKey) {
tfsNew = append(tfsNew, tf) tfsNew = append(tfsNew, tf)
continue continue
} }
@ -385,6 +385,7 @@ func (tf *tagFilter) Init(commonPrefix, key, value []byte, isNegative, isRegexp
if tf.isRegexp { if tf.isRegexp {
prefix, expr = getRegexpPrefix(tf.value) prefix, expr = getRegexpPrefix(tf.value)
if len(expr) == 0 { if len(expr) == 0 {
tf.value = append(tf.value[:0], prefix...)
tf.isRegexp = false tf.isRegexp = false
} }
} }

View File

@ -985,8 +985,9 @@ func TestTagFiltersString(t *testing.T) {
mustAdd("tag_re", "re.value", false, true) mustAdd("tag_re", "re.value", false, true)
mustAdd("tag_nre", "nre.value", true, true) mustAdd("tag_nre", "nre.value", true, true)
mustAdd("tag_n", "n_value", true, false) mustAdd("tag_n", "n_value", true, false)
mustAdd("tag_re_graphite", "foo\\.bar", false, true)
s := tfs.String() s := tfs.String()
sExpected := `AccountID=12, ProjectID=34 {__name__="metric_name", tag_re=~"re.value", tag_nre!~"nre.value", tag_n!="n_value"}` sExpected := `AccountID=12, ProjectID=34 {__name__="metric_name", tag_re=~"re.value", tag_nre!~"nre.value", tag_n!="n_value", tag_re_graphite="foo.bar"}`
if s != sExpected { if s != sExpected {
t.Fatalf("unexpected TagFilters.String(); got %q; want %q", s, sExpected) t.Fatalf("unexpected TagFilters.String(); got %q; want %q", s, sExpected)
} }