windowsperfcountersreceiver

package module
v0.160.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 9

README

Windows Performance Counters Receiver

This receiver, for Windows only, captures the configured system, application, or custom performance counter data from the Windows registry using the PDH interface.

Status
Stability beta: metrics
Unsupported Platforms darwin, linux
Distributions contrib
Issues Open issues Closed issues
Code coverage codecov
Code Owners @dashpole, @alxbl, @pjanotti | Seeking more code owners!

This receiver is based on the Telegraf Windows Performance Counters Input Plugin.

If one of the specified performance counters cannot be loaded on startup, a warning will be printed, but the application will not fail fast. It is expected that some performance counters may not exist on some systems due to different OS configuration.

Configuration

The collection interval and the list of performance counters to be scraped can be configured:

windows_perf_counters:
  collection_interval: <duration> # default = "1m"
  initial_delay: <duration> # default = "1s"
  metrics:
    <metric name>:
      description: <description>
      unit: <unit type>
      gauge:
    <metric name>:
      description: <description>
      unit: <unit type>
      sum:
        aggregation: <cumulative or delta>
        monotonic: <true or false>
  perfcounters:
    - object: <object name>
      instances: [<instance name>]*
      aggregation_name: <aggregation instance name> # default = "_Total"
      counters:
        - name: <counter name>
          metric: <metric name>
          attributes:
            <key>: <value>
          recreate_query: <true or false>
Understanding the instances configuration option
Value Interpretation
Not specified This is the only valid value if the counter has no instances.
"*" All instances, excluding the configured aggregation instance (_Total by default).
["*", "_Total"] All instances, including _Total, with the instance attribute preserved.
"_Total" The "total" instance, that aggregates the values of all other instances. See below for its special treatment.
"instance1" A single instance.
["instance1", "instance2", ...] A set of instances.
Aggregation instances

By default, the receiver treats _Total as the aggregation instance. When a query returns _Total with other instances, _Total is omitted because it can be derived in the backend. When _Total is collected by itself, its instance attribute is omitted.

Set aggregation_name to change which instance receives this treatment. For example, aggregation_name: "_Global_" omits _Global_ instead of _Total. To retain the aggregation instance alongside the wildcard results, explicitly include its name in instances. This still creates one wildcard query:

windows_perf_counters:
  metrics:
    processor.time:
      description: CPU active and idle time
      unit: "%"
      gauge:
  collection_interval: 30s
  perfcounters:
    - object: "Processor"
      instances: ["*", "_Total"]
      counters:
        - name: "% Processor Time"
          metric: processor.time

For a counter whose aggregation instance has a different name, configure that name consistently in both fields. For example:

perfcounters:
  - object: "Custom Object"
    instances: ["*", "_Global_"]
    aggregation_name: "_Global_"
    counters:
      - name: "Custom Counter"

[!WARNING] Retaining an aggregation instance alongside its component instances can cause double-counting. Prefer deriving aggregate values in the backend when possible.

Recreating the query on every scrape

On some versions of Windows, Counters are sometimes corrupted and continuously return invalid data after the first scrape. When/If this happens, it is possible to set the counter setting recreate_query to true (defaults to false) to tell the receiver to recreate the PDH query on every scrape. This has slight performance implications but should be inconsequential unless collection_interval is very aggressive.

If re-creating the query fails, the previous query will be re-used and an error will be logged.

Scraping at different frequencies

If you would like to scrape some counters at a different frequency than others, you can configure multiple windows_perf_counters receivers with different collection_interval values. For example:

receivers:
  windows_perf_counters/memory:
    metrics:
      bytes.committed:
        description: the number of bytes committed to memory
        unit: By
        gauge:
    collection_interval: 30s
    perfcounters:
      - object: Memory
        counters:
          - name: Committed Bytes
            metric: bytes.committed

  windows_perf_counters/processor:
    collection_interval: 1m
    metrics:
      processor.time:
        description: active and idle time of the processor
        unit: "%"
        gauge:
    perfcounters:
      - object: "Processor"
        instances: "*"
        counters:
          - name: "% Processor Time"
            metric: processor.time
            attributes:
              state: active
      - object: "Processor"
        instances: ["1", "2"]
        counters:
          - name: "% Idle Time"
            metric: processor.time
            attributes:
              state: idle

