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
5d64568f
Commit
5d64568f
authored
Oct 29, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring: some minor refactoring and changes to AWS profile PR #3053
parent
374fbad0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
65 deletions
+20
-65
pkg/api/cloudwatch/cloudwatch.go
+6
-4
pkg/api/dataproxy.go
+1
-1
public/app/plugins/datasource/cloudwatch/datasource.js
+0
-3
public/app/plugins/datasource/cloudwatch/partials/config.html
+13
-57
No files found.
pkg/api/cloudwatch/cloudwatch.go
View file @
5d64568f
...
...
@@ -12,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/grafana/grafana/pkg/middleware"
m
"github.com/grafana/grafana/pkg/models"
)
type
actionHandler
func
(
*
cwRequest
,
*
middleware
.
Context
)
...
...
@@ -20,9 +21,9 @@ var actionHandlers map[string]actionHandler
type
cwRequest
struct
{
Region
string
`json:"region"`
Profile
string
`json:"profile"`
Action
string
`json:"action"`
Body
[]
byte
`json:"-"`
DataSource
*
m
.
DataSource
}
func
init
()
{
...
...
@@ -41,7 +42,7 @@ func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) {
creds
:=
credentials
.
NewChainCredentials
(
[]
credentials
.
Provider
{
&
credentials
.
EnvProvider
{},
&
credentials
.
SharedCredentialsProvider
{
Filename
:
""
,
Profile
:
req
.
Profil
e
},
&
credentials
.
SharedCredentialsProvider
{
Filename
:
""
,
Profile
:
req
.
DataSource
.
Databas
e
},
&
ec2rolecreds
.
EC2RoleProvider
{
ExpiryWindow
:
5
*
time
.
Minute
},
})
svc
:=
cloudwatch
.
New
(
&
aws
.
Config
{
...
...
@@ -85,7 +86,7 @@ func handleListMetrics(req *cwRequest, c *middleware.Context) {
creds
:=
credentials
.
NewChainCredentials
(
[]
credentials
.
Provider
{
&
credentials
.
EnvProvider
{},
&
credentials
.
SharedCredentialsProvider
{
Filename
:
""
,
Profile
:
req
.
Profil
e
},
&
credentials
.
SharedCredentialsProvider
{
Filename
:
""
,
Profile
:
req
.
DataSource
.
Databas
e
},
&
ec2rolecreds
.
EC2RoleProvider
{
ExpiryWindow
:
5
*
time
.
Minute
},
})
svc
:=
cloudwatch
.
New
(
&
aws
.
Config
{
...
...
@@ -145,9 +146,10 @@ func handleDescribeInstances(req *cwRequest, c *middleware.Context) {
c
.
JSON
(
200
,
resp
)
}
func
HandleRequest
(
c
*
middleware
.
Context
)
{
func
HandleRequest
(
c
*
middleware
.
Context
,
ds
*
m
.
DataSource
)
{
var
req
cwRequest
req
.
Body
,
_
=
ioutil
.
ReadAll
(
c
.
Req
.
Request
.
Body
)
req
.
DataSource
=
ds
json
.
Unmarshal
(
req
.
Body
,
&
req
)
if
handler
,
found
:=
actionHandlers
[
req
.
Action
];
!
found
{
...
...
pkg/api/dataproxy.go
View file @
5d64568f
...
...
@@ -97,7 +97,7 @@ func ProxyDataSourceRequest(c *middleware.Context) {
}
if
ds
.
Type
==
m
.
DS_CLOUDWATCH
{
cloudwatch
.
HandleRequest
(
c
)
cloudwatch
.
HandleRequest
(
c
,
ds
)
}
else
{
proxyPath
:=
c
.
Params
(
"*"
)
proxy
:=
NewReverseProxy
(
ds
,
proxyPath
,
targetUrl
)
...
...
public/app/plugins/datasource/cloudwatch/datasource.js
View file @
5d64568f
...
...
@@ -18,7 +18,6 @@ function (angular, _) {
this
.
supportMetrics
=
true
;
this
.
proxyUrl
=
datasource
.
url
;
this
.
defaultRegion
=
datasource
.
jsonData
.
defaultRegion
;
this
.
profile
=
datasource
.
jsonData
.
profile
;
}
CloudWatchDatasource
.
prototype
.
query
=
function
(
options
)
{
...
...
@@ -74,7 +73,6 @@ function (angular, _) {
CloudWatchDatasource
.
prototype
.
performTimeSeriesQuery
=
function
(
query
,
start
,
end
)
{
return
this
.
awsRequest
({
region
:
query
.
region
,
profile
:
this
.
profile
,
action
:
'GetMetricStatistics'
,
parameters
:
{
namespace
:
query
.
namespace
,
...
...
@@ -117,7 +115,6 @@ function (angular, _) {
CloudWatchDatasource
.
prototype
.
getDimensionValues
=
function
(
region
,
namespace
,
metricName
,
dimensions
)
{
var
request
=
{
region
:
templateSrv
.
replace
(
region
),
profile
:
this
.
profile
,
action
:
'ListMetrics'
,
parameters
:
{
namespace
:
templateSrv
.
replace
(
namespace
),
...
...
public/app/plugins/datasource/cloudwatch/partials/config.html
View file @
5d64568f
<br>
<h5>
CloudWatch details
</h5>
<div
class=
"tight-form last"
>
<div
class=
"editor-row"
>
<div
class=
"section tight-form-container"
style=
"margin-bottom: 20px"
>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 16
0px"
>
Default Region
<tip>
Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.
</tip>
<li
class=
"tight-form-item"
style=
"width: 20
0px"
>
Credentials profile name
<tip>
Credentials profile name, as specified in ~/.aws/credentials, leave blank for default
</tip>
</li>
<li>
<input
type=
"text"
class=
"tight-form-input input-xlarge"
ng-model=
'current.jsonData.defaultRegion'
placeholder=
"
"
required
></input>
<input
type=
"text"
class=
"tight-form-input input-large last"
ng-model=
'current.database'
placeholder=
"default
"
required
></input>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form last
"
>
</div>
<div
class=
"tight-form
"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 16
0px"
>
AWS Profile
<li
class=
"tight-form-item"
style=
"width: 20
0px"
>
Default Region
<tip>
Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.
</tip>
</li>
<li>
<input
type=
"text"
class=
"tight-form-input input-xlarge"
ng-model=
'current.jsonData.profile'
placeholder=
"default
"
required
></input>
<input
type=
"text"
class=
"tight-form-input input-large last"
ng-model=
'current.jsonData.defaultRegion'
placeholder=
"
"
required
></input>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
</div>
</div>
<!-- <div class="tight-form" ng-show="current.jsonData.access === 'direct'"> -->
<!-- <ul class="tight-form-list"> -->
<!-- <li class="tight-form-item" style="width: 160px"> -->
<!-- </li> -->
<!-- <li> -->
<!-- <input type="text" class="tight-form-input input-xlarge" ng-model='current.jsonData.accessKeyId' placeholder=""></input> -->
<!-- </li> -->
<!-- </ul> -->
<!-- <div class="clearfix"></div> -->
<!-- </div> -->
<!-- <div class="tight-form" ng-show="current.jsonData.access === 'direct'"> -->
<!-- <ul class="tight-form-list"> -->
<!-- <li class="tight-form-item" style="width: 160px"> -->
<!-- Access Key Id -->
<!-- </li> -->
<!-- <li> -->
<!-- <input type="text" class="tight-form-input input-xlarge" ng-model='current.jsonData.accessKeyId' placeholder=""></input> -->
<!-- </li> -->
<!-- </ul> -->
<!-- <div class="clearfix"></div> -->
<!-- </div> -->
<!-- <div class="tight-form" ng-show="current.jsonData.access === 'direct'"> -->
<!-- <ul class="tight-form-list"> -->
<!-- <li class="tight-form-item" style="width: 160px"> -->
<!-- Secret Access Key -->
<!-- </li> -->
<!-- <li> -->
<!-- <input type="password" class="tight-form-input input-xlarge" ng-model='current.jsonData.secretAccessKey' placeholder=""></input> -->
<!-- </li> -->
<!-- </ul> -->
<!-- <div class="clearfix"></div> -->
<!-- </div> -->
<!-- <div class="tight-form last"> -->
<!-- <ul class="tight-form-list"> -->
<!-- <li class="tight-form-item" style="width: 160px"> -->
<!-- Custom Metric Attributes -->
<!-- </li> -->
<!-- <li> -->
<!-- <input type="text" class="tight-form-input input-xlarge" -->
<!-- ng-model='current.jsonData.customMetricsAttributes[0]' -->
<!-- ng-init="current.jsonData.customMetricsAttributes = current.jsonData.customMetricsAttributes || []" placeholder="JSON url" bs-tooltip="'Set JSON url of the result, \'aws cloudwatch list-metrics --output json\''"> -->
<!-- </input> -->
<!-- </li> -->
<!-- </ul> -->
<!-- <div class="clearfix"></div> -->
<!-- </div> -->
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