papertrailpull

package module
v0.0.0-...-7b880fd Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2022 License: MPL-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LASTLOGID_KIND      = "last_log_id_papertrail"
	LASTLOGID_KEY       = "last_log_id_papertrail"
	LASTLOGID_NAMESPACE = "last_log_id_papertrail"

	LOGGER_NAME = "papertrailpull"

	PAPERTRAIL_URL = "https://papertrailapp.com/api/v1/events/search.json"
)

Variables

View Source
var (
	PAPERTRAIL_TOKEN string
	PAPERTRAIL_QUERY string
)

Functions

func InitConfig

func InitConfig()

func PapertrailPull

func PapertrailPull(ctx context.Context, psmsg PubSubMessage) error

Main function ran within the cloudfunction.

Types

type PapertrailEvent

type PapertrailEvent struct {
	DisplayReceivedAt string `json:"display_received_at"`
	Facility          string `json:"facility"`
	GeneratedAt       string `json:"generated_at"`
	Hostname          string `json:"hostname"`
	Id                string `json:"id"`
	Message           string `json:"message"`
	Program           string `json:"program"`
	ReceivedAt        string `json:"received_at"`
	Severity          string `json:"severity"`
	SourceId          int    `json:"source_id"`
	SourceIp          string `json:"source_ip"`
	SourceName        string `json:"source_name"`
}

The format of Papertrail log events

type PapertrailSearchResp

type PapertrailSearchResp struct {
	Events      []PapertrailEvent `json:"events"`
	MaxId       string            `json:"max_id"`
	MaxIdParsed int               `json:"-"`
	MinId       string            `json:"min_id"`
	MinIdParsed int               `json:"-"`
}

Struct for response from Papertrail. MaxIdParsed and MinIdParsed are populated through the `.Parse()` method

func (*PapertrailSearchResp) Parse

func (resp *PapertrailSearchResp) Parse() error

Parse MaxId and MinId from strings to ints

type PubSubMessage

type PubSubMessage struct {
	Data []byte `json:"data"`
}

PubSubMessage is used for the function signature of the main function (Papertrailpull()) represent the data sent from PubSub. The data is not actually read, this is only used as a mechanism for triggering the function (using Cloud Scheduler or similiar)

Directories

Path Synopsis
cmd module

Jump to

Keyboard shortcuts

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