GithubHelp home page GithubHelp logo

m90 / papertrailforwarder Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 6 KB

Forward CloudWatch logs to Papertrail like what??!?

License: MIT License

Makefile 0.96% Go 99.04%
papertrail aws-lambda cloudwatch-logs golang

papertrailforwarder's Introduction

papertrailforwarder

Build Status godoc

Forward CloudWatch logs to Papertrail

Installation:

Install the library:

go get github.com/m90/papertrailforwarder

Usage:

Package papertrailforwarder allows for easy creation of AWS Lambda handlers that forward CloudWatch Log Events to Papertrail.

This is an example of an entire Lambda function:

package main

import (
	"fmt"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
	"github.com/m90/papertrailforwarder"
)

func main() {
	handler, err := papertrailforwarder.New(
		// the host of the papertrail log target
		papertrailforwarder.WithPapertrailHost(<HOST_VALUE>),
		// the port of the papertrail log target as an integer value
		papertrailforwarder.WithPapertrailPort(<PORT_VALUE>),
		// a function that returns a message and whether it should be logged
		// it is passed the raw log message as well as the full event
		papertrailforwarder.WithMessageTransform(func(message string, event events.CloudwatchLogsLogEvent) (string, bool) {
			// prefix all log messages with the event id, forward all messages
			return fmt.Sprintf("[%s] %s", event.ID, message), true
		}),
	)
	if err != nil {
		panic(err)
	}
	lambda.Start(handler)
}

When invoked without any options, New() will return a handler that uses the values set in the environment variables PAPERTRAIL_HOST and PAPERTRAIL_PORT and the unmodified log message will be forwarded.

Refer to the packages godoc for the entire documentation.

License

MIT © Frederik Ring

papertrailforwarder's People

Contributors

m90 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.