-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Cristian Greco <[email protected]>
- Loading branch information
1 parent
e640767
commit 039ba23
Showing
3 changed files
with
126 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: v1alpha1 | ||
discovery: | ||
exportedTagsOnMetrics: | ||
qldb: | ||
- Name | ||
jobs: | ||
- type: qldb | ||
regions: | ||
- us-east-2 | ||
period: 300 | ||
length: 300 | ||
metrics: | ||
- name: JournalStorage | ||
statistics: | ||
- Average | ||
- name: IndexedStorage | ||
statistics: | ||
- Average | ||
- name: ReadIOs | ||
statistics: | ||
- Sum | ||
- name: WriteIOs | ||
statistics: | ||
- Sum | ||
- name: CommandLatency | ||
statistics: | ||
- Average | ||
- name: OccConflictExceptions | ||
statistics: | ||
- Sum | ||
- name: Session4xxExceptions | ||
statistics: | ||
- Sum | ||
- name: Session5xxExceptions | ||
statistics: | ||
- Sum | ||
- name: SessionRateExceededExceptions | ||
statistics: | ||
- Sum | ||
|
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,76 @@ | ||
package maxdimassociator | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/grafana/regexp" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/nerdswords/yet-another-cloudwatch-exporter/pkg/config" | ||
"github.com/nerdswords/yet-another-cloudwatch-exporter/pkg/logging" | ||
"github.com/nerdswords/yet-another-cloudwatch-exporter/pkg/model" | ||
) | ||
|
||
var validQldbInstance = &model.TaggedResource{ | ||
ARN: "arn:aws:qldb:us-east-1:123456789012:ledger/test1", | ||
Namespace: "AWS/QLDB", | ||
} | ||
|
||
func TestAssociatorQLDB(t *testing.T) { | ||
type args struct { | ||
dimensionRegexps []*regexp.Regexp | ||
resources []*model.TaggedResource | ||
metric *model.Metric | ||
} | ||
|
||
type testCase struct { | ||
name string | ||
args args | ||
expectedSkip bool | ||
expectedResource *model.TaggedResource | ||
} | ||
|
||
testcases := []testCase{ | ||
{ | ||
name: "should match with ledger name dimension", | ||
args: args{ | ||
dimensionRegexps: config.SupportedServices.GetService("AWS/QLDB").DimensionRegexps, | ||
resources: []*model.TaggedResource{validQldbInstance}, | ||
metric: &model.Metric{ | ||
Namespace: "AWS/QLDB", | ||
MetricName: "JournalStorage", | ||
Dimensions: []*model.Dimension{ | ||
{Name: "LedgerName", Value: "test2"}, | ||
}, | ||
}, | ||
}, | ||
expectedSkip: true, | ||
expectedResource: nil, | ||
}, | ||
{ | ||
name: "should not match with ledger name dimension when QLDB arn is not valid", | ||
args: args{ | ||
dimensionRegexps: config.SupportedServices.GetService("AWS/QLDB").DimensionRegexps, | ||
resources: []*model.TaggedResource{validQldbInstance}, | ||
metric: &model.Metric{ | ||
Namespace: "AWS/QLDB", | ||
MetricName: "JournalStorage", | ||
Dimensions: []*model.Dimension{ | ||
{Name: "LedgerName", Value: "test1"}, | ||
}, | ||
}, | ||
}, | ||
expectedSkip: false, | ||
expectedResource: validQldbInstance, | ||
}, | ||
} | ||
|
||
for _, tc := range testcases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
associator := NewAssociator(logging.NewNopLogger(), tc.args.dimensionRegexps, tc.args.resources) | ||
res, skip := associator.AssociateMetricToResource(tc.args.metric) | ||
require.Equal(t, tc.expectedSkip, skip) | ||
require.Equal(t, tc.expectedResource, res) | ||
}) | ||
} | ||
} |