Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
bf908424
Unverified
Commit
bf908424
authored
Feb 21, 2020
by
Arve Knudsen
Committed by
GitHub
Feb 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alerting: Don't include image_url field with Slack message if empty (#22372)
parent
8c2107cd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
pkg/services/alerting/notifiers/slack.go
+11
-7
No files found.
pkg/services/alerting/notifiers/slack.go
View file @
bf908424
...
@@ -276,22 +276,25 @@ func (sn *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
...
@@ -276,22 +276,25 @@ func (sn *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
},
},
}
}
}
}
body
:=
map
[
string
]
interface
{}{
attachment
:=
map
[
string
]
interface
{}{
"text"
:
evalContext
.
GetNotificationTitle
(),
"blocks"
:
blocks
,
"attachments"
:
[]
map
[
string
]
interface
{}{
{
"color"
:
evalContext
.
GetStateModel
()
.
Color
,
"color"
:
evalContext
.
GetStateModel
()
.
Color
,
"title"
:
evalContext
.
GetNotificationTitle
(),
"title"
:
evalContext
.
GetNotificationTitle
(),
"title_link"
:
ruleURL
,
"title_link"
:
ruleURL
,
"text"
:
msg
,
"text"
:
msg
,
"fallback"
:
evalContext
.
GetNotificationTitle
(),
"fallback"
:
evalContext
.
GetNotificationTitle
(),
"fields"
:
fields
,
"fields"
:
fields
,
"image_url"
:
imageURL
,
"footer"
:
"Grafana v"
+
setting
.
BuildVersion
,
"footer"
:
"Grafana v"
+
setting
.
BuildVersion
,
"footer_icon"
:
"https://grafana.com/assets/img/fav32.png"
,
"footer_icon"
:
"https://grafana.com/assets/img/fav32.png"
,
"ts"
:
time
.
Now
()
.
Unix
(),
"ts"
:
time
.
Now
()
.
Unix
(),
},
}
if
imageURL
!=
""
{
attachment
[
"image_url"
]
=
imageURL
}
body
:=
map
[
string
]
interface
{}{
"text"
:
evalContext
.
GetNotificationTitle
(),
"blocks"
:
blocks
,
"attachments"
:
[]
map
[
string
]
interface
{}{
attachment
,
},
},
"parse"
:
"full"
,
// to linkify urls, users and channels in alert message.
"parse"
:
"full"
,
// to linkify urls, users and channels in alert message.
}
}
...
@@ -313,6 +316,7 @@ func (sn *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
...
@@ -313,6 +316,7 @@ func (sn *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
cmd
:=
&
models
.
SendWebhookSync
{
Url
:
sn
.
URL
,
Body
:
string
(
data
)}
cmd
:=
&
models
.
SendWebhookSync
{
Url
:
sn
.
URL
,
Body
:
string
(
data
)}
if
err
:=
bus
.
DispatchCtx
(
evalContext
.
Ctx
,
cmd
);
err
!=
nil
{
if
err
:=
bus
.
DispatchCtx
(
evalContext
.
Ctx
,
cmd
);
err
!=
nil
{
sn
.
log
.
Error
(
"Failed to send slack notification"
,
"error"
,
err
,
"webhook"
,
sn
.
Name
)
sn
.
log
.
Error
(
"Failed to send slack notification"
,
"error"
,
err
,
"webhook"
,
sn
.
Name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment