forked from K-Phoen/grabana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from breeze7086/support-cloudwatch-target
Private fork and add support of Cloudwatch target
- Loading branch information
Showing
27 changed files
with
172 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/K-Phoen/grabana | ||
module github.com/breeze7086/grabana | ||
|
||
go 1.13 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package cloudwatch | ||
|
||
type Option func(target *Cloudwatch) | ||
|
||
type Cloudwatch struct { | ||
Namespace string | ||
MetricName string | ||
Statistics []string | ||
Dimensions map[string]string | ||
Region string | ||
Period string | ||
|
||
Ref string | ||
Hidden bool | ||
Alias string | ||
Expression string | ||
} | ||
|
||
func New(namespace string, metricName string, statistics []string, dimensions map[string]string, region string, period string, options ...Option) *Cloudwatch { | ||
cloudwatch := &Cloudwatch{ | ||
Namespace: namespace, | ||
MetricName: metricName, | ||
Statistics: statistics, | ||
Dimensions: dimensions, | ||
Region: region, | ||
Period: period, | ||
} | ||
|
||
for _, opt := range options { | ||
opt(cloudwatch) | ||
} | ||
|
||
return cloudwatch | ||
} | ||
|
||
func Ref(ref string) Option { | ||
return func(cloudwatch *Cloudwatch) { | ||
cloudwatch.Ref = ref | ||
} | ||
} | ||
|
||
func Hide() Option { | ||
return func(cloudwatch *Cloudwatch) { | ||
cloudwatch.Hidden = true | ||
} | ||
} | ||
|
||
func Alias(alias string) Option { | ||
return func(cloudwatch *Cloudwatch) { | ||
cloudwatch.Alias = alias | ||
} | ||
} | ||
|
||
func Expression(expr string) Option { | ||
return func(cloudwatch *Cloudwatch) { | ||
cloudwatch.Expression = expr | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cloudwatch_test | ||
|
||
import ( | ||
"github.com/breeze7086/grabana/target/cloudwatch" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestNewCloudwatchTargetCanBeCreated(t *testing.T) { | ||
req := require.New(t) | ||
|
||
namespace := "LBProvisionedLCU" | ||
metricName := "ProvisionedLCU" | ||
statistics := []string{"Average"} | ||
dimensions := map[string]string{ | ||
"Loadbalancer Name": "9f2e1c28-default-prometheu-0928", | ||
} | ||
region := "us-east-1" | ||
period := "" | ||
|
||
target := cloudwatch.New(namespace, metricName, statistics, dimensions, region, period) | ||
|
||
req.Equal(namespace, target.Namespace) | ||
req.Equal(metricName, target.MetricName) | ||
req.Equal(statistics, target.Statistics) | ||
req.Equal(dimensions, target.Dimensions) | ||
req.Equal(region, target.Region) | ||
req.Equal(period, target.Period) | ||
} |
Oops, something went wrong.