Search in sources :

Example 1 with PointLineBlacklistRegexFilter

use of com.wavefront.agent.preprocessor.PointLineBlacklistRegexFilter in project java by wavefrontHQ.

the class AbstractAgent method initPreprocessors.

private void initPreprocessors() throws IOException {
    // blacklistRegex and whitelistRegex are applied to pushListenerPorts, graphitePorts and picklePorts
    if (whitelistRegex != null || blacklistRegex != null) {
        String allPorts = StringUtils.join(new String[] { pushListenerPorts == null ? "" : pushListenerPorts, graphitePorts == null ? "" : graphitePorts, picklePorts == null ? "" : picklePorts }, ",");
        Iterable<String> ports = Splitter.on(",").omitEmptyStrings().trimResults().split(allPorts);
        for (String strPort : ports) {
            if (blacklistRegex != null) {
                preprocessors.forPort(strPort).forPointLine().addFilter(new PointLineBlacklistRegexFilter(blacklistRegex, Metrics.newCounter(new TaggedMetricName("validationRegex", "points-rejected", "port", strPort))));
            }
            if (whitelistRegex != null) {
                preprocessors.forPort(strPort).forPointLine().addFilter(new PointLineWhitelistRegexFilter(whitelistRegex, Metrics.newCounter(new TaggedMetricName("validationRegex", "points-rejected", "port", strPort))));
            }
        }
    }
    // opentsdbBlacklistRegex and opentsdbWhitelistRegex are applied to opentsdbPorts only
    if (opentsdbPorts != null && (opentsdbWhitelistRegex != null || opentsdbBlacklistRegex != null)) {
        Iterable<String> ports = Splitter.on(",").omitEmptyStrings().trimResults().split(opentsdbPorts);
        for (String strPort : ports) {
            if (opentsdbBlacklistRegex != null) {
                preprocessors.forPort(strPort).forPointLine().addFilter(new PointLineBlacklistRegexFilter(opentsdbBlacklistRegex, Metrics.newCounter(new TaggedMetricName("validationRegex", "points-rejected", "port", strPort))));
            }
            if (opentsdbWhitelistRegex != null) {
                preprocessors.forPort(strPort).forPointLine().addFilter(new PointLineWhitelistRegexFilter(opentsdbWhitelistRegex, Metrics.newCounter(new TaggedMetricName("validationRegex", "points-rejected", "port", strPort))));
            }
        }
    }
    if (preprocessorConfigFile != null) {
        FileInputStream stream = new FileInputStream(preprocessorConfigFile);
        preprocessors.loadFromStream(stream);
        logger.info("Preprocessor configuration loaded from " + preprocessorConfigFile);
    }
}
Also used : PointLineWhitelistRegexFilter(com.wavefront.agent.preprocessor.PointLineWhitelistRegexFilter) PointLineBlacklistRegexFilter(com.wavefront.agent.preprocessor.PointLineBlacklistRegexFilter) TaggedMetricName(com.wavefront.common.TaggedMetricName) FileInputStream(java.io.FileInputStream)

Aggregations

PointLineBlacklistRegexFilter (com.wavefront.agent.preprocessor.PointLineBlacklistRegexFilter)1 PointLineWhitelistRegexFilter (com.wavefront.agent.preprocessor.PointLineWhitelistRegexFilter)1 TaggedMetricName (com.wavefront.common.TaggedMetricName)1 FileInputStream (java.io.FileInputStream)1