Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/activedirectoryds] Add Active Directory Domain Services metrics receiver #9359

Merged
merged 16 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ 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: go test --tags containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper ./...
working-directory: ./receiver/activedirectorydsreceiver
djaglowski marked this conversation as resolved.
Show resolved Hide resolved
- 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://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://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