@@ -2,21 +2,18 @@ package slackv2
22
33import (
44 "fmt"
5+ "github.com/prometheus/alertmanager/blobstore"
6+ "github.com/prometheus/alertmanager/template"
7+ "github.com/prometheus/common/model"
8+ uuid "github.com/satori/go.uuid"
9+ "github.com/slack-go/slack"
510 "io"
611 "net/http"
712 url2 "net/url"
813 "path"
9- "regexp"
1014 "strconv"
1115 "strings"
1216 "time"
13-
14- "github.com/prometheus/common/model"
15- "github.com/satori/go.uuid"
16- "github.com/slack-go/slack"
17-
18- "github.com/prometheus/alertmanager/blobstore"
19- "github.com/prometheus/alertmanager/template"
2017)
2118
2219func (n * Notifier ) getGrafanaImage (org string , dash string , panel string ) ([]byte , error ) {
@@ -105,9 +102,9 @@ func (n *Notifier) formatGrafanaMessage(data *template.Data) slack.Blocks {
105102 dashboardUid = v .Value
106103 case strings .ToLower ("__panelId__" ):
107104 panelId = v .Value
108- case strings .ToLower ("OrgID " ):
105+ case strings .ToLower ("__orgId__ " ):
109106 orgId = v .Value
110- case strings .ToLower ("__value_string__ " ):
107+ case strings .ToLower ("__values__ " ):
111108 grafanaValues = v .Value
112109 case strings .ToLower ("runbook_url" ):
113110 runBook = v .Value
@@ -217,20 +214,7 @@ func (n *Notifier) formatGrafanaMessage(data *template.Data) slack.Blocks {
217214 block := Block {Type : slack .MBTContext , Elements : make ([]* Element , 0 )}
218215
219216 if (grafanaValues != "[no value]" ) || (grafanaValues != "" ) {
220- regexpForParseMetric := regexp .MustCompile (`(?m) labels={[a-zA-z0-9=:,_@{ -.]+} value=` )
221- valueStringCollection := regexpForParseMetric .ReplaceAllString (grafanaValues , ", value=" )
222- regexpForParseParams := regexp .MustCompile (`(?m)metric='(?P<name>.*)', value=(?P<value>.*)` )
223-
224- grafanaMapParams := make (map [string ]string )
225- for _ , parsedCollection := range strings .Split (valueStringCollection , "], [ " ) {
226- match := regexpForParseParams .FindStringSubmatch (parsedCollection )
227- if len (match ) >= 3 {
228- grafanaMapParams [match [1 ]] = match [2 ]
229- }
230- }
231- if valueStringCollection != "" {
232- block .Elements = append (block .Elements , & Element {Type : slack .MarkdownType , Text : fmt .Sprintf ("*Metric:* %s\n " , valueStringCollection )})
233- }
217+ block .Elements = append (block .Elements , & Element {Type : slack .MarkdownType , Text : fmt .Sprintf ("*Metric:* %s\n " , grafanaValues )})
234218 }
235219
236220 if val := getMapValue (data .CommonAnnotations , "description" ); len (val ) > 0 {
0 commit comments