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
9ccdd4b8
Unverified
Commit
9ccdd4b8
authored
May 18, 2020
by
zhulongcheng
Committed by
GitHub
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TSDB: show influxdb error message (#24393)
Closes #21647 Signed-off-by: zhulongcheng <zhulongcheng.dev@gmail.com>
parent
cc6df0ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
pkg/tsdb/influxdb/response_parser.go
+3
-0
pkg/tsdb/influxdb/response_parser_test.go
+51
-0
No files found.
pkg/tsdb/influxdb/response_parser.go
View file @
9ccdd4b8
...
...
@@ -26,6 +26,9 @@ func (rp *ResponseParser) Parse(response *Response, query *Query) *tsdb.QueryRes
for
_
,
result
:=
range
response
.
Results
{
queryRes
.
Series
=
append
(
queryRes
.
Series
,
rp
.
transformRows
(
result
.
Series
,
queryRes
,
query
)
...
)
if
result
.
Err
!=
nil
{
queryRes
.
Error
=
result
.
Err
}
}
return
queryRes
...
...
pkg/tsdb/influxdb/response_parser_test.go
View file @
9ccdd4b8
...
...
@@ -2,6 +2,7 @@ package influxdb
import
(
"encoding/json"
"fmt"
"testing"
"github.com/grafana/grafana/pkg/setting"
...
...
@@ -172,5 +173,55 @@ func TestInfluxdbResponseParser(t *testing.T) {
})
})
})
Convey
(
"Response parser with errors"
,
func
()
{
parser
:=
&
ResponseParser
{}
cfg
:=
setting
.
NewCfg
()
err
:=
cfg
.
Load
(
&
setting
.
CommandLineArgs
{
HomePath
:
"../../../"
,
})
So
(
err
,
ShouldBeNil
)
response
:=
&
Response
{
Results
:
[]
Result
{
{
Series
:
[]
Row
{
{
Name
:
"cpu"
,
Columns
:
[]
string
{
"time"
,
"mean"
,
"sum"
},
Tags
:
map
[
string
]
string
{
"datacenter"
:
"America"
},
Values
:
[][]
interface
{}{
{
json
.
Number
(
"111"
),
json
.
Number
(
"222"
),
json
.
Number
(
"333"
)},
{
json
.
Number
(
"111"
),
json
.
Number
(
"222"
),
json
.
Number
(
"333"
)},
{
json
.
Number
(
"111"
),
json
.
Number
(
"null"
),
json
.
Number
(
"333"
)},
},
},
},
},
{
Err
:
fmt
.
Errorf
(
"query-timeout limit exceeded"
),
},
},
}
query
:=
&
Query
{}
result
:=
parser
.
Parse
(
response
,
query
)
Convey
(
"can parse all series"
,
func
()
{
So
(
len
(
result
.
Series
),
ShouldEqual
,
2
)
})
Convey
(
"can parse all points"
,
func
()
{
So
(
len
(
result
.
Series
[
0
]
.
Points
),
ShouldEqual
,
3
)
So
(
len
(
result
.
Series
[
1
]
.
Points
),
ShouldEqual
,
3
)
})
Convey
(
"can parse errors "
,
func
()
{
So
(
result
.
Error
,
ShouldNotBeNil
)
So
(
result
.
Error
.
Error
(),
ShouldEqual
,
"query-timeout limit exceeded"
)
})
})
})
}
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