Documentation ¶
Overview ¶
Cicerone - a lager connoisseur
lager emits logs chug pretty prints logs in real time cicerone sifts through those logs and analyzes them
The dsl package has a number of different nouns:
- Entry: Cicerone's representation of a log line - Entries: an ordered list of entries, can be filtered and grouped - GroupedEntries: a collection of Entries grouped by an arbitrary key - EntryPair: a set of two entries typically used to represent a period of time between two events of interest - EntryPairs: a collection of EntryPair. From this one can generate:
- DTStats: a set of statistics describing a collection of EntryPairs
- Durations: an array of time.Durations with some convenience helpers
- TimelineDescription: a collection of TimelinePoints used to construct a timeline - Timeline: combines a TimelineDescription with an Entries -- represents the timeline associated with a particular object flowing through the logs - Timelines: a pile of logs will have several timelines in them. These are collected into a Timelines object. - Matchers: matchers take an Entry and return a boolean - Getters: getters take an Entry and pull data out of it
Using these nouns and their attendant verbs one can use Cicerone to quickly slice and dice a collection of log lines. The resulting data can then be visualized with the viz package.
Index ¶
- Variables
- type DTStats
- type DTStatsSlice
- type Durations
- type Entries
- func (e Entries) ConstructTimeline(description TimelineDescription, zeroEntry Entry) Timeline
- func (e Entries) Filter(matcher Matcher) Entries
- func (e Entries) First(matcher Matcher) (Entry, bool)
- func (e Entries) GroupBy(getter Getter) *GroupedEntries
- func (e Entries) Len() int
- func (e Entries) Less(i, j int) bool
- func (e Entries) Swap(i, j int)
- func (e Entries) WriteLagerFormatTo(w io.Writer) error
- type Entry
- type EntryPair
- type EntryPairs
- type Getter
- type GetterFunc
- type GroupedEntries
- func (g *GroupedEntries) Append(key interface{}, entry Entry)
- func (g *GroupedEntries) AppendEntries(key interface{}, entries Entries)
- func (g *GroupedEntries) ConstructTimelines(description TimelineDescription) (Timelines, error)
- func (g *GroupedEntries) EachGroup(f func(interface{}, Entries) error) error
- func (g *GroupedEntries) Filter(matcher Matcher) *GroupedEntries
- func (g *GroupedEntries) Lookup(key interface{}) (Entries, bool)
- func (g *GroupedEntries) WriteLagerFormatTo(w io.Writer) error
- type GroupedTimelines
- func (g *GroupedTimelines) Append(key interface{}, timeline Timeline)
- func (g *GroupedTimelines) AppendTimelines(key interface{}, timelines Timelines)
- func (g *GroupedTimelines) Description() TimelineDescription
- func (g *GroupedTimelines) EachGroup(f func(interface{}, Timelines) error) error
- func (g *GroupedTimelines) Lookup(key interface{}) (Timelines, bool)
- type Matcher
- func And(matchers ...Matcher) Matcher
- func False() Matcher
- func MatchAfter(t time.Time) Matcher
- func MatchBefore(t time.Time) Matcher
- func MatchBetween(after, before time.Time) Matcher
- func MatchIndex(index int) Matcher
- func MatchJob(job string) Matcher
- func MatchLogLevel(logLevel lager.LogLevel) Matcher
- func MatchMessage(message string) Matcher
- func MatchSession(session string) Matcher
- func MatchSource(source string) Matcher
- func MatchVM(vm string) Matcher
- func Not(matcher Matcher) Matcher
- func Or(matchers ...Matcher) Matcher
- func RegExpMatcher(getter Getter, regExp string) Matcher
- func True() Matcher
- type MatcherFunc
- type Timeline
- type TimelineDescription
- type TimelinePoint
- type Timelines
- func (t Timelines) CompleteTimelines() Timelines
- func (t Timelines) DTStatsSlice() DTStatsSlice
- func (t Timelines) Description() TimelineDescription
- func (t Timelines) EndsAfter() time.Duration
- func (t Timelines) EntryPairs(index int) EntryPairs
- func (t Timelines) GroupBy(matcher Matcher, getter Getter) *GroupedTimelines
- func (t Timelines) Len() int
- func (t Timelines) MatchedEntryPairs(i, j int) (EntryPairs, EntryPairs)
- func (t Timelines) SortByEndTime()
- func (t Timelines) SortByEntryAtIndex(index int)
- func (t Timelines) SortByStartTime()
- func (t Timelines) SortByVMForEntryAtIndex(index int)
- func (t Timelines) StartsAfter() time.Duration
- func (t Timelines) String() string
- func (t Timelines) Swap(i, j int)
- func (t Timelines) ToCSV(w io.Writer)
- type TransformationFunction
- type TransformationMap
Constants ¶
This section is empty.
Variables ¶
var GetIndex = GetterFunc(func(entry Entry) (interface{}, bool) { return entry.Index, true })
GetJob returns the Job associated with an entry
var GetJob = GetterFunc(func(entry Entry) (interface{}, bool) { return entry.Job, true })
GetJob returns the Job associated with an entry
var GetLogLevel = GetterFunc(func(entry Entry) (interface{}, bool) { return entry.LogLevel, true })
GetLogLevel returns the LogLevel associated with an entry
var GetMessage = GetterFunc(func(entry Entry) (interface{}, bool) { return entry.Message, true })
GetMessage returns the message associated with an entry
var GetSession = GetterFunc(func(entry Entry) (interface{}, bool) { return entry.Session, true })
GetSession returns the session associated with an entry
var GetSource = GetterFunc(func(entry Entry) (interface{}, bool) { return entry.Source, true })
GetSource returns the source (typically process-name) associated with an entry
var GetVM = GetterFunc(func(entry Entry) (interface{}, bool) { return entry.VM(), true })
GetVM returns the VM associated with an entry
var NoOpTransformation = func(d interface{}) (interface{}, bool) { return d, true }
Functions ¶
This section is empty.
Types ¶
type DTStats ¶
type DTStats struct { Name string Min time.Duration Max time.Duration Mean time.Duration N int MinWinner EntryPair MaxWinner EntryPair }
DTStats bndles up statistics extracted from a collection of EntryPairs
type DTStatsSlice ¶
type DTStatsSlice []DTStats
DTStatsSLice is a collection of DTStats
func (DTStatsSlice) String ¶
func (d DTStatsSlice) String() string
String() joins the Strings() of the underlying DTStats
type Durations ¶
Duration wraps []time.Duration and adds a number of convenience methods
func (Durations) CountInRange ¶
CountInRange returns the number of durations between min and max It's used to construct histograms
type Entries ¶
type Entries []Entry
Entries is a list of invidiual Entry(ies)
func (Entries) ConstructTimeline ¶
func (e Entries) ConstructTimeline(description TimelineDescription, zeroEntry Entry) Timeline
ConstructTimeline takes a TimelineDescription and a Zeroth entry and returns a Timeline The Zeroth entry is used to compute the starting time the Timeline
func (Entries) First ¶
First returns the *first* Entry that satisfies the passed in Matcher. The second return value tells the caller if an entry was found or not
func (Entries) GroupBy ¶
func (e Entries) GroupBy(getter Getter) *GroupedEntries
GroupBy groups all Entries by the passed in Getter it returns a GroupedEntries object The values returned by the Getter correpond to the Keys in the returned GroupedEntries object
type Entry ¶
An Entry represtents a Cicerone log line
func (Entry) LagerFormat ¶
type EntryPair ¶
EntryPair represents a span in time between two Entries It includes an arbitrary annotation
type EntryPairs ¶
type EntryPairs []EntryPair
EntryPairs is a slice of EntryPair
func (EntryPairs) DTStats ¶
func (e EntryPairs) DTStats() DTStats
DTStats returns a DTStats rollup summarizing the distribution of time intervals in the slice of EntryPairs
func (EntryPairs) Durations ¶
func (e EntryPairs) Durations() Durations
Durations returns a Durations slice of time.Duration composed - it's a collection of the time intervals in the slice of EntryPairs
func (EntryPairs) FilterByDurationGreaterThan ¶
func (e EntryPairs) FilterByDurationGreaterThan(cutoff time.Duration) EntryPairs
FilterByDurationGreaterThan returns a copy of the EntryPairs containing entries that exceed the passed in duration
func (EntryPairs) FilterByDurationLessThan ¶
func (e EntryPairs) FilterByDurationLessThan(cutoff time.Duration) EntryPairs
FilterByDurationGreaterThan returns a copy of the EntryPairs containing entries that exceed the passed in duration
func (EntryPairs) String ¶
func (e EntryPairs) String() string
type Getter ¶
Getter objects can return arbitrary data from a passed-in-Entry
func DataGetter ¶
DataGetter returns a Getter that can extract data from an Entry's Data field DataGetter takes multiple keys. These are tried in order -- if a key is found in the Data field, the corresponding value is returned. A key can be a full-blown JSON path (e.g. `foo.bar.baz`) -- DataGetter will traverse the Data field as far as possible to fetch the corresponding value.
These behaviors combine well wtih entries.GroupBy. In particular, we are often inconsistent with how we name keys in our lager.Data -- sometimes this is intentional as a message passes from one layer of abstraction to another. For example, TaskGuid becomes Guid becomes Container.Handle as it flows from BBS=>Rep=>Executor=>Garden.
To group by TaskGuid one can
entries.GroupBy(DataGetter("TaskGuid", "Guid", "Container.Handle"))
func TransformingGetter ¶
func TransformingGetter(transformations TransformationMap) Getter
type GetterFunc ¶
GetterFunc makes it easy to create Getters from bare functions
func (GetterFunc) Get ¶
func (g GetterFunc) Get(entry Entry) (interface{}, bool)
Get satisfies the Getter interface
type GroupedEntries ¶
type GroupedEntries struct { Keys []interface{} Entries []Entries // contains filtered or unexported fields }
GroupedEntries represent an ordered collection of Grouped Entries.
groupedEntries.Keys is a slice of Keys (the value returned by the Getter passed to entries.GroupBy) groupedEntries.Entries is a slice of Entries for each Key
GroupedEntries uses parallel arrays to retain the ordering in which Keys are detected - the first Key in the GroupedEntries is the first Key that was detected by entried.GroupBy
func NewGroupedEntries ¶
func NewGroupedEntries() *GroupedEntries
NewGroupedEntries initializes a new GroupedEntries
func (*GroupedEntries) Append ¶
func (g *GroupedEntries) Append(key interface{}, entry Entry)
Append adds an entry to the given Key
func (*GroupedEntries) AppendEntries ¶
func (g *GroupedEntries) AppendEntries(key interface{}, entries Entries)
Append entries appends a slice of Entries to the given Key
func (*GroupedEntries) ConstructTimelines ¶
func (g *GroupedEntries) ConstructTimelines(description TimelineDescription) (Timelines, error)
ConstructTimelines creates a slice of Timelines by calling entries.ConstructTimeline on each Entries element in the group. The Key associated with the Entries element becomes the Annotation associated with the Timeline.
Note that Timelines aren't Key=>Timeline mappings. Instead GroupedEntries returns a *flat list* of Timelines with the Key parameter associated with the individual Timeline.
func (*GroupedEntries) EachGroup ¶
func (g *GroupedEntries) EachGroup(f func(interface{}, Entries) error) error
EachGroup is an iterator (think functional thoughts) that loops over all Keys and Entries in order
groupedEntries.EachGroup(func(key interface{}, entries Entries) error { fmt.Printf("%s: %s\n", key, entries) return nil })
will print all entries in the group. Returning non-nil will cause the iterator to abort.
func (*GroupedEntries) Filter ¶
func (g *GroupedEntries) Filter(matcher Matcher) *GroupedEntries
Filter applies `entries.Filter` to each Entries element in the group. Entries that end up empty are removed from the group.
As a consequence:
entries.Filter(matcher).GroupBy(getter)
and
entries.GroupBy(getter).Filter(matcher)
are identical.
func (*GroupedEntries) Lookup ¶
func (g *GroupedEntries) Lookup(key interface{}) (Entries, bool)
Look up entries for a given key
func (*GroupedEntries) WriteLagerFormatTo ¶
func (g *GroupedEntries) WriteLagerFormatTo(w io.Writer) error
WriteLagerFormat emits lager formatted output for all Entries in the group.
type GroupedTimelines ¶
type GroupedTimelines struct { Keys []interface{} Timelines []Timelines // contains filtered or unexported fields }
GroupedTimelines represent an ordered collection of Grouped Timelines
func NewGroupedTimelines ¶
func NewGroupedTimelines() *GroupedTimelines
NewGroupedTimelines initializes a new GroupedTimelines
func (*GroupedTimelines) Append ¶
func (g *GroupedTimelines) Append(key interface{}, timeline Timeline)
Append adds an timeline to the given Key
func (*GroupedTimelines) AppendTimelines ¶
func (g *GroupedTimelines) AppendTimelines(key interface{}, timelines Timelines)
Append timelines appends a slice of Timeline to the given Key
func (*GroupedTimelines) Description ¶
func (g *GroupedTimelines) Description() TimelineDescription
Description returns the TimelineDescription associated with the Timelines in the group
func (*GroupedTimelines) EachGroup ¶
func (g *GroupedTimelines) EachGroup(f func(interface{}, Timelines) error) error
EachGroup is an iterator (think functional thoughts) that loops over all Keys and Timelines in order
groupedTimelines.EachGroup(func(key interface{}, timelines Timelines) error { fmt.Printf("%s: %s\n", key, timelines) return nil })
will print all timelines in the group. Returning non-nil will cause the iterator to abort.
func (*GroupedTimelines) Lookup ¶
func (g *GroupedTimelines) Lookup(key interface{}) (Timelines, bool)
Look up timelines for a given key
type Matcher ¶
Matcher objects can test an Entry, returning true/false
func And ¶
And combines Matchers - the output is the logical && of the output of each component Matcher
func MatchAfter ¶
MatchAfter returns true if the Entry's timestamp is after the passed-in time
func MatchBefore ¶
MatchBefore returns true if the Entry's timestamp is before the passed-in time
func MatchBetween ¶
MatchBefore returns true if the Entry's timestamp is within the interval supplied
func MatchIndex ¶
MatchIndex matches true if the Entry's Index matches the passed-in integer
func MatchJob ¶
MatchJob matches true if the Entry's Job matches the passed-in string (interpreted as a regular expression)
func MatchLogLevel ¶
MatchLogLEvel matches true if the Entry's LogLevel matches the passed-in lager.LogLevel
func MatchMessage ¶
MatchMessage matches true if the Entry's Message matches the passed-in string (interpreted as a regular expression)
func MatchSession ¶
MatchSession matches true if the Entry's Session matches the passed-in string (interpreted as a regular expression)
func MatchSource ¶
MatchSource matches true if the Entry's Source matches the passed-in string (interpreted as a regular expression)
func MatchVM ¶
MatchVM matches true if the Entry's VM matches the passed-in string (interpreted as a regular expression)
func Or ¶
Or combines Matchers - the output is the logical || of the output of each component Matcher
func RegExpMatcher ¶
RegExpMatcher takes a Getter (presumed to return a string) and a regular expression (encoded as a string) RegExpMatcher returns true of the string returned by the Getter matches the passed-in regular expression.
type MatcherFunc ¶
MatcherFunc makes it easy to create Matchers from bare functions
func (MatcherFunc) Match ¶
func (m MatcherFunc) Match(entry Entry) bool
Match satisifes the Matcher interface
type Timeline ¶
type Timeline struct { Annotation interface{} Description TimelineDescription ZeroEntry Entry Entries Entries }
Timeline encapsulates a slice of Entries and a corresponding TimelineDescription A Timeline can have an optional - arbitrary - Annotation A Timeline also has a ZeroEntry. This is used as a zero point to compute the time at which the first entry occurs. The Timeline is effectively comprised of two parallel slices: the TimelineDescription and the slice of Entries.
func (Timeline) BeginsAt ¶
BeginsAt returns the timestamp at which the first non-zero entry in the Timeline occurs Note: BeginsAt does not include the ZeroEntry.
func (Timeline) EndsAt ¶
EndsAt returns the timestamp at which the last non-zero entry in the Timeline occurs
func (Timeline) EntryPair ¶
EntryPair returns the EntryPair at the passed-in index of the Timeline.
EntryPair is strict: only timeline points where both the preceding entry and requested entry are non-zero are returned.
As a concrete example, consider a Timeline constructed with a TimelineDescription of:
description := { {"Object-Created", CreateMatcher}, {"Object-Run", RunMatcher}, {"Object-Destroyed", DestroyMatcher} }
Then
timeline.EntryPair(1)
Will return an EntryPair where the FirstEntry corresponds to the Object-Created Entry and the SecondEntry corresponds to the Object-Run event.
The annotation associated with the resulting EntryPair is set to the Annotation associated with this Timeline.
Finally, note that
timeline.EntryPair(0)
returns the ZeroEntry as the FirstEntry in the pair.
func (Timeline) First ¶
First returns the first entry in the timeline that matches the passed-in matcher
func (Timeline) IsComplete ¶
IsComplete returns true if all events in the timeline are present
type TimelineDescription ¶
type TimelineDescription []TimelinePoint
A TimelineDescription is an ordered list of TimelinePoints.
type TimelinePoint ¶
A TimelinePoint describes a point in a TimelineDescription
The Name is any string to associate with the TimelinePoint The Matcher is used to identify Entries that should be associated with the TimelinePoint
type Timelines ¶
type Timelines []Timeline
Timelines is a slice of Timeline It is assumed (though not enforced) that all Timeline entries share identical TimelineDescriptions
func (Timelines) CompleteTimelines ¶
CompleteTimelines returns the subset of Timelines that are complete.
func (Timelines) DTStatsSlice ¶
func (t Timelines) DTStatsSlice() DTStatsSlice
DTStatsSlice returns a collection of DTStats -- one for each TimelinePoint in the TimelineDescription
This allows one to efficiently identify (for example) which TimelinePoint contributes the most to the total elapsed time.
func (Timelines) Description ¶
func (t Timelines) Description() TimelineDescription
Description returns the TimelineDescription associated with the Timelines
func (Timelines) EndsAfter ¶
StartsAfter finds the largest timeline.EndsAt().Sub(timeline.ZeroEntry.Timestamp) in the entire set of Timelines in the sample
func (Timelines) EntryPairs ¶
func (t Timelines) EntryPairs(index int) EntryPairs
EntryPairs fetches the EntryPair at the passed-in index for each Timeline then returns the corresponding list of EntryPairs It filters out EntryPairs with negative DTs.
See the documentation for timeline.EntryPair for more details
func (Timelines) GroupBy ¶
func (t Timelines) GroupBy(matcher Matcher, getter Getter) *GroupedTimelines
GroupBy returns GroupedTimelines - to compute the grouping key a matcher is used to pick out an entry in the timeline then a getter is used to fetch the key
func (Timelines) MatchedEntryPairs ¶
func (t Timelines) MatchedEntryPairs(i, j int) (EntryPairs, EntryPairs)
MatchedEntryPairs fetches two EntryPairs, one for each of the passed-in indices for each Timeline. It ensures that each entry in the first EntryPairs list corresponds to the entry at the same index in the second list. It also ensures that no entries with negative DTs are in either list.
See the documentation for timeline.EntryPair for more details
func (Timelines) SortByEndTime ¶
func (t Timelines) SortByEndTime()
SortByEndTime sorts the Timelines in-place by the timestamp returned by timeline.EndsAt()
func (Timelines) SortByEntryAtIndex ¶
SortByEntryAtIndex sorts the Timelines in-place by the timestamp of the entry at the specifeid index in the TimelineDescription
func (Timelines) SortByStartTime ¶
func (t Timelines) SortByStartTime()
SortByStartTime sorts the Timelines in-place by the timestamp returned by timeline.BeginsAt()
func (Timelines) SortByVMForEntryAtIndex ¶
SortByVMForEntryAtindex sorts the Timelines in-place by VM
Since a Timeline can be comprised of events that span multiple VMs one must specify the entry (by index in the TimelineDescription) that should be used to fetch the VM.
func (Timelines) StartsAfter ¶
StartsAfter finds the smallest timeline.BeginsAt().Sub(timeline.ZeroEntry.Timestamp) in the entire set of Timelines in the sample
type TransformationFunction ¶
type TransformationFunction func(interface{}) (interface{}, bool)
func TrimWithPrefixTransformation ¶
func TrimWithPrefixTransformation(prefix string) TransformationFunction
type TransformationMap ¶
type TransformationMap map[string]TransformationFunction