service:
  pipelines:
    metrics:
      receivers: [windows_perf_counters/memory, windows_perf_counters/processor]
Defining metric format

To report metrics in the desired output format, define a metric and reference it in the corresponding counter, along with any applicable attributes. The metric's data type can either be gauge (default) or sum.

Field Name Description Value Default
name The key for the metric. string Counter Name
description definition of what the metric measures. string
unit what is being measured. string 1
sum representation of a sum metric. Sum Config
gauge representation of a gauge metric. Gauge Config
Sum Config
Field Name Description Value Default
aggregation The type of aggregation temporality for the metric. [cumulative or delta]
monotonic whether or not the metric value can decrease. false
Gauge Config

A gauge config currently accepts no settings. It is specified as an object for forwards compatibility.

e.g. To output the Memory/Committed Bytes counter as a metric with the name bytes.committed:

receivers:
  windows_perf_counters:
    metrics:
      bytes.committed:
        description: the number of bytes committed to memory
        unit: By
        gauge:
    collection_interval: 30s
    perfcounters:
    - object: Memory
      counters:
        - name: Committed Bytes
          metric: bytes.committed

service:
  pipelines:
    metrics:
      receivers: [windows_perf_counters]

Known Limitation

Documentation

Overview

This receiver is only compatible with Windows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() receiver.Factory

NewFactory creates a new factory for windows perf counters receiver.

Types

type Config

type Config struct {
	ControllerConfig scraperhelper.ControllerConfig `mapstructure:",squash"`

	MetricMetaData map[string]MetricConfig `mapstructure:"metrics"`
	PerfCounters   []ObjectConfig          `mapstructure:"perfcounters"`
}

Config defines configuration for WindowsPerfCounters receiver.

func (*Config) Validate added in v0.25.0

func (c *Config) Validate() error

type CounterConfig added in v0.48.0

type CounterConfig struct {
	Name          string    `mapstructure:"name"`
	MetricRep     MetricRep `mapstructure:",squash"`
	RecreateQuery bool      `mapstructure:"recreate_query"`
}

CounterConfig defines the individual counter in an object.

type GaugeMetric added in v0.48.0

type GaugeMetric struct{}

type MetricConfig added in v0.48.0

type MetricConfig struct {
	Unit        string      `mapstructure:"unit"`
	Description string      `mapstructure:"description"`
	Gauge       GaugeMetric `mapstructure:"gauge"`
	Sum         SumMetric   `mapstructure:"sum"`
}

MetricsConfig defines the configuration for a metric to be created.

type MetricRep added in v0.52.0

type MetricRep struct {
	Name       string            `mapstructure:"metric"`
	Attributes map[string]string `mapstructure:"attributes"`
}

type ObjectConfig added in v0.52.0

type ObjectConfig struct {
	Object    string   `mapstructure:"object"`
	Instances []string `mapstructure:"instances"`
	// AggregationName identifies the instance that aggregates the values of all
	// other instances. It defaults to "_Total".
	AggregationName string          `mapstructure:"aggregation_name"`
	Counters        []CounterConfig `mapstructure:"counters"`
}

ObjectConfig defines configuration for a perf counter object.

type SumMetric added in v0.48.0

type SumMetric struct {
	Aggregation string `mapstructure:"aggregation"`
	Monotonic   bool   `mapstructure:"monotonic"`
}

Directories

Path Synopsis
internal
metadata
Package metadata contains the autogenerated telemetry and build information for the receiver/windows_perf_counters component.
Package metadata contains the autogenerated telemetry and build information for the receiver/windows_perf_counters component.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL