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
8fcc370f
Unverified
Commit
8fcc370f
authored
Jun 27, 2019
by
Torkel Ödegaard
Committed by
GitHub
Jun 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Graphite: Fixes issue with seriesByTag & function with variable param (#17795)
Fixes #17696
parent
3045daed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
+23
-12
public/app/plugins/datasource/graphite/graphite_query.ts
+10
-12
public/app/plugins/datasource/graphite/specs/graphite_query.test.ts
+13
-0
No files found.
public/app/plugins/datasource/graphite/graphite_query.ts
View file @
8fcc370f
...
@@ -29,6 +29,7 @@ export default class GraphiteQuery {
...
@@ -29,6 +29,7 @@ export default class GraphiteQuery {
this
.
functions
=
[];
this
.
functions
=
[];
this
.
segments
=
[];
this
.
segments
=
[];
this
.
tags
=
[];
this
.
tags
=
[];
this
.
seriesByTagUsed
=
false
;
this
.
error
=
null
;
this
.
error
=
null
;
if
(
this
.
target
.
textEditor
)
{
if
(
this
.
target
.
textEditor
)
{
...
@@ -57,17 +58,6 @@ export default class GraphiteQuery {
...
@@ -57,17 +58,6 @@ export default class GraphiteQuery {
}
}
this
.
checkOtherSegmentsIndex
=
this
.
segments
.
length
-
1
;
this
.
checkOtherSegmentsIndex
=
this
.
segments
.
length
-
1
;
this
.
checkForSeriesByTag
();
}
checkForSeriesByTag
()
{
const
seriesByTagFunc
:
any
=
_
.
find
(
this
.
functions
,
func
=>
func
.
def
.
name
===
'seriesByTag'
);
if
(
seriesByTagFunc
)
{
this
.
seriesByTagUsed
=
true
;
seriesByTagFunc
.
hidden
=
true
;
const
tags
=
this
.
splitSeriesByTagParams
(
seriesByTagFunc
);
this
.
tags
=
tags
;
}
}
}
getSegmentPathUpTo
(
index
)
{
getSegmentPathUpTo
(
index
)
{
...
@@ -98,6 +88,14 @@ export default class GraphiteQuery {
...
@@ -98,6 +88,14 @@ export default class GraphiteQuery {
innerFunc
.
updateText
();
innerFunc
.
updateText
();
this
.
functions
.
push
(
innerFunc
);
this
.
functions
.
push
(
innerFunc
);
// extract tags from seriesByTag function and hide function
if
(
innerFunc
.
def
.
name
===
'seriesByTag'
&&
!
this
.
seriesByTagUsed
)
{
this
.
seriesByTagUsed
=
true
;
innerFunc
.
hidden
=
true
;
this
.
tags
=
this
.
splitSeriesByTagParams
(
innerFunc
);
}
break
;
break
;
case
'series-ref'
:
case
'series-ref'
:
if
(
this
.
segments
.
length
>
0
||
this
.
getSeriesByTagFuncIndex
()
>=
0
)
{
if
(
this
.
segments
.
length
>
0
||
this
.
getSeriesByTagFuncIndex
()
>=
0
)
{
...
@@ -112,7 +110,7 @@ export default class GraphiteQuery {
...
@@ -112,7 +110,7 @@ export default class GraphiteQuery {
this
.
addFunctionParameter
(
func
,
astNode
.
value
);
this
.
addFunctionParameter
(
func
,
astNode
.
value
);
break
;
break
;
case
'metric'
:
case
'metric'
:
if
(
this
.
segments
.
length
>
0
)
{
if
(
this
.
segments
.
length
||
this
.
tags
.
length
)
{
this
.
addFunctionParameter
(
func
,
_
.
join
(
_
.
map
(
astNode
.
segments
,
'value'
),
'.'
));
this
.
addFunctionParameter
(
func
,
_
.
join
(
_
.
map
(
astNode
.
segments
,
'value'
),
'.'
));
}
else
{
}
else
{
this
.
segments
=
astNode
.
segments
;
this
.
segments
=
astNode
.
segments
;
...
...
public/app/plugins/datasource/graphite/specs/graphite_query.test.ts
View file @
8fcc370f
...
@@ -57,4 +57,17 @@ describe('Graphite query model', () => {
...
@@ -57,4 +57,17 @@ describe('Graphite query model', () => {
expect
(
ctx
.
queryModel
.
functions
[
1
].
params
[
0
]).
toBe
(
'#A'
);
expect
(
ctx
.
queryModel
.
functions
[
1
].
params
[
0
]).
toBe
(
'#A'
);
});
});
});
});
describe
(
'when query has seriesByTag and highestMax with variable param'
,
()
=>
{
beforeEach
(()
=>
{
ctx
.
target
=
{
refId
:
'A'
,
target
:
`highestMax(seriesByTag('namespace=asd'), $limit)`
};
ctx
.
targets
=
[
ctx
.
target
];
ctx
.
queryModel
=
new
GraphiteQuery
(
ctx
.
datasource
,
ctx
.
target
,
ctx
.
templateSrv
);
});
it
(
'should add $limit to highestMax function param'
,
()
=>
{
expect
(
ctx
.
queryModel
.
segments
.
length
).
toBe
(
0
);
expect
(
ctx
.
queryModel
.
functions
[
1
].
params
[
0
]).
toBe
(
'$limit'
);
});
});
});
});
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