private InternalStatisticEvent buildStatisticEvent(final MetaStatisticsTemplate template,
                                                       final Map<String, String> metaData) {
        Preconditions.checkNotNull(template);
        Preconditions.checkNotNull(template.getTimeMsAttribute());
        Preconditions.checkNotNull(template.getKey());
        Preconditions.checkNotNull(metaData);

        final long timeMs;
        final String timeValue = metaData.get(template.getTimeMsAttribute());
        if (timeValue != null && !timeValue.isEmpty()) {
            try {
                timeMs = DateUtil.parseNormalDateTimeString(timeValue);
            } catch (final RuntimeException e) {
                // Quit!
                return null;
            }
        } else {
            LOGGER.error("HeaderMap [{}] has no time attribute, unable to create stat", metaData);
            return null;
        }

        final SortedMap<String, String> statisticTags = new TreeMap<>();

        for (final String tagName : template.getTagAttributeList()) {
            final String tagValue = metaData.get(tagName);

            if (tagValue != null && !tagValue.isEmpty()) {
                statisticTags.put(tagName, tagValue);
            } else {
                // Quit!
                return null;
            }
        }

        long increment = 1;
        if (template.getIncrementAttribute() != null) {
            final String incrementValue = metaData.get(template.getIncrementAttribute());
            if (incrementValue != null && !incrementValue.isEmpty()) {
                try {
                    increment = Long.parseLong(incrementValue);
                } catch (final RuntimeException e) {
                    // Quit!
                    return null;
                }
            } else {
                // Quit!
                return null;
            }
        }
        return InternalStatisticEvent.createPlusNCountStat(template.getKey(), timeMs, statisticTags, increment);
    }
@return build the STAT or return null for not valid
stroom-meta/stroom-meta-statistics-impl/src/main/java/stroom/meta/statistics/impl/MetaStatisticsImpl.java