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
35f40b73
Commit
35f40b73
authored
Jan 09, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(plugins): upgraded opentsdb
parent
b76449d1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
44 deletions
+44
-44
public/app/core/routes/all.js
+3
-3
public/app/plugins/datasource/opentsdb/datasource.d.ts
+3
-0
public/app/plugins/datasource/opentsdb/datasource.js
+14
-20
public/app/plugins/datasource/opentsdb/module.js
+9
-1
public/app/plugins/datasource/opentsdb/plugin.json
+1
-6
public/app/plugins/datasource/opentsdb/specs/datasource-specs.ts
+14
-14
No files found.
public/app/core/routes/all.js
View file @
35f40b73
...
...
@@ -42,17 +42,17 @@ define([
controller
:
'DashboardImportCtrl'
,
})
.
when
(
'/datasources'
,
{
templateUrl
:
'app/features/
org/partials/datasources
.html'
,
templateUrl
:
'app/features/
datasources/partials/list
.html'
,
controller
:
'DataSourcesCtrl'
,
resolve
:
loadOrgBundle
,
})
.
when
(
'/datasources/edit/:id'
,
{
templateUrl
:
'app/features/
org/partials/datasourceE
dit.html'
,
templateUrl
:
'app/features/
datasources/partials/e
dit.html'
,
controller
:
'DataSourceEditCtrl'
,
resolve
:
loadOrgBundle
,
})
.
when
(
'/datasources/new'
,
{
templateUrl
:
'app/features/
org/partials/datasourceE
dit.html'
,
templateUrl
:
'app/features/
datasources/partials/e
dit.html'
,
controller
:
'DataSourceEditCtrl'
,
resolve
:
loadOrgBundle
,
})
...
...
public/app/plugins/datasource/opentsdb/datasource.d.ts
0 → 100644
View file @
35f40b73
declare
var
Datasource
:
any
;
export
default
Datasource
;
public/app/plugins/datasource/opentsdb/datasource.js
View file @
35f40b73
...
...
@@ -3,25 +3,19 @@ define([
'lodash'
,
'app/core/utils/datemath'
,
'moment'
,
'./directives'
,
'./queryCtrl'
,
],
function
(
angular
,
_
,
dateMath
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.services'
);
module
.
factory
(
'OpenTSDBDatasource'
,
function
(
$q
,
backendSrv
,
templateSrv
)
{
function
OpenTSDBDatasource
(
datasource
)
{
function
OpenTSDBDatasource
(
instanceSettings
,
$q
,
backendSrv
,
templateSrv
)
{
this
.
type
=
'opentsdb'
;
this
.
url
=
datasource
.
url
;
this
.
name
=
datasource
.
name
;
this
.
url
=
instanceSettings
.
url
;
this
.
name
=
instanceSettings
.
name
;
this
.
supportMetrics
=
true
;
}
// Called once per panel (graph)
OpenTSDBDatasource
.
prototype
.
query
=
function
(
options
)
{
this
.
query
=
function
(
options
)
{
var
start
=
convertToTSDBTime
(
options
.
rangeRaw
.
from
,
false
);
var
end
=
convertToTSDBTime
(
options
.
rangeRaw
.
to
,
true
);
var
qs
=
[];
...
...
@@ -60,7 +54,7 @@ function (angular, _, dateMath) {
});
};
OpenTSDBDatasource
.
prototype
.
performTimeSeriesQuery
=
function
(
queries
,
start
,
end
)
{
this
.
performTimeSeriesQuery
=
function
(
queries
,
start
,
end
)
{
var
reqBody
=
{
start
:
start
,
queries
:
queries
...
...
@@ -80,13 +74,13 @@ function (angular, _, dateMath) {
return
backendSrv
.
datasourceRequest
(
options
);
};
OpenTSDBDatasource
.
prototype
.
_performSuggestQuery
=
function
(
query
,
type
)
{
this
.
_performSuggestQuery
=
function
(
query
,
type
)
{
return
this
.
_get
(
'/api/suggest'
,
{
type
:
type
,
q
:
query
,
max
:
1000
}).
then
(
function
(
result
)
{
return
result
.
data
;
});
};
OpenTSDBDatasource
.
prototype
.
_performMetricKeyValueLookup
=
function
(
metric
,
key
)
{
this
.
_performMetricKeyValueLookup
=
function
(
metric
,
key
)
{
if
(
!
metric
||
!
key
)
{
return
$q
.
when
([]);
}
...
...
@@ -105,7 +99,7 @@ function (angular, _, dateMath) {
});
};
OpenTSDBDatasource
.
prototype
.
_performMetricKeyLookup
=
function
(
metric
)
{
this
.
_performMetricKeyLookup
=
function
(
metric
)
{
if
(
!
metric
)
{
return
$q
.
when
([]);
}
return
this
.
_get
(
'/api/search/lookup'
,
{
m
:
metric
,
limit
:
1000
}).
then
(
function
(
result
)
{
...
...
@@ -122,7 +116,7 @@ function (angular, _, dateMath) {
});
};
OpenTSDBDatasource
.
prototype
.
_get
=
function
(
relativeUrl
,
params
)
{
this
.
_get
=
function
(
relativeUrl
,
params
)
{
return
backendSrv
.
datasourceRequest
({
method
:
'GET'
,
url
:
this
.
url
+
relativeUrl
,
...
...
@@ -130,7 +124,7 @@ function (angular, _, dateMath) {
});
};
OpenTSDBDatasource
.
prototype
.
metricFindQuery
=
function
(
query
)
{
this
.
metricFindQuery
=
function
(
query
)
{
if
(
!
query
)
{
return
$q
.
when
([]);
}
var
interpolated
;
...
...
@@ -181,14 +175,14 @@ function (angular, _, dateMath) {
return
$q
.
when
([]);
};
OpenTSDBDatasource
.
prototype
.
testDatasource
=
function
()
{
this
.
testDatasource
=
function
()
{
return
this
.
_performSuggestQuery
(
'cpu'
,
'metrics'
).
then
(
function
()
{
return
{
status
:
"success"
,
message
:
"Data source is working"
,
title
:
"Success"
};
});
};
var
aggregatorsPromise
=
null
;
OpenTSDBDatasource
.
prototype
.
getAggregators
=
function
()
{
this
.
getAggregators
=
function
()
{
if
(
aggregatorsPromise
)
{
return
aggregatorsPromise
;
}
aggregatorsPromise
=
this
.
_get
(
'/api/aggregators'
).
then
(
function
(
result
)
{
...
...
@@ -311,7 +305,7 @@ function (angular, _, dateMath) {
return
date
.
valueOf
();
}
return
OpenTSDBDatasource
;
});
}
return
OpenTSDBDatasource
;
});
public/app/plugins/datasource/opentsdb/
directives
.js
→
public/app/plugins/datasource/opentsdb/
module
.js
View file @
35f40b73
define
([
'angular'
,
'./datasource'
,
],
function
(
angular
)
{
function
(
angular
,
OpenTsDatasource
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.directives'
);
...
...
@@ -13,4 +14,11 @@ function (angular) {
};
});
module
.
directive
(
'datasourceCustomSettingsViewOpentsdb'
,
function
()
{
return
{
templateUrl
:
'app/plugins/datasource/opentsdb/partials/config.html'
};
});
return
{
Datasource
:
OpenTsDatasource
};
});
public/app/plugins/datasource/opentsdb/plugin.json
View file @
35f40b73
...
...
@@ -3,12 +3,7 @@
"name"
:
"OpenTSDB"
,
"id"
:
"opentsdb"
,
"serviceName"
:
"OpenTSDBDatasource"
,
"module"
:
"app/plugins/datasource/opentsdb/datasource"
,
"partials"
:
{
"config"
:
"app/plugins/datasource/opentsdb/partials/config.html"
},
"module"
:
"app/plugins/datasource/opentsdb/module"
,
"metrics"
:
true
,
"defaultMatchFormat"
:
"pipe"
...
...
public/
test/specs/opentsdbDatasource-specs.j
s
→
public/
app/plugins/datasource/opentsdb/specs/datasource-specs.t
s
View file @
35f40b73
define
([
'./helpers'
,
'app/plugins/datasource/opentsdb/datasource'
],
function
(
helpers
)
{
'use strict'
;
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
helpers
from
'test/specs/helpers'
;
import
Datasource
from
"../datasource"
;
describe
(
'opentsdb'
,
function
()
{
describe
(
'opentsdb'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
var
instanceSettings
=
{
url
:
''
};
beforeEach
(
module
(
'grafana.core'
));
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'backendSrv'
]));
beforeEach
(
ctx
.
createService
(
'OpenTSDBDatasource'
));
beforeEach
(
function
()
{
ctx
.
ds
=
new
ctx
.
service
({
url
:
[
''
]
});
});
beforeEach
(
angularMocks
.
inject
(
function
(
$q
,
$rootScope
,
$httpBackend
,
$injector
)
{
ctx
.
$q
=
$q
;
ctx
.
$httpBackend
=
$httpBackend
;
ctx
.
$rootScope
=
$rootScope
;
ctx
.
ds
=
$injector
.
instantiate
(
Datasource
,
{
instanceSettings
:
instanceSettings
});
}));
describe
(
'When performing metricFindQuery'
,
function
()
{
var
results
;
...
...
@@ -64,8 +65,7 @@ define([
expect
(
requestOptions
.
params
.
type
).
to
.
be
(
'tagv'
);
expect
(
requestOptions
.
params
.
q
).
to
.
be
(
'bar'
);
});
});
});
});
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