skip invalid entries

This commit is contained in:
2017-09-24 17:21:20 +02:00
parent a7cd918fc6
commit e0655f66fa

View File

@@ -116,15 +116,21 @@ public class TcpIngestor implements Ingestor, AutoCloseable, DisposableBean {
public Optional<Entry> createEntry(final Map<String, Object> map) { public Optional<Entry> createEntry(final Map<String, Object> map) {
try { try {
final OffsetDateTime date = getDate(map); if (map.containsKey("duration")
final long duration = (int) map.get("duration"); && map.containsKey("@timestamp")) {
final OffsetDateTime date = getDate(map);
final long duration = (int) map.get("duration");
final Tags tags = createTags(map); final Tags tags = createTags(map);
final Entry entry = new Entry(date, duration, tags); final Entry entry = new Entry(date, duration, tags);
return Optional.of(entry); return Optional.of(entry);
} else {
LOGGER.info("Skipping invalid entry: " + map);
return Optional.empty();
}
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.error("Failed to create entry.", e); LOGGER.error("Failed to create entry from map: " + map, e);
return Optional.empty(); return Optional.empty();
} }
} }