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
8ed0df64
Commit
8ed0df64
authored
Jul 01, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes to OpenTSDB datasource, and added support for repeat panels and repeat rows
parent
e8c65dc3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
18 deletions
+22
-18
public/app/plugins/datasource/opentsdb/datasource.js
+21
-17
public/app/plugins/datasource/opentsdb/queryCtrl.js
+1
-1
No files found.
public/app/plugins/datasource/opentsdb/datasource.js
View file @
8ed0df64
...
...
@@ -27,7 +27,7 @@ function (angular, _, kbn) {
var
qs
=
[];
_
.
each
(
options
.
targets
,
function
(
target
)
{
qs
.
push
(
convertTargetToQuery
(
target
,
options
.
interval
));
qs
.
push
(
convertTargetToQuery
(
target
,
options
));
});
var
queries
=
_
.
compact
(
qs
);
...
...
@@ -47,10 +47,10 @@ function (angular, _, kbn) {
});
return
this
.
performTimeSeriesQuery
(
queries
,
start
,
end
).
then
(
function
(
response
)
{
var
metricToTargetMapping
=
mapMetricsToTargets
(
response
.
data
,
options
.
targets
);
var
metricToTargetMapping
=
mapMetricsToTargets
(
response
.
data
,
options
);
var
result
=
_
.
map
(
response
.
data
,
function
(
metricData
,
index
)
{
index
=
metricToTargetMapping
[
index
];
return
transformMetricData
(
metricData
,
groupByTags
,
options
.
targets
[
index
]);
return
transformMetricData
(
metricData
,
groupByTags
,
options
.
targets
[
index
]
,
options
);
});
return
{
data
:
result
};
});
...
...
@@ -125,6 +125,8 @@ function (angular, _, kbn) {
};
OpenTSDBDatasource
.
prototype
.
metricFindQuery
=
function
(
query
)
{
if
(
!
query
)
{
return
$q
.
when
([]);
}
var
interpolated
;
try
{
interpolated
=
templateSrv
.
replace
(
query
);
...
...
@@ -147,8 +149,8 @@ function (angular, _, kbn) {
if
(
metrics_query
)
{
return
this
.
_performSuggestQuery
(
metrics_query
[
1
]).
then
(
responseTransform
);
}
var
tag_names_query
=
interpolated
.
match
(
tag_names_regex
);
var
tag_names_query
=
interpolated
.
match
(
tag_names_regex
);
if
(
tag_names_query
)
{
return
this
.
_performMetricKeyLookup
(
tag_names_query
[
1
]).
then
(
responseTransform
);
}
...
...
@@ -157,6 +159,8 @@ function (angular, _, kbn) {
if
(
tag_values_query
)
{
return
this
.
_performMetricKeyValueLookup
(
tag_values_query
[
1
],
tag_values_query
[
2
]).
then
(
responseTransform
);
}
return
$q
.
when
([]);
};
OpenTSDBDatasource
.
prototype
.
testDatasource
=
function
()
{
...
...
@@ -165,8 +169,8 @@ function (angular, _, kbn) {
});
};
function
transformMetricData
(
md
,
groupByTags
,
options
)
{
var
metricLabel
=
createMetricLabel
(
md
,
options
,
groupByTag
s
);
function
transformMetricData
(
md
,
groupByTags
,
target
,
options
)
{
var
metricLabel
=
createMetricLabel
(
md
,
target
,
groupByTags
,
option
s
);
var
dps
=
[];
// TSDB returns datapoints has a hash of ts => value.
...
...
@@ -178,13 +182,13 @@ function (angular, _, kbn) {
return
{
target
:
metricLabel
,
datapoints
:
dps
};
}
function
createMetricLabel
(
md
,
options
,
groupByTag
s
)
{
if
(
!
_
.
isUndefined
(
options
)
&&
options
.
alias
)
{
var
scopedVars
=
{}
;
function
createMetricLabel
(
md
,
target
,
groupByTags
,
option
s
)
{
if
(
target
.
alias
)
{
var
scopedVars
=
_
.
clone
(
options
.
scopedVars
||
{})
;
_
.
each
(
md
.
tags
,
function
(
value
,
key
)
{
scopedVars
[
'tag_'
+
key
]
=
{
value
:
value
};
});
return
templateSrv
.
replace
(
options
.
alias
,
scopedVars
);
return
templateSrv
.
replace
(
target
.
alias
,
scopedVars
);
}
var
label
=
md
.
metric
;
...
...
@@ -205,13 +209,13 @@ function (angular, _, kbn) {
return
label
;
}
function
convertTargetToQuery
(
target
,
interval
)
{
function
convertTargetToQuery
(
target
,
options
)
{
if
(
!
target
.
metric
||
target
.
hide
)
{
return
null
;
}
var
query
=
{
metric
:
templateSrv
.
replace
(
target
.
metric
),
metric
:
templateSrv
.
replace
(
target
.
metric
,
options
.
scopedVars
),
aggregator
:
"avg"
};
...
...
@@ -235,7 +239,7 @@ function (angular, _, kbn) {
}
if
(
!
target
.
disableDownsampling
)
{
interval
=
templateSrv
.
replace
(
target
.
downsampleInterval
||
interval
);
var
interval
=
templateSrv
.
replace
(
target
.
downsampleInterval
||
options
.
interval
);
if
(
interval
.
match
(
/
\.[
0-9
]
+s/
))
{
interval
=
parseFloat
(
interval
)
*
1000
+
"ms"
;
...
...
@@ -247,20 +251,20 @@ function (angular, _, kbn) {
query
.
tags
=
angular
.
copy
(
target
.
tags
);
if
(
query
.
tags
){
for
(
var
key
in
query
.
tags
){
query
.
tags
[
key
]
=
templateSrv
.
replace
(
query
.
tags
[
key
]);
query
.
tags
[
key
]
=
templateSrv
.
replace
(
query
.
tags
[
key
]
,
options
.
scopedVars
);
}
}
return
query
;
}
function
mapMetricsToTargets
(
metrics
,
target
s
)
{
function
mapMetricsToTargets
(
metrics
,
option
s
)
{
var
interpolatedTagValue
;
return
_
.
map
(
metrics
,
function
(
metricData
)
{
return
_
.
findIndex
(
targets
,
function
(
target
)
{
return
_
.
findIndex
(
options
.
targets
,
function
(
target
)
{
return
target
.
metric
===
metricData
.
metric
&&
_
.
all
(
target
.
tags
,
function
(
tagV
,
tagK
)
{
interpolatedTagValue
=
templateSrv
.
replace
(
tagV
);
interpolatedTagValue
=
templateSrv
.
replace
(
tagV
,
options
.
scopedVars
);
return
metricData
.
tags
[
tagK
]
===
interpolatedTagValue
||
interpolatedTagValue
===
"*"
;
});
});
...
...
public/app/plugins/datasource/opentsdb/queryCtrl.js
View file @
8ed0df64
...
...
@@ -59,7 +59,7 @@ function (angular, _, kbn) {
};
$scope
.
suggestTagValues
=
function
(
query
,
callback
)
{
$scope
.
datasource
.
metricFindQuery
(
'tag_
nam
es('
+
$scope
.
target
.
metric
+
','
+
$scope
.
target
.
currentTagKey
+
')'
)
$scope
.
datasource
.
metricFindQuery
(
'tag_
valu
es('
+
$scope
.
target
.
metric
+
','
+
$scope
.
target
.
currentTagKey
+
')'
)
.
then
(
$scope
.
getTextValues
)
.
then
(
callback
);
};
...
...
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