Skip to content

Commit

Permalink
(+) "program" message field
Browse files Browse the repository at this point in the history
  • Loading branch information
ont committed May 8, 2018
1 parent d9bdd20 commit fd85613
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/flux/log-message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import log "github.com/sirupsen/logrus"

var (
HostFieldName string // name of "host" field in json log message
MessageFieldName string // name of "message" field in json log message
RouteFieldName string // name of "route" field in json log message
ProgramFieldName string // name of "program" field
MessageFieldName string // name of "message" field
RouteFieldName string // name of "route" field
)

func init() {
HostFieldName = GetenvStr("FLUX_HOST_FIELD_NAME", "HOST")
ProgramFieldName = GetenvStr("FLUX_PROGRAM_FIELD_NAME", "PROGRAM")
MessageFieldName = GetenvStr("FLUX_MESSAGE_FIELD_NAME", "MESSAGE")
RouteFieldName = GetenvStr("FLUX_ROUTE_FIELD_NAME", "ROUTE")
}
Expand All @@ -20,6 +22,10 @@ func (l LogMessage) Host() string {
return l.getFieldStr(HostFieldName)
}

func (l LogMessage) Program() string {
return l.getFieldStr(ProgramFieldName)
}

func (l LogMessage) Message() string {
return l.getFieldStr(MessageFieldName)
}
Expand All @@ -30,6 +36,7 @@ func (l LogMessage) Route() string {

func (l LogMessage) Validate() bool {
return l.hasField(HostFieldName) &&
l.hasField(ProgramFieldName) &&
l.hasField(MessageFieldName) &&
l.hasField(RouteFieldName)
}
Expand Down
5 changes: 3 additions & 2 deletions src/flux/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ func (w *Worker) Process(message LogMessage) {
Debug("worker: parsed tags and values after script")
}

// add hostname as tag to point
// NOTE: it overwrites any "tag_host" value from regexp and script
// add hostname and program as tag to influx point
// NOTE: it overwrites any "tag_host" and "tag_program" value from regexp and script
tags["host"] = message.Host()
tags["program"] = message.Program()

log.WithField("tags", tags).
WithField("values", values).
Expand Down

0 comments on commit fd85613

Please sign in to comment.