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
921d672a
Commit
921d672a
authored
May 26, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Worked on alias pattern for InfluxDB 0.9 editor, #1525
parent
5f004f95
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
5 deletions
+33
-5
public/app/plugins/datasource/influxdb/influxSeries.js
+16
-1
public/test/specs/influxSeries-specs.js
+17
-4
No files found.
public/app/plugins/datasource/influxdb/influxSeries.js
View file @
921d672a
...
...
@@ -29,7 +29,7 @@ function (_) {
var
seriesName
=
series
.
name
;
if
(
self
.
alias
)
{
seriesName
=
self
.
alias
;
seriesName
=
self
.
_getSeriesName
(
series
)
;
}
else
if
(
series
.
tags
)
{
var
tags
=
_
.
map
(
series
.
tags
,
function
(
value
,
key
)
{
return
key
+
': '
+
value
;
...
...
@@ -44,6 +44,21 @@ function (_) {
return
output
;
};
p
.
_getSeriesName
=
function
(
series
)
{
var
regex
=
/
\$(\w
+
)
|
\[\[([\s\S]
+
?)\]\]
/g
;
return
this
.
alias
.
replace
(
regex
,
function
(
match
,
g1
,
g2
)
{
var
group
=
g1
||
g2
;
if
(
group
===
'm'
||
group
===
'measurement'
)
{
return
series
.
name
;
}
if
(
group
.
indexOf
(
'tag_'
)
!==
0
)
{
return
match
;
}
var
tag
=
group
.
replace
(
'tag_'
,
''
);
if
(
!
series
.
tags
)
{
return
match
;
}
return
series
.
tags
[
tag
];
});
};
p
.
getAnnotations
=
function
()
{
var
list
=
[];
var
self
=
this
;
...
...
public/test/specs/influxSeries-specs.js
View file @
921d672a
...
...
@@ -9,13 +9,13 @@ define([
var
options
=
{
series
:
[
{
name
:
'cpu'
,
tags
:
{
app
:
'test'
},
tags
:
{
app
:
'test'
,
server
:
'server1'
},
columns
:
[
'time'
,
'mean'
],
values
:
[[
"2015-05-18T10:57:05Z"
,
10
],
[
"2015-05-18T10:57:06Z"
,
12
]]
},
{
name
:
'cpu'
,
tags
:
{
app
:
'test2'
},
tags
:
{
app
:
'test2'
,
server
:
'server2'
},
columns
:
[
'time'
,
'mean'
],
values
:
[[
"2015-05-18T10:57:05Z"
,
15
],
[
"2015-05-18T10:57:06Z"
,
16
]]
}
...
...
@@ -28,13 +28,13 @@ define([
var
result
=
series
.
getTimeSeries
();
expect
(
result
.
length
).
to
.
be
(
2
);
expect
(
result
[
0
].
target
).
to
.
be
(
'cpu {app: test}'
);
expect
(
result
[
0
].
target
).
to
.
be
(
'cpu {app: test
, server: server1
}'
);
expect
(
result
[
0
].
datapoints
[
0
][
0
]).
to
.
be
(
10
);
expect
(
result
[
0
].
datapoints
[
0
][
1
]).
to
.
be
(
1431946625000
);
expect
(
result
[
0
].
datapoints
[
1
][
0
]).
to
.
be
(
12
);
expect
(
result
[
0
].
datapoints
[
1
][
1
]).
to
.
be
(
1431946626000
);
expect
(
result
[
1
].
target
).
to
.
be
(
'cpu {app: test2}'
);
expect
(
result
[
1
].
target
).
to
.
be
(
'cpu {app: test2
, server: server2
}'
);
expect
(
result
[
1
].
datapoints
[
0
][
0
]).
to
.
be
(
15
);
expect
(
result
[
1
].
datapoints
[
0
][
1
]).
to
.
be
(
1431946625000
);
expect
(
result
[
1
].
datapoints
[
1
][
0
]).
to
.
be
(
16
);
...
...
@@ -52,6 +52,19 @@ define([
});
});
describe
(
'and alias patterns'
,
function
()
{
it
(
'should replace patterns'
,
function
()
{
options
.
alias
=
'alias: $m -> $tag_server ([[measurement]])'
;
var
series
=
new
InfluxSeries
(
options
);
var
result
=
series
.
getTimeSeries
();
expect
(
result
[
0
].
target
).
to
.
be
(
'alias: cpu -> server1 (cpu)'
);
expect
(
result
[
1
].
target
).
to
.
be
(
'alias: cpu -> server2 (cpu)'
);
});
});
});
});
...
...
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