Skip to content

Commit b95099a

Browse files
nickbazinetnicolas.bazinetcristiangreco
authored
feat: Add support for Redshift-Serverless (#1589)
Signed-off-by: nickbazinet <[email protected]> Signed-off-by: Cristian Greco <[email protected]> Co-authored-by: nicolas.bazinet <[email protected]> Co-authored-by: Cristian Greco <[email protected]>
1 parent 8262f53 commit b95099a

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Only the latest version gets security updates. We won't support older versions.
122122
* `AWS/QuickSight` - QuickSight (Business Intelligence)
123123
* `AWS/RDS` - Relational Database Service
124124
* `AWS/Redshift` - Redshift Database
125+
* `AWS/Redshift-Serverless` - Redshift Serverless
125126
* `AWS/Route53` - Route53 Health Checks
126127
* `AWS/Route53Resolver` - Route53 Resolver
127128
* `AWS/RUM` - Real User Monitoring

examples/redshift-serverless.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1alpha1
2+
discovery:
3+
jobs:
4+
- type: AWS/Redshift-Serverless
5+
regions:
6+
- us-east-1
7+
period: 300
8+
length: 300
9+
metrics:
10+
- name: DatabaseConnections
11+
statistics: [Average]
12+
- name: ComputeCapacity
13+
statistics: [Average]
14+
- name: QueryRuntimeBreakdown
15+
statistics: [Average]
16+
- name: QueriesRunning
17+
statistics: [Average]
18+
- name: QueriesQueued
19+
statistics: [Average]
20+
- name: QueryDuration
21+
statistics: [Average]

pkg/config/services.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,14 @@ var SupportedServices = serviceConfigs{
770770
regexp.MustCompile(":cluster:(?P<ClusterIdentifier>[^/]+)"),
771771
},
772772
},
773+
{
774+
Namespace: "AWS/Redshift-Serverless",
775+
Alias: "redshift",
776+
ResourceFilters: []*string{
777+
aws.String("redshift-serverless:workgroup"),
778+
aws.String("redshift-serverless:namespace"),
779+
},
780+
},
773781
{
774782
Namespace: "AWS/Route53Resolver",
775783
Alias: "route53-resolver",
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright 2024 The Prometheus Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
package maxdimassociator
14+
15+
import (
16+
"testing"
17+
18+
"github.com/prometheus/common/promslog"
19+
"github.com/stretchr/testify/require"
20+
21+
"github.com/prometheus-community/yet-another-cloudwatch-exporter/pkg/config"
22+
"github.com/prometheus-community/yet-another-cloudwatch-exporter/pkg/model"
23+
)
24+
25+
var workgroup = &model.TaggedResource{
26+
ARN: "arn:aws:redshift-serverless:us-east-1:123456789012:workgroup/my-workgroup1",
27+
Namespace: "AWS/Redshift-Serverless",
28+
}
29+
30+
var namespace = &model.TaggedResource{
31+
ARN: "arn:aws:redshift-serverless:us-east-1:123456789012:namespace/my-namespace1",
32+
Namespace: "AWS/Redshift-Serverless",
33+
}
34+
35+
var redshiftResources = []*model.TaggedResource{
36+
workgroup,
37+
namespace,
38+
}
39+
40+
func TestAssociatorRedshiftServerless(t *testing.T) {
41+
type args struct {
42+
dimensionRegexps []model.DimensionsRegexp
43+
resources []*model.TaggedResource
44+
metric *model.Metric
45+
}
46+
47+
type testCase struct {
48+
name string
49+
args args
50+
expectedSkip bool
51+
expectedResource *model.TaggedResource
52+
}
53+
54+
testcases := []testCase{
55+
{
56+
name: "should not match nor skip with any workgroup none ARN dimension",
57+
args: args{
58+
dimensionRegexps: config.SupportedServices.GetService("AWS/Redshift-Serverless").ToModelDimensionsRegexp(),
59+
resources: redshiftResources,
60+
metric: &model.Metric{
61+
MetricName: "ComputeSeconds",
62+
Namespace: "AWS/Redshift-Serverless",
63+
Dimensions: []model.Dimension{
64+
{Name: "Workgroup", Value: "my-nonexistant-workgroup-test1"},
65+
},
66+
},
67+
},
68+
expectedSkip: false,
69+
expectedResource: nil,
70+
},
71+
}
72+
73+
for _, tc := range testcases {
74+
t.Run(tc.name, func(t *testing.T) {
75+
associator := NewAssociator(promslog.NewNopLogger(), tc.args.dimensionRegexps, tc.args.resources)
76+
res, skip := associator.AssociateMetricToResource(tc.args.metric)
77+
require.Equal(t, tc.expectedSkip, skip)
78+
require.Equal(t, tc.expectedResource, res)
79+
})
80+
}
81+
}

0 commit comments

Comments
 (0)