${'{x="yy", bar!="baz"}'}|${'do not add duplicate labels'}|${'bar'}|${'!='}|${'baz'}|${'{x="yy", bar!="baz"}'}
${'rate({bar="baz"}[1m])'}|${'do not add duplicate labels'}|${'bar'}|${'='}|${'baz'}|${'rate({bar="baz"}[1m])'}
${'{list="a,b,c", bar="baz"}'}|${'do not add duplicate labels'}|${'bar'}|${'='}|${'baz'}|${'{list="a,b,c", bar="baz"}'}
${'avg(rate({bar="baz"} [$__interval]))+ sum(rate({bar="baz"}[5m]))'}|${'do not add duplicate labels'}|${'bar'}|${'='}|${'baz'}|${'avg(rate({bar="baz"} [$__interval]))+ sum(rate({bar="baz"}[5m]))'}
${'{x="y"} |="yy"'}|${'do not remove filters'}|${'bar'}|${'='}|${'baz'}|${'{x="y", bar="baz"} |="yy"'}
${'{x="y"} |="yy" !~"xx"'}|${'do not remove filters'}|${'bar'}|${'='}|${'baz'}|${'{x="y", bar="baz"} |="yy" !~"xx"'}
${'{x="y"} or {}'}|${'metric with logical operators'}|${'bar'}|${'='}|${'baz'}|${'{x="y", bar="baz"} or {bar="baz"}'}
${'{x="y"} and {}'}|${'metric with logical operators'}|${'bar'}|${'='}|${'baz'}|${'{x="y", bar="baz"} and {bar="baz"}'}
${'sum(rate({job="foo"}[2m])) by (value $variable)'}|${'template variables'}|${'bar'}|${'='}|${'baz'}|${'sum(rate({job="foo", bar="baz"}[2m])) by (value $variable)'}
${'rate({x="y"}[${__range_s}s])'}|${'metric query with range grafana variable'}|${'bar'}|${'='}|${'baz'}|${'rate({x="y", bar="baz"}[${__range_s}s])'}
${'max by (id, name, type) ({type=~"foo|bar|baz-test"}) * on(id) group_right(id, type, name) sum by (id) (rate({} [5m])) * 1000'}|${'metric query with labels in label list with the group modifier'}|${'bar'}|${'='}|${'baz'}|${'max by (id, name, type) ({type=~"foo|bar|baz-test", bar="baz"}) * on(id) group_right(id, type, name) sum by (id) (rate({bar="baz"}[5m])) * 1000'}
${'{foo="bar"} | logfmt'}|${'query with parser'}|${'bar'}|${'='}|${'baz'}|${'{foo="bar"} | logfmt | bar=`baz`'}
${'{x="yy", bar!="baz"}'}|${'do not add duplicate labels'}|${'bar'}|${'!='}|${'baz'}|${'{x="yy", bar!="baz"}'}
${'rate({bar="baz"}[1m])'}|${'do not add duplicate labels'}|${'bar'}|${'='}|${'baz'}|${'rate({bar="baz"}[1m])'}
${'{list="a,b,c", bar="baz"}'}|${'do not add duplicate labels'}|${'bar'}|${'='}|${'baz'}|${'{list="a,b,c", bar="baz"}'}
${'avg(rate({bar="baz"} [$__interval]))+ sum(rate({bar="baz"}[5m]))'}|${'do not add duplicate labels'}|${'bar'}|${'='}|${'baz'}|${'avg(rate({bar="baz"} [$__interval]))+ sum(rate({bar="baz"}[5m]))'}
${'{x="y"} |="yy"'}|${'do not remove filters'}|${'bar'}|${'='}|${'baz'}|${'{x="y", bar="baz"} |="yy"'}
${'{x="y"} |="yy" !~"xx"'}|${'do not remove filters'}|${'bar'}|${'='}|${'baz'}|${'{x="y", bar="baz"} |="yy" !~"xx"'}
${'{x="y"} or {}'}|${'metric with logical operators'}|${'bar'}|${'='}|${'baz'}|${'{x="y", bar="baz"} or {bar="baz"}'}
${'{x="y"} and {}'}|${'metric with logical operators'}|${'bar'}|${'='}|${'baz'}|${'{x="y", bar="baz"} and {bar="baz"}'}
${'sum(rate({job="foo"}[2m])) by (value $variable)'}|${'template variables'}|${'bar'}|${'='}|${'baz'}|${'sum(rate({job="foo", bar="baz"}[2m])) by (value $variable)'}
${'rate({x="y"}[${__range_s}s])'}|${'metric query with range grafana variable'}|${'bar'}|${'='}|${'baz'}|${'rate({x="y", bar="baz"}[${__range_s}s])'}
${'max by (id, name, type) ({type=~"foo|bar|baz-test"}) * on(id) group_right(id, type, name) sum by (id) (rate({} [5m])) * 1000'}|${'metric query with labels in label list with the group modifier'}|${'bar'}|${'='}|${'baz'}|${'max by (id, name, type) ({type=~"foo|bar|baz-test", bar="baz"}) * on(id) group_right(id, type, name) sum by (id) (rate({bar="baz"}[5m])) * 1000'}
${'{foo="bar"} | logfmt'}|${'query with parser'}|${'bar'}|${'='}|${'baz'}|${'{foo="bar"} | logfmt | bar=`baz`'}
${'{foo="bar"} | logfmt | line_format "{{.status}}"'}|${'do not add filter to line_format expressions in query with parser'}|${'bar'}|${'='}|${'baz'}|${'{foo="bar"} | logfmt | bar=`baz` | line_format "{{.status}}"'}
${'{foo="bar"} | logfmt | line_format "{{status}}"'}|${'do not add filter to line_format expressions in query with parser'}|${'bar'}|${'='}|${'baz'}|${'{foo="bar"} | logfmt | bar=`baz` | line_format "{{status}}"'}
${'{}'}|${'query without stream selector'}|${'bar'}|${'='}|${'baz'}|${'{bar="baz"}'}
${'{} | logfmt'}|${'query without stream selector and with parser'}|${'bar'}|${'='}|${'baz'}|${'{bar="baz"}| logfmt'}
${'{} | x="y"'}|${'query without stream selector and with label filter'}|${'bar'}|${'='}|${'baz'}|${'{bar="baz"}| x="y"'}
${'{} | logfmt | x="y"'}|${'query without stream selector and with parser and label filter'}|${'bar'}|${'='}|${'baz'}|${'{bar="baz"}| logfmt | x="y"'}
${'sum(rate({x="y"} [5m])) + sum(rate({} | logfmt [5m]))'}|${'metric query with 1 empty and 1 not empty stream selector with parser'}|${'bar'}|${'='}|${'baz'}|${'sum(rate({x="y", bar="baz"} [5m])) + sum(rate({bar="baz"}| logfmt [5m]))'}
${'sum(rate({x="y"} | logfmt [5m])) + sum(rate({} [5m]))'}|${'metric query with 1 non-empty and 1 not empty stream selector with parser'}|${'bar'}|${'='}|${'baz'}|${'sum(rate({x="y", bar="baz"} | logfmt [5m])) + sum(rate({bar="baz"}[5m]))'}
${'{x="yy"}'}|${'simple query with escaped value'}|${'bar'}|${'='}|${'"baz"'}|${'{x="yy", bar=""baz""}'}
${'{x="yy"}'}|${'simple query with escaped value'}|${'bar'}|${'='}|${'\\"baz\\"'}|${'{x="yy", bar="\\"baz\\""}'}
${'{x="yy"}'}|${'simple query with an other escaped value'}|${'bar'}|${'='}|${'baz\\\\'}|${'{x="yy", bar="baz\\\\"}'}
${'{x="yy"}'}|${'simple query with escaped value and regex operator'}|${'bar'}|${'~='}|${'baz\\\\'}|${'{x="yy", bar~="baz\\\\"}'}
${'{foo="bar"} | logfmt'}|${'query with parser with escaped value'}|${'bar'}|${'='}|${'\\"baz\\"'}|${'{foo="bar"} | logfmt | bar=`"baz"`'}
${'{foo="bar"} | logfmt'}|${'query with parser with an other escaped value'}|${'bar'}|${'='}|${'baz\\\\'}|${'{foo="bar"} | logfmt | bar=`baz\\`'}
${'{foo="bar"} | logfmt'}|${'query with parser with escaped value and regex operator'}|${'bar'}|${'~='}|${'\\"baz\\"'}|${'{foo="bar"} | logfmt | bar~=`"baz"`'}
${'{foo="bar"} | logfmt'}|${'query with parser with escaped value and regex operator'}|${'bar'}|${'~='}|${'\\"baz\\"'}|${'{foo="bar"} | logfmt | bar~=`"baz"`'}
`(
'should add label to query: $query, description: $description',