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
effd2098
Commit
effd2098
authored
Sep 26, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): fixes broken image renderer
parent
887e236b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
21 deletions
+12
-21
pkg/services/alerting/eval_context.go
+2
-11
pkg/services/alerting/notifier.go
+8
-7
pkg/services/alerting/notifiers/webhook.go
+2
-3
No files found.
pkg/services/alerting/eval_context.go
View file @
effd2098
...
...
@@ -71,7 +71,7 @@ func (c *EvalContext) GetNotificationTitle() string {
return
"["
+
c
.
GetStateModel
()
.
Text
+
"] "
+
c
.
Rule
.
Name
}
func
(
c
*
EvalContext
)
g
etDashboardSlug
()
(
string
,
error
)
{
func
(
c
*
EvalContext
)
G
etDashboardSlug
()
(
string
,
error
)
{
if
c
.
dashboardSlug
!=
""
{
return
c
.
dashboardSlug
,
nil
}
...
...
@@ -86,7 +86,7 @@ func (c *EvalContext) getDashboardSlug() (string, error) {
}
func
(
c
*
EvalContext
)
GetRuleUrl
()
(
string
,
error
)
{
if
slug
,
err
:=
c
.
g
etDashboardSlug
();
err
!=
nil
{
if
slug
,
err
:=
c
.
G
etDashboardSlug
();
err
!=
nil
{
return
""
,
err
}
else
{
ruleUrl
:=
fmt
.
Sprintf
(
"%sdashboard/db/%s?fullscreen&edit&tab=alert&panelId=%d"
,
setting
.
AppUrl
,
slug
,
c
.
Rule
.
PanelId
)
...
...
@@ -94,15 +94,6 @@ func (c *EvalContext) GetRuleUrl() (string, error) {
}
}
func
(
c
*
EvalContext
)
GetImageUrl
()
(
string
,
error
)
{
if
slug
,
err
:=
c
.
getDashboardSlug
();
err
!=
nil
{
return
""
,
err
}
else
{
ruleUrl
:=
fmt
.
Sprintf
(
"%sdashboard-solo/db/%s?&panelId=%d"
,
setting
.
AppUrl
,
slug
,
c
.
Rule
.
PanelId
)
return
ruleUrl
,
nil
}
}
func
NewEvalContext
(
rule
*
Rule
)
*
EvalContext
{
return
&
EvalContext
{
StartTime
:
time
.
Now
(),
...
...
pkg/services/alerting/notifier.go
View file @
effd2098
...
...
@@ -2,6 +2,7 @@ package alerting
import
(
"errors"
"fmt"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/imguploader"
...
...
@@ -60,22 +61,22 @@ func (n *RootNotifier) sendNotifications(notifiers []Notifier, context *EvalCont
}
}
func
(
n
*
RootNotifier
)
uploadImage
(
context
*
EvalContext
)
error
{
func
(
n
*
RootNotifier
)
uploadImage
(
context
*
EvalContext
)
(
err
error
)
{
uploader
,
_
:=
imguploader
.
NewImageUploader
()
imageUrl
,
err
:=
context
.
GetImageUrl
()
if
err
!=
nil
{
return
err
}
renderOpts
:=
&
renderer
.
RenderOpts
{
Url
:
imageUrl
,
Width
:
"800"
,
Height
:
"400"
,
Timeout
:
"30"
,
OrgId
:
context
.
Rule
.
OrgId
,
}
if
slug
,
err
:=
context
.
GetDashboardSlug
();
err
!=
nil
{
return
err
}
else
{
renderOpts
.
Url
=
fmt
.
Sprintf
(
"dashboard-solo/db/%s?&panelId=%d"
,
slug
,
context
.
Rule
.
PanelId
)
}
if
imagePath
,
err
:=
renderer
.
RenderToPng
(
renderOpts
);
err
!=
nil
{
return
err
}
else
{
...
...
pkg/services/alerting/notifiers/webhook.go
View file @
effd2098
...
...
@@ -52,9 +52,8 @@ func (this *WebhookNotifier) Notify(context *alerting.EvalContext) {
bodyJSON
.
Set
(
"rule_url"
,
ruleUrl
)
}
imageUrl
,
err
:=
context
.
GetImageUrl
()
if
err
==
nil
{
bodyJSON
.
Set
(
"image_url"
,
imageUrl
)
if
context
.
ImagePublicUrl
!=
""
{
bodyJSON
.
Set
(
"image_url"
,
context
.
ImagePublicUrl
)
}
body
,
_
:=
bodyJSON
.
MarshalJSON
()
...
...
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