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
f9b75244
Commit
f9b75244
authored
Sep 05, 2018
by
Erik Sundell
Committed by
Daniel Lee
Sep 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented datasource test
parent
350bcf4f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
14 deletions
+79
-14
public/app/plugins/datasource/stackdriver/datasource.ts
+61
-11
public/app/plugins/datasource/stackdriver/module.ts
+2
-2
public/app/plugins/datasource/stackdriver/plugin.json
+16
-1
No files found.
public/app/plugins/datasource/stackdriver/datasource.ts
View file @
f9b75244
/** @ngInject */
export
function
StackdriverDatasource
(
this
:
any
,
instanceSettings
,
$q
,
backendSrv
,
templateSrv
)
{
// this.basicAuth = instanceSettings.basicAuth;
// this.url = instanceSettings.url;
// this.name = instanceSettings.name;
// this.graphiteVersion = instanceSettings.jsonData.graphiteVersion || '0.9';
// this.supportsTags = supportsTags(this.graphiteVersion);
// this.cacheTimeout = instanceSettings.cacheTimeout;
// this.withCredentials = instanceSettings.withCredentials;
// this.render_method = instanceSettings.render_method || 'POST';
// this.funcDefs = null;
// this.funcDefsPromise = null;
export
default
class
StackdriverDatasource
{
url
:
string
;
baseUrl
:
string
;
cloudName
:
string
;
constructor
(
instanceSettings
,
private
backendSrv
)
{
this
.
cloudName
=
'stackdriver'
;
this
.
baseUrl
=
`/
${
this
.
cloudName
}
/`
;
this
.
url
=
instanceSettings
.
url
;
}
testDatasource
()
{
const
path
=
`v3/projects/raintank-production/timeSeries?aggregation.crossSeriesReducer=
REDUCE_NONE&filter=metric.type%20%3D%20%22compute.googleapis.com%2Finstance%2Fcpu%2Fusage_time%
22&aggregation.perSeriesAligner=ALIGN_NONE&interval.startTime=2018-09-04T05%3A16%3A02.383Z&interval.endTime=2018-09-04T11%3A16%3A02.383Z`
;
return
this
.
doRequest
(
`
${
this
.
baseUrl
}${
path
}
`
)
.
then
(
response
=>
{
if
(
response
.
status
===
200
)
{
return
{
status
:
'success'
,
message
:
'Successfully queried the Azure Monitor service.'
,
title
:
'Success'
,
};
}
else
{
throw
new
Error
();
}
})
.
catch
(
error
=>
{
let
message
=
'Azure Monitor: '
;
message
+=
error
.
statusText
?
error
.
statusText
+
': '
:
''
;
if
(
error
.
data
&&
error
.
data
.
error
&&
error
.
data
.
error
.
code
)
{
message
+=
error
.
data
.
error
.
code
+
'. '
+
error
.
data
.
error
.
message
;
}
else
if
(
error
.
data
&&
error
.
data
.
error
)
{
message
+=
error
.
data
.
error
;
}
else
if
(
error
.
data
)
{
message
+=
error
.
data
;
}
else
{
message
+=
'Cannot connect to Azure Monitor REST API.'
;
}
return
{
status
:
'error'
,
message
:
message
,
};
});
}
doRequest
(
url
,
maxRetries
=
1
)
{
return
this
.
backendSrv
.
datasourceRequest
({
url
:
this
.
url
+
url
,
method
:
'GET'
,
})
.
catch
(
error
=>
{
if
(
maxRetries
>
0
)
{
return
this
.
doRequest
(
url
,
maxRetries
-
1
);
}
throw
error
;
});
}
}
public/app/plugins/datasource/stackdriver/module.ts
View file @
f9b75244
// import { StackdriverDatasource }
from './datasource';
import
StackdriverDatasource
from
'./datasource'
;
// import { StackdriverQueryCtrl } from './query_ctrl';
import
{
StackdriverConfigCtrl
}
from
'./config_ctrl'
;
...
...
@@ -7,7 +7,7 @@ import { StackdriverConfigCtrl } from './config_ctrl';
// }
export
{
//
StackdriverDatasource as Datasource,
StackdriverDatasource
as
Datasource
,
// StackdriverQueryCtrl as QueryCtrl,
StackdriverConfigCtrl
as
ConfigCtrl
,
// AnnotationsQueryCtrl,
...
...
public/app/plugins/datasource/stackdriver/plugin.json
View file @
f9b75244
...
...
@@ -12,5 +12,19 @@
"info"
:
{
"description"
:
"Data Source for Stackdriver"
,
"version"
:
"1.0.0"
}
},
"routes"
:
[
{
"path"
:
"stackdriver"
,
"method"
:
"GET"
,
"url"
:
"https://content-monitoring.googleapis.com"
,
"jwtTokenAuth"
:
{
"params"
:
{
"token_uri"
:
"{{.JsonData.tokenUri}}"
,
"client_email"
:
"{{.JsonData.clientEmail}}"
,
"private_key"
:
"{{.SecureJsonData.privateKey}}"
}
}
}
]
}
\ No newline at end of file
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