-
-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auto-discovery for Directory Services(MicrosoftAD)
Signed-off-by: Ruslan Mustaev <[email protected]>
- Loading branch information
1 parent
bd6b01e
commit d287301
Showing
4 changed files
with
103 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
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,19 @@ | ||
apiVersion: v1alpha1 | ||
discovery: | ||
jobs: | ||
- type: AWS/DirectoryService | ||
regions: | ||
- us-east-1 | ||
period: 300 | ||
length: 300 | ||
metrics: | ||
- name: "Bytes Sent/sec" | ||
statistics: [Average] | ||
- name: "% Processor Time" | ||
statistics: [Average] | ||
- name: "DS Directory Searches/Sec" | ||
statistics: [Average] | ||
- name: "Database Cache % Hit" | ||
statistics: [Average] | ||
- name: "% Free Space" | ||
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
73 changes: 73 additions & 0 deletions
73
pkg/job/maxdimassociator/associator_directoryservice_test.go
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,73 @@ | ||
// Copyright 2024 The Prometheus Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package maxdimassociator | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/prometheus-community/yet-another-cloudwatch-exporter/pkg/config" | ||
"github.com/prometheus-community/yet-another-cloudwatch-exporter/pkg/logging" | ||
"github.com/prometheus-community/yet-another-cloudwatch-exporter/pkg/model" | ||
) | ||
|
||
var directory = &model.TaggedResource{ | ||
ARN: "arn:aws:ds::012345678901:directory/d-abc123", | ||
Namespace: "AWS/DirectoryService", | ||
} | ||
|
||
func TestAssociatorDirectoryService(t *testing.T) { | ||
type args struct { | ||
dimensionRegexps []model.DimensionsRegexp | ||
resources []*model.TaggedResource | ||
metric *model.Metric | ||
} | ||
|
||
type testCase struct { | ||
name string | ||
args args | ||
expectedSkip bool | ||
expectedResource *model.TaggedResource | ||
} | ||
|
||
testcases := []testCase{ | ||
{ | ||
name: "should match directory id with Directory ID dimension", | ||
args: args{ | ||
dimensionRegexps: config.SupportedServices.GetService("AWS/DirectoryService").ToModelDimensionsRegexp(), | ||
resources: []*model.TaggedResource{directory}, | ||
metric: &model.Metric{ | ||
MetricName: "Current Bandwidth", | ||
Namespace: "AWS/DirectoryService", | ||
Dimensions: []model.Dimension{ | ||
{Name: "Metric Category", Value: "NTDS"}, | ||
{Name: "Domain Controller IP", Value: "123.123.123.123"}, | ||
{Name: "Directory ID", Value: "d-abc123"}, | ||
}, | ||
}, | ||
}, | ||
expectedSkip: false, | ||
expectedResource: directory, | ||
}, | ||
} | ||
|
||
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) | ||
}) | ||
} | ||
} |