Exemplo n.º 1
0
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
}