예제 #1
0
func (out *ElasticsearchOutputType) EnableTTL() error {
	setting := map[string]interface{}{
		"server-ip": map[string]interface{}{
			"_ttl": map[string]string{"enabled": "true", "default": "15000"},
		},
	}

	// Make sure the index exists, but ignore errors (probably exists already)
	core.Index("packetbeat-topology", "", "", nil, nil)

	_, err := core.Index("packetbeat-topology", "server-ip", "_mapping", nil, setting)
	if err != nil {
		return err
	}
	return nil
}
예제 #2
0
func (out *ElasticsearchOutputType) PublishEvent(event *Event) error {

	index := fmt.Sprintf("%s-%d.%02d.%02d", out.Index, event.Timestamp.Year(), event.Timestamp.Month(), event.Timestamp.Day())
	_, err := core.Index(index, event.Type, "", nil, event)
	DEBUG("output_elasticsearch", "Publish event")
	return err
}