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
93665f49
Commit
93665f49
authored
May 23, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v3.0.x'
parents
dfe3806d
dc77d555
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
public/app/features/templating/templateSrv.js
+11
-7
public/app/plugins/datasource/elasticsearch/datasource.js
+11
-3
No files found.
public/app/features/templating/templateSrv.js
View file @
93665f49
...
...
@@ -42,6 +42,16 @@ function (angular, _) {
return
value
.
replace
(
/
([\!\*\+\-\=
<>
\s\&\|\(\)\[\]\{\}\^\~\?\:\\/
"
])
/g
,
"
\\
$1"
);
}
this
.
luceneFormat
=
function
(
value
)
{
if
(
typeof
value
===
'string'
)
{
return
luceneEscape
(
value
);
}
var
quotedValues
=
_
.
map
(
value
,
function
(
val
)
{
return
'
\
"'
+
luceneEscape
(
val
)
+
'
\
"'
;
});
return
'('
+
quotedValues
.
join
(
' OR '
)
+
')'
;
};
this
.
formatValue
=
function
(
value
,
format
,
variable
)
{
// for some scopedVars there is no variable
variable
=
variable
||
{};
...
...
@@ -60,13 +70,7 @@ function (angular, _) {
return
'('
+
escapedValues
.
join
(
'|'
)
+
')'
;
}
case
"lucene"
:
{
if
(
typeof
value
===
'string'
)
{
return
luceneEscape
(
value
);
}
var
quotedValues
=
_
.
map
(
value
,
function
(
val
)
{
return
'
\
"'
+
luceneEscape
(
val
)
+
'
\
"'
;
});
return
'('
+
quotedValues
.
join
(
' OR '
)
+
')'
;
return
this
.
luceneFormat
(
value
,
format
,
variable
);
}
case
"pipe"
:
{
if
(
typeof
value
===
'string'
)
{
...
...
public/app/plugins/datasource/elasticsearch/datasource.js
View file @
93665f49
...
...
@@ -78,7 +78,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
range
[
timeField
][
"format"
]
=
"epoch_millis"
;
}
var
queryInterpolated
=
templateSrv
.
replace
(
queryString
);
var
queryInterpolated
=
templateSrv
.
replace
(
queryString
,
{},
'lucene'
);
var
filter
=
{
"bool"
:
{
"must"
:
[{
"range"
:
range
}]
}
};
var
query
=
{
"bool"
:
{
"should"
:
[{
"query_string"
:
{
"query"
:
queryInterpolated
}
}]
}
};
var
data
=
{
...
...
@@ -204,6 +204,14 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
});
};
function
escapeForJson
(
value
)
{
return
value
.
replace
(
/
\"
/g
,
'
\\
"'
);
}
function
luceneThenJsonFormat
(
value
)
{
return
escapeForJson
(
templateSrv
.
luceneFormat
(
value
));
}
this
.
getFields
=
function
(
query
)
{
return
this
.
_get
(
'/_mapping'
).
then
(
function
(
res
)
{
var
fields
=
{};
...
...
@@ -246,7 +254,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
var
header
=
this
.
getQueryHeader
(
'count'
,
range
.
from
,
range
.
to
);
var
esQuery
=
angular
.
toJson
(
this
.
queryBuilder
.
getTermsQuery
(
queryDef
));
esQuery
=
esQuery
.
replace
(
"$lucene_query"
,
queryDef
.
query
||
'*'
);
esQuery
=
esQuery
.
replace
(
"$lucene_query"
,
escapeForJson
(
queryDef
.
query
||
'*'
)
);
esQuery
=
esQuery
.
replace
(
/
\$
timeFrom/g
,
range
.
from
.
valueOf
());
esQuery
=
esQuery
.
replace
(
/
\$
timeTo/g
,
range
.
to
.
valueOf
());
esQuery
=
header
+
'
\
n'
+
esQuery
+
'
\
n'
;
...
...
@@ -260,7 +268,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
};
this
.
metricFindQuery
=
function
(
query
)
{
query
=
templateSrv
.
replace
(
query
);
query
=
templateSrv
.
replace
(
query
,
{},
luceneThenJsonFormat
);
query
=
angular
.
fromJson
(
query
);
if
(
!
query
)
{
return
$q
.
when
([]);
...
...
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