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
0a85efbf
Commit
0a85efbf
authored
Jun 20, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): add datasource type to settings
parent
a18506e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
pkg/services/alerting/extractor.go
+9
-8
No files found.
pkg/services/alerting/extractor.go
View file @
0a85efbf
...
@@ -23,28 +23,28 @@ func NewDashAlertExtractor(dash *m.Dashboard, orgId int64) *DashAlertExtractor {
...
@@ -23,28 +23,28 @@ func NewDashAlertExtractor(dash *m.Dashboard, orgId int64) *DashAlertExtractor {
}
}
}
}
func
(
e
*
DashAlertExtractor
)
lookupDatasourceId
(
dsName
string
)
(
int64
,
error
)
{
func
(
e
*
DashAlertExtractor
)
lookupDatasourceId
(
dsName
string
)
(
*
m
.
DataSource
,
error
)
{
if
dsName
==
""
{
if
dsName
==
""
{
query
:=
&
m
.
GetDataSourcesQuery
{
OrgId
:
e
.
OrgId
}
query
:=
&
m
.
GetDataSourcesQuery
{
OrgId
:
e
.
OrgId
}
if
err
:=
bus
.
Dispatch
(
query
);
err
!=
nil
{
if
err
:=
bus
.
Dispatch
(
query
);
err
!=
nil
{
return
0
,
err
return
nil
,
err
}
else
{
}
else
{
for
_
,
ds
:=
range
query
.
Result
{
for
_
,
ds
:=
range
query
.
Result
{
if
ds
.
IsDefault
{
if
ds
.
IsDefault
{
return
ds
.
Id
,
nil
return
ds
,
nil
}
}
}
}
}
}
}
else
{
}
else
{
query
:=
&
m
.
GetDataSourceByNameQuery
{
Name
:
dsName
,
OrgId
:
e
.
OrgId
}
query
:=
&
m
.
GetDataSourceByNameQuery
{
Name
:
dsName
,
OrgId
:
e
.
OrgId
}
if
err
:=
bus
.
Dispatch
(
query
);
err
!=
nil
{
if
err
:=
bus
.
Dispatch
(
query
);
err
!=
nil
{
return
0
,
err
return
nil
,
err
}
else
{
}
else
{
return
query
.
Result
.
Id
,
nil
return
query
.
Result
,
nil
}
}
}
}
return
0
,
errors
.
New
(
"Could not find datasource id for "
+
dsName
)
return
nil
,
errors
.
New
(
"Could not find datasource id for "
+
dsName
)
}
}
func
(
e
*
DashAlertExtractor
)
GetAlerts
()
([]
*
m
.
Alert
,
error
)
{
func
(
e
*
DashAlertExtractor
)
GetAlerts
()
([]
*
m
.
Alert
,
error
)
{
...
@@ -94,10 +94,11 @@ func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error) {
...
@@ -94,10 +94,11 @@ func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error) {
dsName
=
panel
.
Get
(
"datasource"
)
.
MustString
()
dsName
=
panel
.
Get
(
"datasource"
)
.
MustString
()
}
}
if
datasource
Id
,
err
:=
e
.
lookupDatasourceId
(
dsName
);
err
!=
nil
{
if
datasource
,
err
:=
e
.
lookupDatasourceId
(
dsName
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
else
{
}
else
{
valueQuery
.
SetPath
([]
string
{
"datasourceId"
},
datasourceId
)
valueQuery
.
SetPath
([]
string
{
"datasourceId"
},
datasource
.
Id
)
valueQuery
.
SetPath
([]
string
{
"datasourceType"
},
datasource
.
Type
)
}
}
targetQuery
:=
target
.
Get
(
"target"
)
.
MustString
()
targetQuery
:=
target
.
Get
(
"target"
)
.
MustString
()
...
...
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