Class CortexIo
- java.lang.Object
-
- org.opennms.nephron.cortex.CortexIo
-
@Experimental(SOURCE_SINK) public class CortexIo extends Object
Provides write transforms (sinks) for writing to Cortex.Cortex requires that samples of a specific time series are written with increasing timestamps. The write transforms assign index numbers to output values that can be used as an additional metric label that make time series strictly increasing even in case of multiple panes for the same window and panes of later windows completing before panes of earlier windows.
This class can provide two different kinds of sinks:
- Non-accumulating sink
- A sink that assigns unique index numbers to output values.
- Accumulating sink
- A sink that assigns unique index numbers to output values and additionally accumulates values of different panes before they are output.
Note: The
PaneAccumulatorclass can be used to achieve the same accumulation effect that the accumulating Cortex sink has. It makes sense to use thePaneAccumulatorif several sinks can benefit from accumulated outputs. In case of a single sink the accumulating Cortex sink is preferable.Sinks are configured by the
CortexIo.Writeclass and are implemented by subclasses of theCortexIo.WriteFnclass. Sinks provide the following counter metrics in the "cortex" namespace:- sample
- Counts the number of samples
- write
- Counts the number of sent write requests
- write_failure
- Counts the number of failed write requests (requests that resulted in an exception)
- response_failure
- Counts the number of Cortex responses with a non-success result code
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCortexIo.BuildTimeSeries<K,V>static classCortexIo.Write<K,V>Stores the configuration of the transforms.static classCortexIo.WriteFn<K,V,W extends CortexIo.Write<K,V>>Function class for writing to Cortex.static classCortexIo.WriteFnWithAccumulation<K,V>A Cortex sink that assigns unique index numbers and accumulates values.static classCortexIo.WriteFnWithoutAccumulation<K,V>A Cortex sink that assigns unique index numbers.
-
Field Summary
Fields Modifier and Type Field Description static StringCORTEX_METRIC_NAMESPACEstatic StringCORTEX_RESPONSE_FAILURE_METRIC_NAMEstatic StringCORTEX_SAMPLE_METRIC_NAMEstatic StringCORTEX_WRITE_FAILURE_METRIC_NAMEstatic StringCORTEX_WRITE_METRIC_NAMEstatic com.swrve.ratelimitedlogger.RateLimitedLogRATE_LIMITED_LOG
-
Constructor Summary
Constructors Constructor Description CortexIo()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
CortexIo.Write<K,V>of(String writeUrl, CortexIo.BuildTimeSeries<K,V> build)Creates a Cortex sink.static <K,V>
CortexIo.Write<K,V>of(String writeUrl, CortexIo.BuildTimeSeries<K,V> build, org.apache.beam.sdk.coders.Coder<K> keyCoder, org.apache.beam.sdk.coders.Coder<V> valueCoder, org.apache.beam.sdk.transforms.SerializableBiFunction<V,V,V> combiner, org.joda.time.Duration accumulationDelay)static voidsanitize(String name, String value, BiConsumer<String,String> consumer)static StringsanitizeLabelName(String labelName)static StringsanitizeMetricName(String metricName)
-
-
-
Field Detail
-
RATE_LIMITED_LOG
public static final com.swrve.ratelimitedlogger.RateLimitedLog RATE_LIMITED_LOG
-
CORTEX_METRIC_NAMESPACE
public static final String CORTEX_METRIC_NAMESPACE
- See Also:
- Constant Field Values
-
CORTEX_WRITE_METRIC_NAME
public static final String CORTEX_WRITE_METRIC_NAME
- See Also:
- Constant Field Values
-
CORTEX_SAMPLE_METRIC_NAME
public static final String CORTEX_SAMPLE_METRIC_NAME
- See Also:
- Constant Field Values
-
CORTEX_WRITE_FAILURE_METRIC_NAME
public static final String CORTEX_WRITE_FAILURE_METRIC_NAME
- See Also:
- Constant Field Values
-
CORTEX_RESPONSE_FAILURE_METRIC_NAME
public static final String CORTEX_RESPONSE_FAILURE_METRIC_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
of
public static <K,V> CortexIo.Write<K,V> of(String writeUrl, CortexIo.BuildTimeSeries<K,V> build)
Creates a Cortex sink.
-
of
public static <K,V> CortexIo.Write<K,V> of(String writeUrl, CortexIo.BuildTimeSeries<K,V> build, org.apache.beam.sdk.coders.Coder<K> keyCoder, org.apache.beam.sdk.coders.Coder<V> valueCoder, org.apache.beam.sdk.transforms.SerializableBiFunction<V,V,V> combiner, org.joda.time.Duration accumulationDelay)
-
sanitize
public static void sanitize(String name, String value, BiConsumer<String,String> consumer)
-
-