cloudevents

package
v1.30.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 9 Imported by: 0

README

CloudEvents Serializer

The cloudevents data format outputs metrics as CloudEvents in JSON format. Currently, versions v1.0 and v0.3 of the specification are supported with the former being the default.

Configuration

[[outputs.file]]
  ## Files to write to, "stdout" is a specially handled file
  files = ["stdout", "/tmp/metrics.out"]

  ## Data format to output
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
  data_format = "cloudevents"

  ## Specification version to use for events
  ## Currently versions "0.3" and "1.0" are supported.
  # cloudevents_version = "1.0"

  ## Event source specifier
  ## This allows to overwrite the source header-field with the given value.
  # cloudevents_source = "telegraf"

  ## Tag to use as event source specifier
  ## This allows to overwrite the source header-field with the value of the
  ## specified tag. If both 'cloudevents_source' and 'cloudevents_source_tag'
  ## are set, the this setting will take precedence. In case the specified tag
  ## value does not exist for a metric, the serializer will fallback to
  ## 'cloudevents_source'.
  # cloudevents_source_tag = ""

  ## Event-type specifier to overwrite the default value
  ## By default, events (and event batches) containing a single metric will
  ## set the event-type to 'com.influxdata.telegraf.metric' while events
  ## containing a batch of metrics will set the event-type to
  ## 'com.influxdata.telegraf.metric' (plural).
  # cloudevents_event_type = ""

  ## Set time header of the event
  ## Supported values are:
  ##   none     -- do not set event time
  ##   earliest -- use timestamp of the earliest metric
  ##   latest   -- use timestamp of the latest metric
  ##   creation -- use timestamp of event creation
  ## For events containing only a single metric, earliest and latest are
  ## equivalent.
  # cloudevents_event_time = "latest"

  ## Batch format of the output when running in batch mode
  ## If set to 'events' the resulting output will contain a list of events,
  ## each with a single metric according to the JSON Batch Format of the
  ## specification. Use 'application/cloudevents-batch+json' for this format.
  ##
  ## When set to 'metrics', a single event will be generated containing a list
  ## of metrics as payload. Use 'application/cloudevents+json' for this format.
  # cloudevents_batch_format = "events"

Documentation

Index

Constants

View Source
const (
	EventTypeSingle = "com.influxdata.telegraf.metric"
	EventTypeBatch  = "com.influxdata.telegraf.metrics"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Serializer

type Serializer struct {
	Version     string          `toml:"cloudevents_version"`
	Source      string          `toml:"cloudevents_source"`
	SourceTag   string          `toml:"cloudevents_source_tag"`
	EventType   string          `toml:"cloudevents_event_type"`
	EventTime   string          `toml:"cloudevents_event_time"`
	BatchFormat string          `toml:"cloudevents_batch_format"`
	Log         telegraf.Logger `toml:"-"`
	// contains filtered or unexported fields
}

func (*Serializer) Init

func (s *Serializer) Init() error

func (*Serializer) Serialize

func (s *Serializer) Serialize(m telegraf.Metric) ([]byte, error)

func (*Serializer) SerializeBatch

func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error)

Jump to

Keyboard shortcuts

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