Skip to content

v1.2.0

Compare
Choose a tag to compare
@loafoe loafoe released this 05 Jun 08:27

Whats new

  • [NEW] Plugin support
  • Much improved batch error handling

Plugins

This release brings a brand new feature, plugins. It is now possible to add external plugins which are independent Go processes connected via gRPC which get a chance to transform or drop each message passing through Logproxy. Use cases include:

  • Dropping verbose or high frequency logs which are not interesting
  • Trigger events (e.g. send an email, call a webhook) when certain patterns in your logs are detected
  • Forwarding of logs to external systems

Below is a full working example of a plugin. It prints out the logging resource ID

package main

import (
	"fmt"
	"github.com/hashicorp/go-hclog"
	"github.com/hashicorp/go-plugin"
	"github.com/philips-software/go-hsdp-api/logging"
	"github.com/philips-software/logproxy/shared"
)

type Filter struct{}

func (Filter) Filter(msg logging.Resource) (logging.Resource, bool, bool, error) {
	hclog.Default().Info(fmt.Sprintf("Processed: %s", msg.ID))
	return msg, false, false, nil
}

func main() {
	plugin.Serve(&plugin.ServeConfig{
		HandshakeConfig: shared.Handshake,
		Plugins: map[string]plugin.Plugin{
			"filter": &shared.FilterGRPCPlugin{Impl: &Filter{}},
		},
		GRPCServer: plugin.DefaultGRPCServer,
	})
}