func main() { log.Info("Starting docker_events") pub := logyard.Broker.NewPublisherMust() defer pub.Stop() server.MarkRunning("docker_events") for event := range docker_events.Stream() { SendToLogyard(pub, event) } }
func main() { flag.Parse() go common.RegisterTailCleanup() apptail.LoadConfig() fstorage := storage.NewFileStorage(*stateFile_path) tracker := storage.NewTracker(fstorage, *debug) tracker.LoadTailers() interval := time.Duration(int64(apptail.GetConfig().PersistPositionIntervalSeconds)) go tracker.StartSubmissionTimer(interval * time.Second) major, minor, patch := gozmq.Version() log.Infof("Starting apptail (zeromq %d.%d.%d)", major, minor, patch) log.Infof("Config: %+v\n", apptail.GetConfig()) uid := getUID() natsclient := server.NewNatsClient(3) mux := &sync.Mutex{} n := 0 started_instances := StartedInstance{} natsclient.Subscribe("logyard."+uid+".newinstance", func(instance *apptail.Instance) { n++ if started_instances.checkInstanceAndUpdate(n, instance.DockerId, mux) { go func() { instance.Tail(tracker) started_instances.delete(instance.DockerId, mux) }() } }) natsclient.Publish("logyard."+uid+".start", []byte("{}")) log.Infof("Waiting for app instances ...") go docker.DockerListener.Listen() // clean up the cache after restart docker.DockerListener.TrackerCleanUp(tracker) server.MarkRunning("apptail") apptail_event.MonitorCloudEvents() }
func main() { go common.RegisterTailCleanup() major, minor, patch := gozmq.Version() log.Infof("Starting systail (zeromq %d.%d.%d)", major, minor, patch) systail.LoadConfig() nodeid, err := server.LocalIP() if err != nil { common.Fatal("Failed to determine IP addr: %v", err) } log.Info("Host IP: ", nodeid) tailers := []*tail.Tail{} logFiles := systail.GetConfig().LogFiles fmt.Printf("%+v\n", logFiles) if len(logFiles) == 0 { common.Fatal("No log files exist in configuration.") } for name, logfile := range logFiles { t, err := tailLogFile(name, logfile, nodeid) if err != nil { common.Fatal("%v", err) } tailers = append(tailers, t) } server.MarkRunning("systail") for _, tail := range tailers { err := tail.Wait() if err != nil { log.Errorf("Cannot tail [%s]: %s", tail.Filename, err) } } // we don't expect any of the tailers to exit with or without // error. log.Error("No file left to tail; exiting.") os.Exit(1) }
func main() { major, minor, patch := gozmq.Version() log.Infof("Starting logyard_sieve (zeromq %d.%d.%d)", major, minor, patch) LoadConfig() parser := sieve.NewStackatoParser(getConfig().Events) parser.DeleteSamples() pub := logyard.Broker.NewPublisherMust() defer pub.Stop() sub := logyard.Broker.Subscribe("systail") defer sub.Stop() server.MarkRunning("logyard_sieve") log.Info("Watching the systail stream on this node") for message := range sub.Ch { var record systail.Message err := json.Unmarshal([]byte(message.Value), &record) if err != nil { log.Warnf("failed to parse json: %s; ignoring record: %s", err, message.Value) continue } event, err := parser.Parse(record.Name, record.Text) if err != nil { log.Warnf( "failed to parse event from %s: %s -- source: %s", record.Name, err, record.Text) continue } if event != nil { event.MessageCommon = common.NewMessageCommon( event.Desc, time.Unix(record.UnixTime, 0), record.NodeID) event.MustPublish(pub) } } }