mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
Add dash / and at @ signs escapes in regex (#32495)
This commit is contained in:
parent
009df4fb7a
commit
270a255c08
@ -18,7 +18,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
legendFormat = regexp.MustCompile(`\[\[([\w-]+)(\.[\w-]+)*\]\]*|\$\s*([\w-]+?)*`)
|
||||
legendFormat = regexp.MustCompile(`\[\[([\@\/\w-]+)(\.[\@\/\w-]+)*\]\]*|\$\s*([\@\/\w-]+?)*`)
|
||||
}
|
||||
|
||||
func (rp *ResponseParser) Parse(response *Response, query *Query) plugins.DataQueryResult {
|
||||
|
@ -70,6 +70,8 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
||||
"datacenter": "America",
|
||||
"dc.region.name": "Northeast",
|
||||
"cluster-name": "Cluster",
|
||||
"/cluster/name/": "Cluster/",
|
||||
"@cluster@name@": "Cluster@",
|
||||
},
|
||||
Values: [][]interface{}{
|
||||
{json.Number("111"), json.Number("222"), json.Number("333")},
|
||||
@ -141,6 +143,16 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
||||
result = parser.Parse(response, query)
|
||||
|
||||
require.Equal(t, result.Series[0].Name, "alias Cluster")
|
||||
|
||||
query = &Query{Alias: "alias [[tag_/cluster/name/]]"}
|
||||
result = parser.Parse(response, query)
|
||||
|
||||
require.Equal(t, result.Series[0].Name, "alias Cluster/")
|
||||
|
||||
query = &Query{Alias: "alias [[tag_@cluster@name@]]"}
|
||||
result = parser.Parse(response, query)
|
||||
|
||||
require.Equal(t, result.Series[0].Name, "alias Cluster@")
|
||||
})
|
||||
|
||||
t.Run("Influxdb response parser with errors", func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user