Skip to content

Commit

Permalink
[receiver/activedirectoryds] Add Active Directory Domain Services met…
Browse files Browse the repository at this point in the history
…rics receiver (open-telemetry#9359)

Adds the `activedirectoryds` metrics receiver, which scrapes metrics about a running  [Active Directory Domain Services](https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/get-started/virtual-dc/active-directory-domain-services-overview) instance.
  • Loading branch information
BinaryFissionGames committed Apr 20, 2022
1 parent 6fe7912 commit f49b291
Show file tree
Hide file tree
Showing 35 changed files with 4,759 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ processor/spanprocessor/ @open-telemetry/collector-c
processor/tailsamplingprocessor/ @open-telemetry/collector-contrib-approvers @jpkrohling
processor/transformprocessor/ @open-telemetry/collector-contrib-approvers @anuraaga @bogdandrutu

receiver/activedirectorydsreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @binaryfissiongames
receiver/apachereceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/awscontainerinsightreceiver/ @open-telemetry/collector-contrib-approvers @Aneurysm9 @pxaws
receiver/awsecscontainermetricsreceiver/ @open-telemetry/collector-contrib-approvers @anuraaga
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
uses: actions/checkout@v3
- name: install iis
run: Install-WindowsFeature -name Web-Server -IncludeManagementTools
- name: Install Active Directory DS
run: Install-WindowsFeature -name AD-Domain-Services -IncludeManagementTools
- name: Install SQL Server 2019 Dev
run: ./.github/workflows/scripts/sqlserver_install.ps1
- name: Setup Go
Expand All @@ -39,6 +41,11 @@ jobs:
run: go test --tags containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper ./...
- name: Run IIS Unit Tests
run: cd receiver/iisreceiver && go test --tags containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper ./...
- name: Run Active Directory DS Unit Tests
run: |
./testdata/scrape-available-counters.ps1
go test --tags containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper ./...
working-directory: ./receiver/activedirectorydsreceiver
- name: GitHub Issue Generator
if: ${{ failure() && github.ref == 'ref/head/main' }}
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

- `iisreceiver`: Add implementation of IIS Metric Receiver (#8832)
- `sqlserverreceiver`: Add implementation of SQL Server Metric Receiver (#8398)
- `activedirectorydsreceiver`: Add implementation of Active Directory Domain Services metric receiver (#9359)

### 💡 Enhancements 💡
- `pkg/translator/prometheusremotewrite`: Allow to disable sanitize metric labels (#8270)
Expand Down
3 changes: 3 additions & 0 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanmetricsprocessor v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver v0.0.0-00010101000000-000000000000 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver v0.49.0 // indirect
Expand Down Expand Up @@ -696,6 +697,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/span

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor => ../../processor/tailsamplingprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver => ../../receiver/activedirectorydsreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver => ../../receiver/awscontainerinsightreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver => ../../receiver/awsecscontainermetricsreceiver
Expand Down
288 changes: 288 additions & 0 deletions cmd/configschema/go.sum

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanmetricsprocessor v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver v0.0.0-00010101000000-000000000000
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver v0.49.0
Expand Down Expand Up @@ -702,6 +703,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/tail

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor => ./processor/transformprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver => ./receiver/activedirectorydsreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver => ./receiver/awscontainerinsightreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver => ./receiver/awsecscontainermetricsreceiver
Expand Down
2 changes: 2 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanmetricsprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver"
Expand Down Expand Up @@ -176,6 +177,7 @@ func Components() (component.Factories, error) {
}

receivers := []component.ReceiverFactory{
activedirectorydsreceiver.NewFactory(),
awscontainerinsightreceiver.NewFactory(),
awsecscontainermetricsreceiver.NewFactory(),
awsfirehosereceiver.NewFactory(),
Expand Down
4 changes: 4 additions & 0 deletions internal/components/receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func TestDefaultReceivers(t *testing.T) {
skipLifecyle bool
getConfigFn getReceiverConfigFn
}{
{
receiver: "active_directory_ds",
skipLifecyle: true, // Requires a running windows service
},
{
receiver: "awscontainerinsightreceiver",
// TODO: skipped since it will only function in a container environment with procfs in expected location.
Expand Down
1 change: 1 addition & 0 deletions receiver/activedirectorydsreceiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
26 changes: 26 additions & 0 deletions receiver/activedirectorydsreceiver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Active Directory Domain Services Receiver

The `active_directory_ds` receiver scrapes metric relating to an Active Directory domain controller using the Windows Performance Counters.

Supported pipeline types: `metrics`

## Configuration
The following settings are optional:
- `metrics` (default: see `DefaultMetricsSettings` [here](./internal/metadata/generated_metrics_v2.go)): Allows enabling and disabling specific metrics from being collected in this receiver.
- `collection_interval` (default = `10s`): The interval at which metrics are emitted by this receiver.

Example:
```yaml
receivers:
active_directory_ds:
collection_interval: 10s
metrics:
# Disable the active_directory.ds.replication.network.io metric from being emitted
active_directory.ds.replication.network.io: false
```

The full list of settings exposed for this receiver are documented [here](./config.go) with detailed sample configurations [here](./testdata/config.yaml).

## Metrics

Details about the metrics produced by this receiver can be found in [metadata.yaml](./metadata.yaml)
26 changes: 26 additions & 0 deletions receiver/activedirectorydsreceiver/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry 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:https://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 activedirectorydsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver"

import (
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver/internal/metadata"
)

type Config struct {
scraperhelper.ScraperControllerSettings `mapstructure:",squash"`
Metrics metadata.MetricsSettings `mapstructure:"metrics"`
}
55 changes: 55 additions & 0 deletions receiver/activedirectorydsreceiver/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright The OpenTelemetry 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:https://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 activedirectorydsreceiver

import (
"path/filepath"
"testing"
"time"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/service/servicetest"
)

func TestLoadConfig(t *testing.T) {
t.Parallel()

factories, err := componenttest.NopFactories()
require.NoError(t, err)

factory := NewFactory()
factories.Receivers[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)
require.NoError(t, err)
require.NotNil(t, cfg)

require.Equal(t, len(cfg.Receivers), 2)
defaultRecvID := config.NewComponentIDWithName(typeStr, "defaults")

defaultCfg := factory.CreateDefaultConfig().(*Config)
defaultCfg.ReceiverSettings.SetIDName(defaultRecvID.Name())
defaultReceiver := cfg.Receivers[defaultRecvID]
require.Equal(t, defaultCfg, defaultReceiver)

advancedRecv := cfg.Receivers[config.NewComponentID(typeStr)]
expectedAdvancedRecv := factory.CreateDefaultConfig().(*Config)

expectedAdvancedRecv.Metrics.ActiveDirectoryDsReplicationObjectRate.Enabled = false
expectedAdvancedRecv.ScraperControllerSettings.CollectionInterval = 2 * time.Minute

require.Equal(t, expectedAdvancedRecv, advancedRecv)
}
Loading

0 comments on commit f49b291

Please sign in to comment.