func (this *alarmWorker) inject(msg *als.AlsMessage, project *engine.ConfProject) { args, severity, err := this.fieldValues(msg) if err != nil { if err != errMessageIgnored && project.ShowError { project.Println(err) } return } if len(args) != len(this.conf.fields) { // message ignored return } if this.conf.instantFormat != "" { iargs := append([]interface{}{msg.Area}, args...) // 'area' is always 1st col this.workersMutex.Lock() this.colorPrintfLn(true, this.conf.instantFormat, iargs...) this.workersMutex.Unlock() if this._instantAlarmOnly { this.feedAlarmMail(false, severity, this.conf.instantFormat, iargs...) return } } // insert_stmt must be like INSERT INTO (area, ts, ...) args = append([]interface{}{msg.Area, msg.Timestamp}, args...) // enque to slide window this.insert(args...) }
func (this *EsOutput) feedEs(project *engine.ConfProject, pack *engine.PipelinePack) { if pack.EsType == "" || pack.EsIndex == "" { if project.ShowError { project.Printf("Empty ES meta: %s plugins:%v", *pack, pack.PluginNames()) } this.counters.Inc("_error_", 1) return } this.counters.Inc(pack.EsIndex+":"+pack.EsType, 1) this.totalN += 1 if this.dryRun { return } date := time.Unix(int64(pack.Message.Timestamp), 0) data, err := pack.Message.MarshalPayload() if err != nil { project.Println(err, *pack) return } id, _ := uuid.UUID() this.indexer.Index(pack.EsIndex, pack.EsType, id, "", &date, data) // ttl empty }
func (this *SkyOutput) feedSky(project *engine.ConfProject, pack *engine.PipelinePack) { var ( uid interface{} action interface{} err error ) // get uid uid, err = pack.Message.FieldValue(this.uidField, this.uidFieldType) if err != nil { if project.ShowError { project.Printf("invalid uid: %v %s", err, *pack) } return } action, err = pack.Message.FieldValue(this.actionField, this.actionFieldType) if err != nil { if project.ShowError { project.Printf("invalid action: %v %s", err, *pack) } return } eventMap, err := pack.Message.Map() if err != nil { if project.ShowError { project.Println(err) } return } event := sky.NewEvent(pack.Message.Time(), eventMap) if this.actionFieldType == als.KEY_TYPE_INT { event.Data["action"] = "action_" + strconv.Itoa(action.(int)) } else { event.Data["action"] = action } // objectId is uid string err = this.table.AddEvent(strconv.Itoa(uid.(int)), event, sky.Merge) if err != nil && project.ShowError { project.Println(err) } }