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
e921f3b6
Unverified
Commit
e921f3b6
authored
Jul 24, 2018
by
Marcus Efraimsson
Committed by
GitHub
Jul 24, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12698 from mtanda/cw_400_err
CloudWatch backend return 400 if user input error
parents
a63fca03
d9bf8943
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
pkg/api/metrics.go
+1
-1
pkg/tsdb/cloudwatch/cloudwatch.go
+17
-4
No files found.
pkg/api/metrics.go
View file @
e921f3b6
...
...
@@ -52,7 +52,7 @@ func QueryMetrics(c *m.ReqContext, reqDto dtos.MetricRequest) Response {
if
res
.
Error
!=
nil
{
res
.
ErrorString
=
res
.
Error
.
Error
()
resp
.
Message
=
res
.
ErrorString
statusCode
=
5
00
statusCode
=
4
00
}
}
...
...
pkg/tsdb/cloudwatch/cloudwatch.go
View file @
e921f3b6
...
...
@@ -17,6 +17,7 @@ import (
"golang.org/x/sync/errgroup"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
...
...
@@ -100,7 +101,10 @@ func (e *CloudWatchExecutor) executeTimeSeriesQuery(ctx context.Context, queryCo
query
,
err
:=
parseQuery
(
queryContext
.
Queries
[
i
]
.
Model
)
if
err
!=
nil
{
return
nil
,
err
result
.
Results
[
query
.
RefId
]
=
&
tsdb
.
QueryResult
{
Error
:
err
,
}
return
result
,
nil
}
query
.
RefId
=
queryContext
.
Queries
[
i
]
.
RefId
...
...
@@ -113,15 +117,21 @@ func (e *CloudWatchExecutor) executeTimeSeriesQuery(ctx context.Context, queryCo
}
if
query
.
Id
==
""
&&
query
.
Expression
!=
""
{
return
nil
,
fmt
.
Errorf
(
"Invalid query: id should be set if using expression"
)
result
.
Results
[
query
.
RefId
]
=
&
tsdb
.
QueryResult
{
Error
:
fmt
.
Errorf
(
"Invalid query: id should be set if using expression"
),
}
return
result
,
nil
}
eg
.
Go
(
func
()
error
{
queryRes
,
err
:=
e
.
executeQuery
(
ectx
,
query
,
queryContext
)
if
err
!=
nil
{
if
ae
,
ok
:=
err
.
(
awserr
.
Error
);
ok
&&
ae
.
Code
()
==
"500"
{
return
err
}
result
.
Results
[
queryRes
.
RefId
]
=
queryRes
if
err
!=
nil
{
result
.
Results
[
queryRes
.
RefId
]
.
Error
=
err
}
return
nil
})
}
...
...
@@ -131,11 +141,14 @@ func (e *CloudWatchExecutor) executeTimeSeriesQuery(ctx context.Context, queryCo
q
:=
getMetricDataQuery
eg
.
Go
(
func
()
error
{
queryResponses
,
err
:=
e
.
executeGetMetricDataQuery
(
ectx
,
region
,
q
,
queryContext
)
if
err
!=
nil
{
if
ae
,
ok
:=
err
.
(
awserr
.
Error
);
ok
&&
ae
.
Code
()
==
"500"
{
return
err
}
for
_
,
queryRes
:=
range
queryResponses
{
result
.
Results
[
queryRes
.
RefId
]
=
queryRes
if
err
!=
nil
{
result
.
Results
[
queryRes
.
RefId
]
.
Error
=
err
}
}
return
nil
})
...
...
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