parser

package
v0.0.0-...-b51c93b Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2016 License: ISC Imports: 2 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertLogToExtended

func ConvertLogToExtended(input []byte) (map[string]interface{}, error)

ConvertLogToExtended converts MongoDB log line formatted documents to an extended JSON representation

Example
doc, _ := logdoc.ConvertLogToExtended([]byte("{ x: Timestamp(13000000, 0)}"))
buf, _ := json.Marshal(doc)
fmt.Print(string(buf))
Output:

{"x":{"$timestamp":{"t":13000000,"i":0}}}

func ParseLogLine

func ParseLogLine(input string) (map[string]interface{}, error)

ParseLogLine attempts to parse a MongoDB log line into a structured representation

Example
package main

import (
	"encoding/json"
	"fmt"

	"github.com/tmc/mongologtools/parser"
)

func main() {
	line := "Mon Feb 23 03:20:19.670 [TTLMonitor] query local.system.indexes query: { expireAfterSeconds: { $exists: true } } ntoreturn:0 ntoskip:0 nscanned:0 keyUpdates:0 locks(micros) r:86 nreturned:0 reslen:20 0ms"
	doc, _ := parser.ParseLogLine(line)
	buf, _ := json.Marshal(doc)
	fmt.Print(string(buf))
}
Output:

{"context":"TTLMonitor","duration_ms":"0","keyUpdates":0,"nreturned":0,"ns":"local.system.indexes","nscanned":0,"ntoreturn":0,"ntoskip":0,"op":"query","query":{"expireAfterSeconds":{"$exists":true}},"r":86,"reslen":20,"timestamp":"Mon Feb 23 03:20:19.670"}

Types

This section is empty.

Directories

Path Synopsis
internal
logdoc
Package logdoc contains a MongoDB log format document parser
Package logdoc contains a MongoDB log format document parser
logline
Package logline contains a MongoDB log line parser
Package logline contains a MongoDB log line parser

Jump to

Keyboard shortcuts

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