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
ae93f2b9
Commit
ae93f2b9
authored
Oct 22, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(elasticsearch): fixed proper json escaping for lucene query, fixes #2981
parent
87715d62
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
8 deletions
+19
-8
public/app/plugins/datasource/elasticsearch/datasource.js
+4
-1
public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts
+14
-6
public/app/plugins/datasource/elasticsearch/specs/index_pattern_specs.ts
+1
-1
No files found.
public/app/plugins/datasource/elasticsearch/datasource.js
View file @
ae93f2b9
...
...
@@ -159,7 +159,10 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
if
(
target
.
hide
)
{
return
;}
var
esQuery
=
angular
.
toJson
(
this
.
queryBuilder
.
build
(
target
));
esQuery
=
esQuery
.
replace
(
"$lucene_query"
,
target
.
query
||
'*'
);
var
luceneQuery
=
angular
.
toJson
(
target
.
query
||
'*'
);
// remove inner quotes
luceneQuery
=
luceneQuery
.
substr
(
1
,
luceneQuery
.
length
-
2
);
esQuery
=
esQuery
.
replace
(
"$lucene_query"
,
luceneQuery
);
payload
+=
header
+
'
\
n'
+
esQuery
+
'
\
n'
;
sentTargets
.
push
(
target
);
...
...
public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts
View file @
ae93f2b9
...
...
@@ -42,16 +42,15 @@ describe('ElasticDatasource', function() {
});
describe
(
'When issueing metric query with interval pattern'
,
function
()
{
var
requestOptions
,
parts
,
header
;
beforeEach
(
function
()
{
ctx
.
ds
=
new
ctx
.
service
({
url
:
'http://es.com'
,
index
:
'[asd-]YYYY.MM.DD'
,
jsonData
:
{
interval
:
'Daily'
}
});
});
it
(
'should translate index pattern to current day'
,
function
()
{
var
requestOptions
;
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
requestOptions
=
options
;
return
ctx
.
$q
.
when
({
data
:
{
responses
:
[]}});
...
...
@@ -62,13 +61,22 @@ describe('ElasticDatasource', function() {
from
:
moment
([
2015
,
4
,
30
,
10
]),
to
:
moment
([
2015
,
5
,
1
,
10
])
},
targets
:
[{
bucketAggs
:
[],
metrics
:
[]
}]
targets
:
[{
bucketAggs
:
[],
metrics
:
[]
,
query
:
'escape
\\
:test'
}]
});
ctx
.
$rootScope
.
$apply
();
var
parts
=
requestOptions
.
data
.
split
(
'
\
n'
);
var
header
=
angular
.
fromJson
(
parts
[
0
]);
parts
=
requestOptions
.
data
.
split
(
'
\
n'
);
header
=
angular
.
fromJson
(
parts
[
0
]);
});
it
(
'should translate index pattern to current day'
,
function
()
{
expect
(
header
.
index
).
to
.
eql
([
'asd-2015.05.30'
,
'asd-2015.05.31'
,
'asd-2015.06.01'
]);
});
it
(
'should json escape lucene query'
,
function
()
{
var
body
=
angular
.
fromJson
(
parts
[
1
]);
expect
(
body
.
query
.
filtered
.
query
.
query_string
.
query
).
to
.
be
(
'escape
\\
:test'
);
});
});
});
public/app/plugins/datasource/elasticsearch/specs/index_pattern_specs.ts
View file @
ae93f2b9
...
...
@@ -8,7 +8,7 @@ declare var IndexPattern: any;
describe
(
'IndexPattern'
,
function
()
{
describe
.
only
(
'when getting index for today'
,
function
()
{
describe
(
'when getting index for today'
,
function
()
{
it
(
'should return correct index name'
,
function
()
{
var
pattern
=
new
IndexPattern
(
'[asd-]YYYY.MM.DD'
,
'Daily'
);
var
expected
=
'asd-'
+
moment
().
format
(
'YYYY.MM.DD'
);
...
...
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