telemetrygeneratorreceiver

package module
v1.49.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

Telemetry Generator Receiver

This receiver is used to generate synthetic telemetry for testing and configuration purposes.

Minimum Agent Versions

Supported Pipelines

  • Logs
  • Metrics
  • Traces

Configuration for all generators

Field Type Default Required Description
payloads_per_second int 1 false The number of payloads this receiver will generate per second.
generators list true A list of generators to use.
Common Generator Configuration
Field Type Default Required Description
type string true The type of generator to use. Currently logs, otlp, metrics, host_metrics, and windows_events are supported.
resource_attributes map false A map of resource attributes to be included in the generated telemetry. Values can be any.
attributes map false A map of attributes to be included in the generated telemetry. Values can be any.
additional_config map false A map of additional configuration options to be included in the generated telemetry. Values can be any.
Log Generator Configuration
Field Type Default Required Description
body string false The body of the log, set in additional_config
severity int false The severity of the log message, set in additional_config
Example Configuration
telemetrygeneratorreceiver:
    payloads_per_second: 1
    generators:
        - type: logs
          resource_attributes:
              res_key1: res_value1
              res_key2: res_value2            
          attributes:
              attr_key1: attr_value1
              attr_key2: attr_value2            
          additional_config:
              body: this is the body   
              severity: 4
        - type: logs
          resource_attributes:
              res_key3: res_value3
              res_key4: res_value4            
          attributes:
              attr_key3: attr_value3
              attr_key4: attr_value4            
          additional_config:
              body: this is another body   
              severity: 10
OTLP Replay Generator

The OTLP Replay Generator replays JSON-formatted telemetry from the variable otlp_json. It adjusts the timestamps of the telemetry relative the current time, with the most recent record moved to the current time, and the previous records the same relative duration in the past. The otlp_json variable should be valid OTLP, such as the JSON created by plog.JSONMarshaler,ptrace.JSONMarshaler, or pmetric.JSONMarshaler. The otlp_json variable is set in the additional_config section of the generator configuration. The attributes and resource_attributes fields are ignored.

additional_config:
Field Type Default Required Description
telemetry_type string true The type of telemetry to replay: logs, metrics, or traces.
otlp_json string true A string of JSON encoded OTLP telemetry
Example Configuration
telemetrygeneratorreceiver:
    payloads_per_second: 1
    generators:
        - type: otlp
          additional_config:
            telemetry_type: "metrics",
			otlp_json:      `{"resourceMetrics":[{"resource":{},"scopeMetrics":[{"scope":{},"metrics":[{"exponentialHistogram":{"dataPoints":[{"attributes":[{"key":"prod-machine","value":{"stringValue":"prod-1"}}],"count":"4","positive":{},"negative":{},"min":0,"max":100}]}}]}]}]}`,
Metrics Generator

The metrics generator creates synthetic metrics. The generator can be configured to create metrics with arbitrary names, values, and attributes. The generator can be configured to create metrics with a random value between a minimum and maximum value, or a constant value by setting value_max = value_min. For Sum metrics with unit s and Gauge metrics, the generator will create a random float value. For all other Sum metrics, the generator will create a random int value.

additional_config:
Field Type Default Required Description
telemetry_type string true The type of telemetry to replay: logs, metrics, or traces.
metrics array true A list of metrics to generate
metrics:
Field Type Default Required Description
name string true The metric name
value_min int true The metric's minimum value
value_max int true The metric's maximum value
type string true The metric type: Gauge, or Sum
unit string true The metric unit, either By, by, 1, s, {thread}, {errors}, {packets}, {entries}, {connections}, {faults}, {operations}, or {processes}
attributes map false A map of attributes to be included in the generated telemetry record. Values can be any.
Example Configuration
telemetrygeneratorreceiver:
    payloads_per_second: 1
    generators:
        - type: metrics
          resource_attributes:
            host.name: 2ed77de7e4c1
            os.type: linux          
          additional_config:
            metrics: 
            # memory metrics
             - name:	system.memory.usage
                value_min: 100000
                value_max: 1000000000
                type:	Sum
                unit:	By
                attributes:
                  state: cached
            # load metrics                  
              - name:	system.cpu.load_average.1m
                value_min: 0
                value_max: 1
                type: Gauge
                unit:	"{thread}"   
            # file system metrics                                          
              - name: system.filesystem.usage
                value_min: 0
                value_max: 15616700416
                type: Sum
                unit: By
                attributes:
                  device: "/dev/vda1"
                  mode: rw
                  mountpoint: "/etc/hosts"
                  state: reserved
                  type: ext4                    
Host Metrics Generator

The host metrics generator creates synthetic host metrics, from a list of pre-defined metrics. The metrics resource attributes can be set in the resource_attributes section of the generator configuration.

Example Configuration
telemetrygeneratorreceiver:
    payloads_per_second: 1
    generators:
        - type: host_metrics
          resource_attributes:
            host.name: 2ed77de7e4c1
            os.type: linux   
Windows Events Generator

The Windows Events Generator replays a sample of recorded Windows Event Log data. It has no additional configuration, and will ignore resource_attributes and attributes fields.

Example Configuration
telemetrygeneratorreceiver:
    payloads_per_second: 1
    generators:
        - type: windows_events          

Documentation

Overview

Package telemetrygeneratorreceiver generates telemetry for testing purposes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() receiver.Factory

NewFactory creates a new receiver factory

Types

type Config

type Config struct {
	PayloadsPerSecond int               `mapstructure:"payloads_per_second"`
	Generators        []GeneratorConfig `mapstructure:"generators"`
}

Config is the configuration for the telemetry generator receiver

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config

type GeneratorConfig

type GeneratorConfig struct {
	// Type of generator to use, either "logs", "host_metrics", or "windows_events"
	Type generatorType `mapstructure:"type"`

	// ResourceAttributes are additional key-value pairs to add to the resource attributes of telemetry.
	ResourceAttributes map[string]any `mapstructure:"resource_attributes"`

	// Attributes are Additional key-value pairs to add to the telemetry attributes
	Attributes map[string]any `mapstructure:"attributes"`

	// AdditionalConfig are any additional config that a generator might need.
	AdditionalConfig map[string]any `mapstructure:"additional_config"`
}

GeneratorConfig is the configuration for a single generator

func (*GeneratorConfig) Validate

func (g *GeneratorConfig) Validate() error

Validate validates the generator config

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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