Query with "OR" returns partial matches


I have data say -
data1, data2, data3, …data9, data10, data11, data12, data13, …data19, data20 and so on
When I select just one of this say data1 in the query, I get the desired result. But when I select 2 or more of this, say data1 and data2, I get the output for everything that starts with data1 like data1, data10, data11, data12, data13,… data19. How can I just get what I selected ?

Query looks like instance =~ /data1 | data2/
Version - 1.2.2


By default, regular expressions match anywhere in a string. When you write /data1/, it will match data1 exactly and anything containing it as a substring, e.g. foo_data1, data1_bar, ABCdata123, etc.

If you use the start and end anchors, you can match exactly. That syntax would be /^data1$/ where ^ indicates the start of the string and $ indicates the end of the string. If you want to match multiple, distinct strings, use a parenthesized subgroup, which looks like: /^(data1|data2)$/.

You’ll probably find it helpful to go through some regular expression tutorials online. InfluxDB’s regular expression syntax is the same as Go’s regular expression syntax, which is pretty standard. Anything you read about regular expressions is likely to apply.