Skip to content

Commit

Permalink
[receiver/iis] Add IIS Metrics Receiver (#8832)
Browse files Browse the repository at this point in the history
* Add IIS metric receiver based on windows performance counters
  • Loading branch information
Miguel Rodriguez authored Apr 14, 2022
1 parent faf74e4 commit 95f0da0
Show file tree
Hide file tree
Showing 30 changed files with 2,738 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ receiver/googlecloudpubsubreceiver/ @open-telemetry/collector-c
receiver/googlecloudspannerreceiver/ @open-telemetry/collector-contrib-approvers @ydrozhdzhal @asukhyy @khospodarysko @architjugran
receiver/hostmetricsreceiver @open-telemetry/collector-contrib-approvers @dmitryax
receiver/influxdbreceiver/ @open-telemetry/collector-contrib-approvers @jacobmarble
receiver/iisreceiver/ @open-telemetry/collector-contrib-approvers @mrod1598 @djaglowski
receiver/jaegerreceiver/ @open-telemetry/collector-contrib-approvers @jpkrohling
receiver/jmxreceiver/ @open-telemetry/collector-contrib-approvers @rmfitzpatrick
receiver/journaldreceiver/ @open-telemetry/collector-contrib-approvers @pmm-sumo
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: install iis
run: Install-WindowsFeature -name Web-Server -IncludeManagementTools
- name: Setup Go
uses: actions/setup-go@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
### 🚩 Deprecations 🚩

### 🚀 New components 🚀

- `iisreceiver`: Add implementation of IIS Metric Receiver (#8832)
### 💡 Enhancements 💡

### 🧰 Bug fixes 🧰
Expand Down
3 changes: 3 additions & 0 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/fluentforwardreceiver v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/googlecloudspannerreceiver v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/iisreceiver v0.0.0-00010101000000-000000000000 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/influxdbreceiver v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.49.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver v0.49.0 // indirect
Expand Down Expand Up @@ -727,6 +728,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostm

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

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

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver => ../../receiver/jmxreceiver
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/fluentforwardreceiver v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/googlecloudspannerreceiver v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/iisreceiver v0.0.0-00010101000000-000000000000
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/influxdbreceiver v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.49.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver v0.49.0
Expand Down Expand Up @@ -731,6 +732,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostm

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

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

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver => ./receiver/jmxreceiver
Expand Down
2 changes: 2 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/fluentforwardreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/googlecloudspannerreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/iisreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/influxdbreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver"
Expand Down Expand Up @@ -189,6 +190,7 @@ func Components() (component.Factories, error) {
googlecloudspannerreceiver.NewFactory(),
hostmetricsreceiver.NewFactory(),
influxdbreceiver.NewFactory(),
iisreceiver.NewFactory(),
jaegerreceiver.NewFactory(),
jmxreceiver.NewFactory(),
journaldreceiver.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 @@ -115,6 +115,10 @@ func TestDefaultReceivers(t *testing.T) {
{
receiver: "influxdb",
},
{
receiver: "iis",
skipLifecyle: true, // Requires a running windows process
},
{
receiver: "jaeger",
},
Expand Down
1 change: 1 addition & 0 deletions receiver/iisreceiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
26 changes: 26 additions & 0 deletions receiver/iisreceiver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Microsoft IIS Receiver

The `iis` receiver grabs metrics about an IIS instance using the Windows Performance Counters.
Because of this, it is a Windows only receiver.

Supported pipeline types: `metrics`

## Configuration

The following settings are optional:

- `collection_interval` (default = `10s`): The interval at which metrics should be emitted by this receiver.

Example:

```yaml
receivers:
iis:
collection_interval: 10s
```
The full list of settings exposed for this receiver are documented [here](./config.go).
## Metrics
Details about the metrics produced by this receiver can be found in [documentation.md](./documentation.md)
27 changes: 27 additions & 0 deletions receiver/iisreceiver/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 iisreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/iisreceiver"

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

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

// Config defines configuration for simple prometheus receiver.
type Config struct {
scraperhelper.ScraperControllerSettings `mapstructure:",squash"`
Metrics metadata.MetricsSettings `mapstructure:"metrics"`
}
210 changes: 210 additions & 0 deletions receiver/iisreceiver/config_generator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
// 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.

//go:build windows
// +build windows

package iisreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/iisreceiver"

import (
windowsapi "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/winperfcounters"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/iisreceiver/internal/metadata"
)

// getPerfCounters returns established PerfCounters for each metric.
func getScraperCfgs() []windowsapi.ObjectConfig {
return []windowsapi.ObjectConfig{
{
Object: "Web Service",
Instances: []string{"_Total"},
Counters: []windowsapi.CounterConfig{
{
MetricRep: windowsapi.MetricRep{
Name: "iis.connection.active",
},
Name: "Current Connections",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.network.io",
Attributes: map[string]string{
"direction": "received",
},
},
Name: "Total Bytes Received",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.network.io",
Attributes: map[string]string{
"direction": "sent",
},
},
Name: "Total Bytes Sent",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.connection.attempt.count",
},
Name: "Total Connection Attempts (all instances)",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.count",
Attributes: map[string]string{
metadata.A.Request: "delete",
},
},
Name: "Total Delete Requests",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.count",
Attributes: map[string]string{
metadata.A.Request: "get",
},
},

Name: "Total Get Requests",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.count",
Attributes: map[string]string{
metadata.A.Request: "head",
},
},

Name: "Total Head Requests",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.count",
Attributes: map[string]string{
metadata.A.Request: "options",
},
},

Name: "Total Options Requests",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.count",
Attributes: map[string]string{
metadata.A.Request: "post",
},
},

Name: "Total Post Requests",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.count",
Attributes: map[string]string{
metadata.A.Request: "put",
},
},

Name: "Total Put Requests",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.count",
Attributes: map[string]string{
metadata.A.Request: "trace",
},
},

Name: "Total Trace Requests",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.network.file.count",
Attributes: map[string]string{
metadata.A.Direction: "received",
},
},
Name: "Total Files Received",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.network.file.count",
Attributes: map[string]string{
metadata.A.Direction: "sent",
},
},
Name: "Total Files Sent",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.connection.anonymous",
},

Name: "Total Anonymous Users",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.network.blocked",
},

Name: "Total blocked bandwidth bytes",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.uptime",
},

Name: "Service Uptime",
},
},
},
{
Object: "HTTP Service Request Queues",
Counters: []windowsapi.CounterConfig{
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.rejected",
},

Name: "RejectedRequests",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.queue.count",
},

Name: "CurrentQueueSize",
},
{
MetricRep: windowsapi.MetricRep{
Name: "iis.request.queue.age.max",
},
Name: "MaxQueueItemAge",
},
},
},
{
Object: "Process",
Instances: []string{"_Total"},
Counters: []windowsapi.CounterConfig{
{
MetricRep: windowsapi.MetricRep{
Name: "iis.thread.active",
},
Name: "Thread Count",
},
},
},
}
}
17 changes: 17 additions & 0 deletions receiver/iisreceiver/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.

//go:generate mdatagen --experimental-gen metadata.yaml

package iisreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/iisreceiver"
Loading

0 comments on commit 95f0da0

Please sign in to comment.