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
3b235612
Commit
3b235612
authored
Mar 29, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
elasticsearch: improve validation and error message when adding/testing elasticsearch ds, #7836
parent
5702c574
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
public/app/plugins/datasource/elasticsearch/datasource.js
+15
-5
public/app/plugins/datasource/elasticsearch/query_builder.js
+3
-1
No files found.
public/app/plugins/datasource/elasticsearch/datasource.js
View file @
3b235612
...
...
@@ -168,12 +168,22 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
};
this
.
testDatasource
=
function
()
{
timeSrv
.
setTime
({
from
:
'now-1m'
,
to
:
'now'
});
return
this
.
_get
(
'/_stats'
).
then
(
function
()
{
return
{
status
:
"success"
,
message
:
"Data source is working"
,
title
:
"Success"
};
},
function
(
err
)
{
timeSrv
.
setTime
({
from
:
'now-1m'
,
to
:
'now'
},
true
);
// validate that the index exist and has date field
return
this
.
getFields
({
type
:
'date'
}).
then
(
function
(
dateFields
)
{
var
timeField
=
_
.
find
(
dateFields
,
{
text
:
this
.
timeField
});
if
(
!
timeField
)
{
return
{
status
:
"error"
,
message
:
"No date field named "
+
this
.
timeField
+
' found'
,
title
:
"Error"
};
}
return
{
status
:
"success"
,
message
:
"Index OK. Time field name OK."
,
title
:
"Success"
};
}.
bind
(
this
),
function
(
err
)
{
console
.
log
(
err
);
if
(
err
.
data
&&
err
.
data
.
error
)
{
return
{
status
:
"error"
,
message
:
angular
.
toJson
(
err
.
data
.
error
),
title
:
"Error"
};
var
message
=
angular
.
toJson
(
err
.
data
.
error
);
if
(
err
.
data
.
error
.
reason
)
{
message
=
err
.
data
.
error
.
reason
;
}
return
{
status
:
"error"
,
message
:
message
,
title
:
"Error"
};
}
else
{
return
{
status
:
"error"
,
message
:
err
.
status
,
title
:
"Error"
};
}
...
...
public/app/plugins/datasource/elasticsearch/query_builder.js
View file @
3b235612
...
...
@@ -280,10 +280,12 @@ function (queryDef) {
}
});
}
var
size
=
500
;
if
(
queryDef
.
size
)
{
if
(
queryDef
.
size
)
{
size
=
queryDef
.
size
;
}
query
.
aggs
=
{
"1"
:
{
"terms"
:
{
...
...
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