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
4d0c04b8
Commit
4d0c04b8
authored
Jun 04, 2015
by
Masaori Koshiba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tag support
parent
e9a84225
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
11 deletions
+64
-11
public/app/plugins/datasource/kairosdb/datasource.js
+64
-11
No files found.
public/app/plugins/datasource/kairosdb/datasource.js
View file @
4d0c04b8
...
...
@@ -91,6 +91,34 @@ function (angular, _, kbn) {
});
};
KairosDBDatasource
.
prototype
.
performListTagNames
=
function
()
{
var
options
=
{
url
:
this
.
url
+
'/api/v1/tagnames'
,
method
:
'GET'
};
return
$http
(
options
).
then
(
function
(
response
)
{
if
(
!
response
.
data
)
{
return
[];
}
return
response
.
data
.
results
;
});
};
KairosDBDatasource
.
prototype
.
performListTagValues
=
function
()
{
var
options
=
{
url
:
this
.
url
+
'/api/v1/tagvalues'
,
method
:
'GET'
};
return
$http
(
options
).
then
(
function
(
response
)
{
if
(
!
response
.
data
)
{
return
[];
}
return
response
.
data
.
results
;
});
};
KairosDBDatasource
.
prototype
.
performTagSuggestQuery
=
function
(
metricname
)
{
var
options
=
{
url
:
this
.
url
+
'/api/v1/datapoints/query/tags'
,
...
...
@@ -113,6 +141,20 @@ function (angular, _, kbn) {
};
KairosDBDatasource
.
prototype
.
metricFindQuery
=
function
(
query
)
{
function
format
(
results
,
query
)
{
return
_
.
chain
(
results
)
.
filter
(
function
(
result
)
{
return
result
.
indexOf
(
query
)
>=
0
;
})
.
map
(
function
(
result
)
{
return
{
text
:
result
,
expandable
:
true
};
})
.
value
();
}
var
interpolated
;
try
{
interpolated
=
templateSrv
.
replace
(
query
);
...
...
@@ -121,19 +163,30 @@ function (angular, _, kbn) {
return
$q
.
reject
(
err
);
}
var
metrics_regex
=
/metrics
\((
.*
)\)
/
;
var
tag_names_regex
=
/tag_names
\((
.*
)\)
/
;
var
tag_values_regex
=
/tag_values
\((
.*
)\)
/
;
var
metrics_query
=
interpolated
.
match
(
metrics_regex
);
if
(
metrics_query
)
{
return
this
.
performMetricSuggestQuery
().
then
(
function
(
metrics
)
{
return
_
.
chain
(
metrics
)
.
filter
(
function
(
metric
)
{
return
metric
.
indexOf
(
interpolated
)
>=
0
;
})
.
map
(
function
(
metric
)
{
return
{
text
:
metric
,
expandable
:
true
};
})
.
value
();
return
format
(
metrics
,
metrics_query
[
1
]);
});
}
var
tag_names_query
=
interpolated
.
match
(
tag_names_regex
);
if
(
tag_names_query
)
{
return
this
.
performListTagNames
().
then
(
function
(
tag_names
)
{
return
format
(
tag_names
,
tag_names_query
[
1
]);
});
}
var
tag_values_query
=
interpolated
.
match
(
tag_values_regex
);
if
(
tag_values_query
)
{
return
this
.
performListTagValues
().
then
(
function
(
tag_values
)
{
return
format
(
tag_values
,
tag_values_query
[
1
]);
});
}
};
/////////////////////////////////////////////////////////////////////////
...
...
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