@@ -42,7 +42,7 @@ func genGrafanaRenderUrl(grafanaUrl string, grafanaTZ string, org string, dash s
4242 q .Set ("width" , imageWidth )
4343 q .Set ("height" , imageHeight )
4444 q .Set ("tz" , grafanaTZ )
45- u .RawQuery = q . Encode ( )
45+ u .RawQuery = EncodeUrlArgs ( q )
4646 return u .String (), nil
4747
4848}
@@ -64,7 +64,7 @@ func genGrafanaUrl(grafanaUrl string, org string, dash string, panel string) (st
6464 if panel != "" {
6565 q .Set ("viewPanel" , panel )
6666 }
67- u .RawQuery = q . Encode ( )
67+ u .RawQuery = EncodeUrlArgs ( q )
6868 return u .String (), nil
6969}
7070
@@ -83,7 +83,7 @@ func urlMerger(publicUrl string, privateUrl string) (string, error) {
8383 }
8484 q := u .Query ()
8585 q .Set ("pub_secret" , key )
86- u .RawQuery = q . Encode ( )
86+ u .RawQuery = EncodeUrlArgs ( q )
8787
8888 return u .String (), nil
8989}
@@ -192,17 +192,23 @@ func (n *Notifier) formatGrafanaMessage(data *template.Data) slack.Blocks {
192192 for _ , v := range data .CommonLabels .SortedPairs () {
193193 filters = append (filters , fmt .Sprintf ("%s=\" %s\" " , v .Name , v .Value ))
194194 }
195+
195196 args .Add ("filter" , fmt .Sprintf ("{%s}" , strings .Join (filters , "," )))
196- urlParsed .RawQuery = args . Encode ( )
197+ urlParsed .RawQuery = EncodeUrlArgs ( args )
197198 url = urlParsed .String ()
198199 url = strings .Replace (url , "%23" , "#" , 1 )
199200 }
200201
201202 alertEditUrl := ""
202203 for _ , alert := range data .Alerts {
203204 if alert .GeneratorURL != "" {
204- alertEditUrl = alert .GeneratorURL + "?orgId=" + orgId
205- break
205+ if urlParsed , err := url2 .Parse (alert .GeneratorURL ); err == nil {
206+ args := urlParsed .Query ()
207+ args .Add ("orgId" , orgId )
208+ urlParsed .RawQuery = EncodeUrlArgs (args )
209+ alertEditUrl = urlParsed .String ()
210+ break
211+ }
206212 }
207213 }
208214
0 commit comments