-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
windowsservicereceiver wireframe #35362
base: main
Are you sure you want to change the base?
Changes from all commits
823e2d4
482176b
982a9e6
0be9dfd
f24edec
12963e5
c8ca80e
12f4a70
480579b
f6854c5
384e96f
4846d0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: 'new_component' | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: windowsservicereceiver | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: receiver for scraping windows service information from a host or properly configured remote machine. | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [31377] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../Makefile.Common |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Windows Service Receiver | ||
|
||
<!-- status autogenerated section --> | ||
| Status | | | ||
| ------------- |-----------| | ||
| Stability | [development]: metrics | | ||
| Unsupported Platforms | darwin, linux | | ||
| Distributions | [contrib] | | ||
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Fwindowsservice%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fwindowsservice) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Fwindowsservice%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fwindowsservice) | | ||
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@shalper2](https://www.github.com/shalper2) | | ||
|
||
[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development | ||
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib | ||
<!-- end autogenerated section --> | ||
|
||
The Windows Service Receiver is a receiver for scraping information about services running on a Windows machine. | ||
|
||
## Getting Started | ||
|
||
By default the Windows Service Receiver will attempt to identify and monitor the status of all specified services on the host machine. If the `include_services` field is present but empty the receiver will assume that the user wishes to monitor _ALL_ services present on a machine. Should you wish to monitor a majority of services (but not all) an optional `exclude_services` services field may be included with a list of services you do not wish to see metrics from. | ||
|
||
An example of monitoring three services on a host: | ||
```yaml | ||
windowsservice: | ||
collection_interval: <duration> # default = 1m | ||
include_services: | ||
- service1 | ||
- service2 | ||
- service3 | ||
... | ||
``` | ||
The case where you wish to monitor all services present on a host machine, except for `service3`: | ||
```yaml | ||
windowsservice: | ||
collection_interval: <duration> # default = 1m | ||
include_services: | ||
exclude_services: | ||
- service3 | ||
... | ||
``` | ||
|
||
### Notes | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package windowsservicereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsservicereceiver" | ||
|
||
import ( | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsservicereceiver/internal/metadata" | ||
"go.opentelemetry.io/collector/receiver/scraperhelper" | ||
) | ||
|
||
// Config defines configuration for windowsservice receiver. | ||
type Config struct { | ||
scraperhelper.ControllerConfig `mapstructure:",squash"` | ||
metadata.MetricsBuilderConfig `mapstructure:",squash"` | ||
IncludeServices []string `mapstructure:"include_services"` // user provided list of services to monitor with receiver | ||
ExcludeServices []string `mapstructure:"exclude_services"` // user provided list of services to be excluded | ||
} | ||
|
||
// Validate checks the receiver configuration is valid | ||
func (cfg *Config) Validate() error { return nil } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package windowsservicereceiver |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:generate mdatagen metadata.yaml | ||
|
||
// Package windowsservicereceiver reads metrics describing processes running on a Windows host machine. | ||
package windowsservicereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsservicereceiver" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.) | ||
|
||
# windowsservice | ||
|
||
## Default Metrics | ||
|
||
The following metrics are emitted by default. Each of them can be disabled by applying the following configuration: | ||
|
||
```yaml | ||
metrics: | ||
<metric_name>: | ||
enabled: false | ||
``` | ||
|
||
### windows.service | ||
|
||
Gauge value containing service status as an integer value. | ||
|
||
Gauge values map to service status as follows: 0 - Failed to retrieve service status, 1 - Stopped, 2 - Start Pending, 3 - Stop Pending, 4 - Service Running, 5 - Continue Pending, 6 - Pause Pending, 7 - Service Paused | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: it will be nice to have this as a list with each value and meaning on a single line, or perhaps row in a table. |
||
|
||
|
||
| Unit | Metric Type | Value Type | | ||
| ---- | ----------- | ---------- | | ||
| {status} | Gauge | Int | | ||
|
||
#### Attributes | ||
|
||
| Name | Description | Values | | ||
| ---- | ----------- | ------ | | ||
| windows.service.name | The name of the windows Service being reported. | Any Str | | ||
| windows.service.startup_mode | Startup mode of Windows Service () | Str: ``boot_start``, ``system_start``, ``auto_start``, ``demand_start``, ``disabled`` | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package windowsservicereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsservicereceiver" | ||
|
||
import ( | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsservicereceiver/internal/metadata" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/receiver" | ||
"go.opentelemetry.io/collector/receiver/scraperhelper" | ||
) | ||
|
||
func createDefaultConfig() component.Config { | ||
scfg := scraperhelper.NewDefaultControllerConfig() | ||
|
||
return &Config{ | ||
ControllerConfig: scfg, | ||
} | ||
} | ||
|
||
func NewFactory() receiver.Factory { | ||
return receiver.NewFactory(metadata.Type, createDefaultConfig, receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
//go:build !windows | ||
|
||
// catchall for when the receiver is built for non-windows systems | ||
package windowsservicereceiver | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/receiver" | ||
) | ||
|
||
func createMetricsReceiver(_ context.Context, _ receiver.Settings, _ component.Config, _ consumer.Metrics) (receiver.Metrics, error) { | ||
return nil, errors.New("WindowsServiceReceiver is only supported on Windows") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package windowsservicereceiver |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
//go:build windows | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: per convention add a blank line above |
||
|
||
package windowsservicereceiver | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsservicereceiver/internal/metadata" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/receiver" | ||
"go.opentelemetry.io/collector/receiver/scraperhelper" | ||
) | ||
|
||
func createMetricsReceiver( | ||
_ context.Context, | ||
params receiver.Settings, | ||
cfg component.Config, | ||
consumer consumer.Metrics, | ||
) (receiver.Metrics, error) { | ||
c := cfg.(*Config) | ||
s := newWindowsServiceScraper(params, c) | ||
|
||
scp, err := scraperhelper.NewScraperWithoutType(s.scrape, | ||
scraperhelper.WithStart(s.start), | ||
scraperhelper.WithShutdown(s.shutdown)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return scraperhelper.NewScraperControllerReceiver(&c.ControllerConfig, | ||
params, | ||
consumer, | ||
scraperhelper.AddScraperWithType(metadata.Type, scp)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsservicereceiver | ||
|
||
go 1.22.0 | ||
|
||
require ( | ||
github.com/google/go-cmp v0.6.0 | ||
github.com/stretchr/testify v1.9.0 | ||
go.opentelemetry.io/collector/component v0.114.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After taking the comments versions should be updated to match the latest of the collector. |
||
go.opentelemetry.io/collector/component/componenttest v0.114.0 | ||
go.opentelemetry.io/collector/confmap v1.15.0 | ||
go.opentelemetry.io/collector/consumer v0.114.0 | ||
go.opentelemetry.io/collector/consumer/consumertest v0.114.0 | ||
go.opentelemetry.io/collector/pdata v1.20.0 | ||
go.opentelemetry.io/collector/receiver v0.114.0 | ||
go.opentelemetry.io/collector/receiver/receivertest v0.114.0 | ||
go.uber.org/goleak v1.3.0 | ||
go.uber.org/zap v1.27.0 | ||
golang.org/x/sys v0.27.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/go-logr/logr v1.4.2 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/go-viper/mapstructure/v2 v2.1.0 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/knadh/koanf/maps v0.1.1 // indirect | ||
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect | ||
github.com/knadh/koanf/v2 v2.1.1 // indirect | ||
github.com/mitchellh/copystructure v1.2.0 // indirect | ||
github.com/mitchellh/reflectwalk v1.0.2 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/rogpeppe/go-internal v1.12.0 // indirect | ||
go.opentelemetry.io/collector/config/configtelemetry v0.114.0 // indirect | ||
go.opentelemetry.io/collector/consumer/consumererror v0.114.0 // indirect | ||
go.opentelemetry.io/collector/consumer/consumerprofiles v0.114.0 // indirect | ||
go.opentelemetry.io/collector/pdata/pprofile v0.114.0 // indirect | ||
go.opentelemetry.io/collector/pipeline v0.114.0 // indirect | ||
go.opentelemetry.io/collector/receiver/receiverprofiles v0.114.0 // indirect | ||
go.opentelemetry.io/otel v1.32.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.32.0 // indirect | ||
go.opentelemetry.io/otel/sdk v1.32.0 // indirect | ||
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.32.0 // indirect | ||
go.uber.org/multierr v1.11.0 // indirect | ||
golang.org/x/net v0.28.0 // indirect | ||
golang.org/x/text v0.18.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect | ||
google.golang.org/grpc v1.67.1 // indirect | ||
google.golang.org/protobuf v1.35.1 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially is just the wire-frame and separating the support of remote that can be added later with the caveat that we should create a config that is compatible with later adding remote without breaking the initial config. Anyway, there is still more flexibility while the component is still in development.