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
0da733de
Commit
0da733de
authored
Feb 03, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(plugins): migrated opentsdb plugin
parent
2fc8da7a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
237 additions
and
285 deletions
+237
-285
public/app/plugins/datasource/opentsdb/datasource.d.ts
+2
-2
public/app/plugins/datasource/opentsdb/datasource.js
+7
-6
public/app/plugins/datasource/opentsdb/module.js
+0
-23
public/app/plugins/datasource/opentsdb/module.ts
+13
-0
public/app/plugins/datasource/opentsdb/partials/config.html
+1
-1
public/app/plugins/datasource/opentsdb/partials/query.editor.html
+84
-124
public/app/plugins/datasource/opentsdb/queryCtrl.js
+0
-127
public/app/plugins/datasource/opentsdb/query_ctrl.ts
+128
-0
public/app/plugins/datasource/opentsdb/specs/datasource-specs.ts
+2
-2
No files found.
public/app/plugins/datasource/opentsdb/datasource.d.ts
View file @
0da733de
declare
var
Datasource
:
any
;
export
default
Datasource
;
declare
var
OpenTs
Datasource
:
any
;
export
{
OpenTsDatasource
}
;
public/app/plugins/datasource/opentsdb/datasource.js
View file @
0da733de
...
...
@@ -3,13 +3,12 @@ define([
'lodash'
,
'app/core/utils/datemath'
,
'moment'
,
'./queryCtrl'
,
],
function
(
angular
,
_
,
dateMath
)
{
'use strict'
;
/** @ngInject */
function
OpenT
SDB
Datasource
(
instanceSettings
,
$q
,
backendSrv
,
templateSrv
)
{
function
OpenT
s
Datasource
(
instanceSettings
,
$q
,
backendSrv
,
templateSrv
)
{
this
.
type
=
'opentsdb'
;
this
.
url
=
instanceSettings
.
url
;
this
.
name
=
instanceSettings
.
name
;
...
...
@@ -73,13 +72,13 @@ function (angular, _, dateMath) {
url
:
this
.
url
+
'/api/query'
,
data
:
reqBody
};
if
(
this
.
basicAuth
||
this
.
withCredentials
)
{
options
.
withCredentials
=
true
;
}
if
(
this
.
basicAuth
)
{
options
.
headers
=
{
"Authorization"
:
this
.
basicAuth
};
options
.
headers
=
{
"Authorization"
:
this
.
basicAuth
};
}
// In case the backend is 3rd-party hosted and does not suport OPTIONS, urlencoded requests
...
...
@@ -325,5 +324,7 @@ function (angular, _, dateMath) {
}
return
OpenTSDBDatasource
;
return
{
OpenTsDatasource
:
OpenTsDatasource
};
});
public/app/plugins/datasource/opentsdb/module.js
deleted
100644 → 0
View file @
2fc8da7a
define
([
'./datasource'
,
],
function
(
OpenTsDatasource
)
{
'use strict'
;
function
metricsQueryEditor
()
{
return
{
controller
:
'OpenTSDBQueryCtrl'
,
templateUrl
:
'public/app/plugins/datasource/opentsdb/partials/query.editor.html'
,
};
}
function
configView
()
{
return
{
templateUrl
:
'public/app/plugins/datasource/opentsdb/partials/config.html'
};
}
return
{
Datasource
:
OpenTsDatasource
,
metricsQueryEditor
:
metricsQueryEditor
,
configView
:
configView
,
};
});
public/app/plugins/datasource/opentsdb/module.ts
0 → 100644
View file @
0da733de
import
{
OpenTsDatasource
}
from
'./datasource'
;
import
{
OpenTsQueryCtrl
}
from
'./query_ctrl'
;
class
OpenTsConfigCtrl
{
static
templateUrl
=
'public/app/plugins/datasource/opentsdb/partials/config.html'
;
}
export
{
OpenTsDatasource
as
Datasource
,
OpenTsQueryCtrl
as
QueryCtrl
,
OpenTsConfigCtrl
as
ConfigCtrl
,
};
public/app/plugins/datasource/opentsdb/partials/config.html
View file @
0da733de
<datasource-http-settings></datasource-http-settings>
<datasource-http-settings
current=
"ctrl.current"
></datasource-http-settings>
public/app/plugins/datasource/opentsdb/partials/query.editor.html
View file @
0da733de
This diff is collapsed.
Click to expand it.
public/app/plugins/datasource/opentsdb/queryCtrl.js
deleted
100644 → 0
View file @
2fc8da7a
define
([
'angular'
,
'lodash'
,
'app/core/utils/kbn'
],
function
(
angular
,
_
,
kbn
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'OpenTSDBQueryCtrl'
,
function
(
$scope
)
{
$scope
.
panelCtrl
=
$scope
.
ctrl
;
$scope
.
init
=
function
()
{
$scope
.
target
.
errors
=
validateTarget
(
$scope
.
target
);
$scope
.
aggregators
=
[
'avg'
,
'sum'
,
'min'
,
'max'
,
'dev'
,
'zimsum'
,
'mimmin'
,
'mimmax'
];
$scope
.
fillPolicies
=
[
'none'
,
'nan'
,
'null'
,
'zero'
];
if
(
!
$scope
.
target
.
aggregator
)
{
$scope
.
target
.
aggregator
=
'sum'
;
}
if
(
!
$scope
.
target
.
downsampleAggregator
)
{
$scope
.
target
.
downsampleAggregator
=
'avg'
;
}
if
(
!
$scope
.
target
.
downsampleFillPolicy
)
{
$scope
.
target
.
downsampleFillPolicy
=
'none'
;
}
$scope
.
datasource
.
getAggregators
().
then
(
function
(
aggs
)
{
$scope
.
aggregators
=
aggs
;
});
};
$scope
.
targetBlur
=
function
()
{
$scope
.
target
.
errors
=
validateTarget
(
$scope
.
target
);
// this does not work so good
if
(
!
_
.
isEqual
(
$scope
.
oldTarget
,
$scope
.
target
)
&&
_
.
isEmpty
(
$scope
.
target
.
errors
))
{
$scope
.
oldTarget
=
angular
.
copy
(
$scope
.
target
);
$scope
.
get_data
();
}
};
$scope
.
getTextValues
=
function
(
metricFindResult
)
{
return
_
.
map
(
metricFindResult
,
function
(
value
)
{
return
value
.
text
;
});
};
$scope
.
suggestMetrics
=
function
(
query
,
callback
)
{
$scope
.
datasource
.
metricFindQuery
(
'metrics('
+
query
+
')'
)
.
then
(
$scope
.
getTextValues
)
.
then
(
callback
);
};
$scope
.
suggestTagKeys
=
function
(
query
,
callback
)
{
$scope
.
datasource
.
metricFindQuery
(
'suggest_tagk('
+
query
+
')'
)
.
then
(
$scope
.
getTextValues
)
.
then
(
callback
);
};
$scope
.
suggestTagValues
=
function
(
query
,
callback
)
{
$scope
.
datasource
.
metricFindQuery
(
'suggest_tagv('
+
query
+
')'
)
.
then
(
$scope
.
getTextValues
)
.
then
(
callback
);
};
$scope
.
addTag
=
function
()
{
if
(
!
$scope
.
addTagMode
)
{
$scope
.
addTagMode
=
true
;
return
;
}
if
(
!
$scope
.
target
.
tags
)
{
$scope
.
target
.
tags
=
{};
}
$scope
.
target
.
errors
=
validateTarget
(
$scope
.
target
);
if
(
!
$scope
.
target
.
errors
.
tags
)
{
$scope
.
target
.
tags
[
$scope
.
target
.
currentTagKey
]
=
$scope
.
target
.
currentTagValue
;
$scope
.
target
.
currentTagKey
=
''
;
$scope
.
target
.
currentTagValue
=
''
;
$scope
.
targetBlur
();
}
$scope
.
addTagMode
=
false
;
};
$scope
.
removeTag
=
function
(
key
)
{
delete
$scope
.
target
.
tags
[
key
];
$scope
.
targetBlur
();
};
$scope
.
editTag
=
function
(
key
,
value
)
{
$scope
.
removeTag
(
key
);
$scope
.
target
.
currentTagKey
=
key
;
$scope
.
target
.
currentTagValue
=
value
;
$scope
.
addTag
();
};
function
validateTarget
(
target
)
{
var
errs
=
{};
if
(
target
.
shouldDownsample
)
{
try
{
if
(
target
.
downsampleInterval
)
{
kbn
.
describe_interval
(
target
.
downsampleInterval
);
}
else
{
errs
.
downsampleInterval
=
"You must supply a downsample interval (e.g. '1m' or '1h')."
;
}
}
catch
(
err
)
{
errs
.
downsampleInterval
=
err
.
message
;
}
}
if
(
target
.
tags
&&
_
.
has
(
target
.
tags
,
target
.
currentTagKey
))
{
errs
.
tags
=
"Duplicate tag key '"
+
target
.
currentTagKey
+
"'."
;
}
return
errs
;
}
$scope
.
init
();
});
});
public/app/plugins/datasource/opentsdb/query_ctrl.ts
0 → 100644
View file @
0da733de
///<reference path="../../../headers/common.d.ts" />
import
_
from
'lodash'
;
import
kbn
from
'app/core/utils/kbn'
;
import
{
QueryCtrl
}
from
'app/features/panel/panel'
;
export
class
OpenTsQueryCtrl
extends
QueryCtrl
{
static
templateUrl
=
'public/app/plugins/datasource/opentsdb/partials/query.editor.html'
;
aggregators
:
any
;
fillPolicies
:
any
;
aggregator
:
any
;
downsampleInterval
:
any
;
downsampleAggregator
:
any
;
downsampleFillPolicy
:
any
;
errors
:
any
;
suggestMetrics
:
any
;
suggestTagKeys
:
any
;
suggestTagValues
:
any
;
addTagMode
:
boolean
;
constructor
(
$scope
,
$injector
)
{
super
(
$scope
,
$injector
);
this
.
errors
=
this
.
validateTarget
();
this
.
aggregators
=
[
'avg'
,
'sum'
,
'min'
,
'max'
,
'dev'
,
'zimsum'
,
'mimmin'
,
'mimmax'
];
this
.
fillPolicies
=
[
'none'
,
'nan'
,
'null'
,
'zero'
];
if
(
!
this
.
target
.
aggregator
)
{
this
.
target
.
aggregator
=
'sum'
;
}
if
(
!
this
.
target
.
downsampleAggregator
)
{
this
.
target
.
downsampleAggregator
=
'avg'
;
}
if
(
!
this
.
target
.
downsampleFillPolicy
)
{
this
.
target
.
downsampleFillPolicy
=
'none'
;
}
this
.
datasource
.
getAggregators
().
then
(
function
(
aggs
)
{
this
.
aggregators
=
aggs
;
});
// needs to be defined here as it is called from typeahead
this
.
suggestMetrics
=
(
query
,
callback
)
=>
{
this
.
datasource
.
metricFindQuery
(
'metrics('
+
query
+
')'
)
.
then
(
this
.
getTextValues
)
.
then
(
callback
);
};
this
.
suggestTagKeys
=
(
query
,
callback
)
=>
{
this
.
datasource
.
metricFindQuery
(
'suggest_tagk('
+
query
+
')'
)
.
then
(
this
.
getTextValues
)
.
then
(
callback
);
};
this
.
suggestTagValues
=
(
query
,
callback
)
=>
{
this
.
datasource
.
metricFindQuery
(
'suggest_tagv('
+
query
+
')'
)
.
then
(
this
.
getTextValues
)
.
then
(
callback
);
};
}
targetBlur
()
{
this
.
errors
=
this
.
validateTarget
();
this
.
refresh
();
}
getTextValues
(
metricFindResult
)
{
return
_
.
map
(
metricFindResult
,
function
(
value
)
{
return
value
.
text
;
});
}
addTag
()
{
if
(
!
this
.
addTagMode
)
{
this
.
addTagMode
=
true
;
return
;
}
if
(
!
this
.
target
.
tags
)
{
this
.
target
.
tags
=
{};
}
this
.
errors
=
this
.
validateTarget
();
if
(
!
this
.
errors
.
tags
)
{
this
.
target
.
tags
[
this
.
target
.
currentTagKey
]
=
this
.
target
.
currentTagValue
;
this
.
target
.
currentTagKey
=
''
;
this
.
target
.
currentTagValue
=
''
;
this
.
targetBlur
();
}
this
.
addTagMode
=
false
;
}
removeTag
(
key
)
{
delete
this
.
target
.
tags
[
key
];
this
.
targetBlur
();
}
editTag
(
key
,
value
)
{
this
.
removeTag
(
key
);
this
.
target
.
currentTagKey
=
key
;
this
.
target
.
currentTagValue
=
value
;
this
.
addTag
();
}
validateTarget
()
{
var
errs
:
any
=
{};
if
(
this
.
target
.
shouldDownsample
)
{
try
{
if
(
this
.
target
.
downsampleInterval
)
{
kbn
.
describe_interval
(
this
.
target
.
downsampleInterval
);
}
else
{
errs
.
downsampleInterval
=
"You must supply a downsample interval (e.g. '1m' or '1h')."
;
}
}
catch
(
err
)
{
errs
.
downsampleInterval
=
err
.
message
;
}
}
if
(
this
.
target
.
tags
&&
_
.
has
(
this
.
target
.
tags
,
this
.
target
.
currentTagKey
))
{
errs
.
tags
=
"Duplicate tag key '"
+
this
.
target
.
currentTagKey
+
"'."
;
}
return
errs
;
}
}
public/app/plugins/datasource/opentsdb/specs/datasource-specs.ts
View file @
0da733de
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
helpers
from
'test/specs/helpers'
;
import
Datasource
from
"../datasource"
;
import
{
OpenTsDatasource
}
from
"../datasource"
;
describe
(
'opentsdb'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
...
...
@@ -14,7 +14,7 @@ describe('opentsdb', function() {
ctx
.
$q
=
$q
;
ctx
.
$httpBackend
=
$httpBackend
;
ctx
.
$rootScope
=
$rootScope
;
ctx
.
ds
=
$injector
.
instantiate
(
Datasource
,
{
instanceSettings
:
instanceSettings
});
ctx
.
ds
=
$injector
.
instantiate
(
OpenTs
Datasource
,
{
instanceSettings
:
instanceSettings
});
}));
describe
(
'When performing metricFindQuery'
,
function
()
{
...
...
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