Search in sources :

Example 1 with GraphiteHostAnnotator

use of com.wavefront.ingester.GraphiteHostAnnotator in project java by wavefrontHQ.

the class PushAgent method startGraphiteListener.

protected void startGraphiteListener(String strPort, boolean withCustomFormatter) {
    int port = Integer.parseInt(strPort);
    if (prefix != null && !prefix.isEmpty()) {
        preprocessors.forPort(strPort).forReportPoint().addTransformer(new ReportPointAddPrefixTransformer(prefix));
    }
    preprocessors.forPort(strPort).forReportPoint().addFilter(new ReportPointTimestampInRangeFilter(dataBackfillCutoffHours, dataPrefillCutoffHours));
    // Add a metadatahandler, to handle @SourceTag, @SourceDescription, etc.
    SourceTagHandler metadataHandler = new SourceTagHandlerImpl(getSourceTagFlushTasks(port));
    // Set up a custom graphite handler, with no formatter
    ChannelHandler graphiteHandler = new ChannelStringHandler(new GraphiteDecoder("unknown", customSourceTags), new PointHandlerImpl(strPort, pushValidationLevel, pushBlockedSamples, getFlushTasks(strPort)), preprocessors.forPort(strPort), metadataHandler);
    if (!withCustomFormatter) {
        List<Function<Channel, ChannelHandler>> handler = Lists.newArrayList(1);
        handler.add(input -> {
            SocketChannel ch = (SocketChannel) input;
            if (ch != null && ch.remoteAddress() != null) {
                return new GraphiteHostAnnotator(disableRdnsLookup ? ch.remoteAddress().getAddress().getHostAddress() : reverseDnsCache.get(ch.remoteAddress().getAddress()), customSourceTags);
            }
            return new GraphiteHostAnnotator("unknown", customSourceTags);
        });
        startAsManagedThread(new StringLineIngester(handler, graphiteHandler, port).withChildChannelOptions(childChannelOptions), "listener-plaintext-wavefront-" + port);
    } else {
        startAsManagedThread(new StringLineIngester(graphiteHandler, port).withChildChannelOptions(childChannelOptions), "Listener-plaintext-graphite-" + port);
    }
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) GraphiteHostAnnotator(com.wavefront.ingester.GraphiteHostAnnotator) QueuingChannelHandler(com.wavefront.agent.histogram.QueuingChannelHandler) ChannelHandler(io.netty.channel.ChannelHandler) Function(com.google.common.base.Function) ReportPointAddPrefixTransformer(com.wavefront.agent.preprocessor.ReportPointAddPrefixTransformer) StringLineIngester(com.wavefront.ingester.StringLineIngester) ReportPointTimestampInRangeFilter(com.wavefront.agent.preprocessor.ReportPointTimestampInRangeFilter) GraphiteDecoder(com.wavefront.ingester.GraphiteDecoder)

Aggregations

Function (com.google.common.base.Function)1 QueuingChannelHandler (com.wavefront.agent.histogram.QueuingChannelHandler)1 ReportPointAddPrefixTransformer (com.wavefront.agent.preprocessor.ReportPointAddPrefixTransformer)1 ReportPointTimestampInRangeFilter (com.wavefront.agent.preprocessor.ReportPointTimestampInRangeFilter)1 GraphiteDecoder (com.wavefront.ingester.GraphiteDecoder)1 GraphiteHostAnnotator (com.wavefront.ingester.GraphiteHostAnnotator)1 StringLineIngester (com.wavefront.ingester.StringLineIngester)1 ChannelHandler (io.netty.channel.ChannelHandler)1 SocketChannel (io.netty.channel.socket.SocketChannel)1