example

package
v1.0.33 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricsExample

type MetricsExample struct {
	// contains filtered or unexported fields
}

MetricsExample struct implements the MetricInput interface. The plugin has a counter field, which would be increment every 5 seconds. And, the value of this counter will be sent as metrics data.

func (*MetricsExample) Collect

func (m *MetricsExample) Collect(collector ilogtail.Collector) error

Collect is called every trigger interval to collect the metrics and send them to the collector.

func (*MetricsExample) Description

func (m *MetricsExample) Description() string

func (*MetricsExample) Init

func (m *MetricsExample) Init(context ilogtail.Context) (int, error)

Init method would be triggered before working. In the example plugin, we set the initial value of counter to 100. And we return 0 to use the default trigger interval.

type ServiceExample

type ServiceExample struct {
	Address string
	// contains filtered or unexported fields
}

ServiceExample struct implement the ServiceInput interface. The plugin has a http server to receive the data. You could test the plugin with the command: curl --header "test:val123" http://127.0.0.1:19000/data

func (*ServiceExample) Description

func (s *ServiceExample) Description() string

func (*ServiceExample) Init

func (s *ServiceExample) Init(context ilogtail.Context) (int, error)

Init method would be triggered before working. In the example plugin, we only store the logstore config context reference. And we return 0 to use the default trigger interval.

func (*ServiceExample) Start

func (s *ServiceExample) Start(collector ilogtail.Collector) error

Start the service example plugin would run in a separate go routine, so it is blocking method. The ServiceInput plugin is suitable for receiving the external input data. In the demo, we implemented an http server to accept the specified header of requests.

func (*ServiceExample) Stop

func (s *ServiceExample) Stop() error

Stop method would triggered when closing the plugin to graceful stop the go routine blocking with the Start method.

Jump to

Keyboard shortcuts

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