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 (
...
@@ -12,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/middleware"
m
"github.com/grafana/grafana/pkg/models"
)
)
type
actionHandler
func
(
*
cwRequest
,
*
middleware
.
Context
)
type
actionHandler
func
(
*
cwRequest
,
*
middleware
.
Context
)
...
@@ -20,9 +21,9 @@ var actionHandlers map[string]actionHandler
...
@@ -20,9 +21,9 @@ var actionHandlers map[string]actionHandler
type
cwRequest
struct
{
type
cwRequest
struct
{
Region
string
`json:"region"`
Region
string
`json:"region"`
Profile
string
`json:"profile"`
Action
string
`json:"action"`
Action
string
`json:"action"`
Body
[]
byte
`json:"-"`
Body
[]
byte
`json:"-"`
DataSource
*
m
.
DataSource
}
}
func
init
()
{
func
init
()
{
...
@@ -41,7 +42,7 @@ func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) {
...
@@ -41,7 +42,7 @@ func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) {
creds
:=
credentials
.
NewChainCredentials
(
creds
:=
credentials
.
NewChainCredentials
(
[]
credentials
.
Provider
{
[]
credentials
.
Provider
{
&
credentials
.
EnvProvider
{},
&
credentials
.
EnvProvider
{},
&
credentials
.
SharedCredentialsProvider
{
Filename
:
""
,
Profile
:
req
.
Profil
e
},
&
credentials
.
SharedCredentialsProvider
{
Filename
:
""
,
Profile
:
req
.
DataSource
.
Databas
e
},
&
ec2rolecreds
.
EC2RoleProvider
{
ExpiryWindow
:
5
*
time
.
Minute
},
&
ec2rolecreds
.
EC2RoleProvider
{
ExpiryWindow
:
5
*
time
.
Minute
},
})
})
svc
:=
cloudwatch
.
New
(
&
aws
.
Config
{
svc
:=
cloudwatch
.
New
(
&
aws
.
Config
{
...
@@ -85,7 +86,7 @@ func handleListMetrics(req *cwRequest, c *middleware.Context) {
...
@@ -85,7 +86,7 @@ func handleListMetrics(req *cwRequest, c *middleware.Context) {
creds
:=
credentials
.
NewChainCredentials
(
creds
:=
credentials
.
NewChainCredentials
(
[]
credentials
.
Provider
{
[]
credentials
.
Provider
{
&
credentials
.
EnvProvider
{},
&
credentials
.
EnvProvider
{},
&
credentials
.
SharedCredentialsProvider
{
Filename
:
""
,
Profile
:
req
.
Profil
e
},
&
credentials
.
SharedCredentialsProvider
{
Filename
:
""
,
Profile
:
req
.
DataSource
.
Databas
e
},
&
ec2rolecreds
.
EC2RoleProvider
{
ExpiryWindow
:
5
*
time
.
Minute
},
&
ec2rolecreds
.
EC2RoleProvider
{
ExpiryWindow
:
5
*
time
.
Minute
},
})
})
svc
:=
cloudwatch
.
New
(
&
aws
.
Config
{
svc
:=
cloudwatch
.
New
(
&
aws
.
Config
{
...
@@ -145,9 +146,10 @@ func handleDescribeInstances(req *cwRequest, c *middleware.Context) {
...
@@ -145,9 +146,10 @@ func handleDescribeInstances(req *cwRequest, c *middleware.Context) {
c
.
JSON
(
200
,
resp
)
c
.
JSON
(
200
,
resp
)
}
}
func
HandleRequest
(
c
*
middleware
.
Context
)
{
func
HandleRequest
(
c
*
middleware
.
Context
,
ds
*
m
.
DataSource
)
{
var
req
cwRequest
var
req
cwRequest
req
.
Body
,
_
=
ioutil
.
ReadAll
(
c
.
Req
.
Request
.
Body
)
req
.
Body
,
_
=
ioutil
.
ReadAll
(
c
.
Req
.
Request
.
Body
)
req
.
DataSource
=
ds
json
.
Unmarshal
(
req
.
Body
,
&
req
)
json
.
Unmarshal
(
req
.
Body
,
&
req
)
if
handler
,
found
:=
actionHandlers
[
req
.
Action
];
!
found
{
if
handler
,
found
:=
actionHandlers
[
req
.
Action
];
!
found
{
...
...
pkg/api/dataproxy.go
View file @
5d64568f
...
@@ -97,7 +97,7 @@ func ProxyDataSourceRequest(c *middleware.Context) {
...
@@ -97,7 +97,7 @@ func ProxyDataSourceRequest(c *middleware.Context) {
}
}
if
ds
.
Type
==
m
.
DS_CLOUDWATCH
{
if
ds
.
Type
==
m
.
DS_CLOUDWATCH
{
cloudwatch
.
HandleRequest
(
c
)
cloudwatch
.
HandleRequest
(
c
,
ds
)
}
else
{
}
else
{
proxyPath
:=
c
.
Params
(
"*"
)
proxyPath
:=
c
.
Params
(
"*"
)
proxy
:=
NewReverseProxy
(
ds
,
proxyPath
,
targetUrl
)
proxy
:=
NewReverseProxy
(
ds
,
proxyPath
,
targetUrl
)
...
...
public/app/plugins/datasource/cloudwatch/datasource.js
View file @
5d64568f
...
@@ -18,7 +18,6 @@ function (angular, _) {
...
@@ -18,7 +18,6 @@ function (angular, _) {
this
.
supportMetrics
=
true
;
this
.
supportMetrics
=
true
;
this
.
proxyUrl
=
datasource
.
url
;
this
.
proxyUrl
=
datasource
.
url
;
this
.
defaultRegion
=
datasource
.
jsonData
.
defaultRegion
;
this
.
defaultRegion
=
datasource
.
jsonData
.
defaultRegion
;
this
.
profile
=
datasource
.
jsonData
.
profile
;
}
}
CloudWatchDatasource
.
prototype
.
query
=
function
(
options
)
{
CloudWatchDatasource
.
prototype
.
query
=
function
(
options
)
{
...
@@ -74,7 +73,6 @@ function (angular, _) {
...
@@ -74,7 +73,6 @@ function (angular, _) {
CloudWatchDatasource
.
prototype
.
performTimeSeriesQuery
=
function
(
query
,
start
,
end
)
{
CloudWatchDatasource
.
prototype
.
performTimeSeriesQuery
=
function
(
query
,
start
,
end
)
{
return
this
.
awsRequest
({
return
this
.
awsRequest
({
region
:
query
.
region
,
region
:
query
.
region
,
profile
:
this
.
profile
,
action
:
'GetMetricStatistics'
,
action
:
'GetMetricStatistics'
,
parameters
:
{
parameters
:
{
namespace
:
query
.
namespace
,
namespace
:
query
.
namespace
,
...
@@ -117,7 +115,6 @@ function (angular, _) {
...
@@ -117,7 +115,6 @@ function (angular, _) {
CloudWatchDatasource
.
prototype
.
getDimensionValues
=
function
(
region
,
namespace
,
metricName
,
dimensions
)
{
CloudWatchDatasource
.
prototype
.
getDimensionValues
=
function
(
region
,
namespace
,
metricName
,
dimensions
)
{
var
request
=
{
var
request
=
{
region
:
templateSrv
.
replace
(
region
),
region
:
templateSrv
.
replace
(
region
),
profile
:
this
.
profile
,
action
:
'ListMetrics'
,
action
:
'ListMetrics'
,
parameters
:
{
parameters
:
{
namespace
:
templateSrv
.
replace
(
namespace
),
namespace
:
templateSrv
.
replace
(
namespace
),
...
...
public/app/plugins/datasource/cloudwatch/partials/config.html
View file @
5d64568f
<br>
<br>
<h5>
CloudWatch details
</h5>
<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"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 16
0px"
>
<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>
Credentials profile name
<tip>
Credentials profile name, as specified in ~/.aws/credentials, leave blank for default
</tip>
</li>
</li>
<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>
</li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
</div>
</div>
<div
class=
"tight-form last
"
>
<div
class=
"tight-form
"
>
<ul
class=
"tight-form-list"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 16
0px"
>
<li
class=
"tight-form-item"
style=
"width: 20
0px"
>
AWS Profile
Default Region
<tip>
Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.
</tip>
</li>
</li>
<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>
</li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
</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