skip invalid entries

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

View File

@@ -116,6 +116,8 @@ 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 {
if (map.containsKey("duration")
&& map.containsKey("@timestamp")) {
final OffsetDateTime date = getDate(map); final OffsetDateTime date = getDate(map);
final long duration = (int) map.get("duration"); final long duration = (int) map.get("duration");
@@ -123,8 +125,12 @@ public class TcpIngestor implements Ingestor, AutoCloseable, DisposableBean {
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();
} }
} }