Class PipelineConfig
- java.lang.Object
-
- com.github.loki4j.client.pipeline.PipelineConfig
-
public class PipelineConfig extends java.lang.ObjectConfiguration properties for Loki4j pipeline
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPipelineConfig.Builderstatic classPipelineConfig.WriterFactoryA factory for Writer
-
Field Summary
Fields Modifier and Type Field Description intbatchMaxBytesMax number of bytes a single batch can contain (as counted by Loki).intbatchMaxItemsMax number of events to put into a single batch before sending it to LokilongbatchTimeoutMsMax time in milliseconds to keep a batch before sending it to Loki, even if max items/bytes limits for this batch are not reachedstatic java.util.function.Function<HttpConfig,Loki4jHttpClient>defaultHttpClientFactorybooleandrainOnStopIf true, the pipeline will try to send all the remaining events on shutdown, so the proper shutdown procedure might take longer.java.util.function.Function<HttpConfig,Loki4jHttpClient>httpClientFactoryA factory for HTTP client for sending logs to Loki.HttpConfighttpConfigConfiguration properties for HTTP clientsjava.util.function.Function<java.lang.Object,Loki4jLogger>internalLoggingFactoryA factory for an internal logger.longinternalQueuesCheckTimeoutMsA timeout for Loki4j threads to sleep if encode or send queues are empty.static PipelineConfig.WriterFactoryjsonintmaxRetriesMax number of attempts to send a batch to Loki before it will be dropped.booleanmetricsEnabledIf true, the pipeline will report its metrics using Micrometerjava.lang.StringnameName of this pipelinestatic PipelineConfig.WriterFactoryprotobuflongretryTimeoutMsTime in milliseconds to wait before the next attempt to re-send a failed batch.longsendQueueMaxBytesMax number of bytes to keep in the send queue.booleansortByTimeIf true, log records in batch are sorted by timestamp.booleanstaticLabelsIf you use only one label for all log records, you can set this flag to true and save some CPU time on grouping records by label.booleanuseDirectBuffersUse off-heap memory for storing intermediate dataPipelineConfig.WriterFactorywriterFactoryA factory for Writer
-
Constructor Summary
Constructors Constructor Description PipelineConfig(java.lang.String name, int batchMaxItems, int batchMaxBytes, long batchTimeoutMs, boolean sortByTime, boolean staticLabels, long sendQueueMaxBytes, int maxRetries, long retryTimeoutMs, long internalQueuesCheckTimeoutMs, boolean useDirectBuffers, boolean drainOnStop, boolean metricsEnabled, PipelineConfig.WriterFactory writerFactory, HttpConfig httpConfig, java.util.function.Function<HttpConfig,Loki4jHttpClient> httpClientFactory, java.util.function.Function<java.lang.Object,Loki4jLogger> internalLoggingFactory)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static HttpConfig.Builderapache(int maxConnections, long connectionKeepAliveMs)static PipelineConfig.Builderbuilder()static HttpConfig.Builderjava(long innerThreadsExpirationMs)
-
-
-
Field Detail
-
json
public static final PipelineConfig.WriterFactory json
-
protobuf
public static final PipelineConfig.WriterFactory protobuf
-
defaultHttpClientFactory
public static final java.util.function.Function<HttpConfig,Loki4jHttpClient> defaultHttpClientFactory
-
name
public final java.lang.String name
Name of this pipeline
-
batchMaxItems
public final int batchMaxItems
Max number of events to put into a single batch before sending it to Loki
-
batchMaxBytes
public final int batchMaxBytes
Max number of bytes a single batch can contain (as counted by Loki). This value should not be greater than server.grpc_server_max_recv_msg_size in your Loki config
-
batchTimeoutMs
public final long batchTimeoutMs
Max time in milliseconds to keep a batch before sending it to Loki, even if max items/bytes limits for this batch are not reached
-
sortByTime
public final boolean sortByTime
If true, log records in batch are sorted by timestamp. If false, records will be sent to Loki in arrival order. Turn this on if you see 'entry out of order' error from Loki.
-
staticLabels
public final boolean staticLabels
If you use only one label for all log records, you can set this flag to true and save some CPU time on grouping records by label.
-
sendQueueMaxBytes
public final long sendQueueMaxBytes
Max number of bytes to keep in the send queue. When the queue is full, incoming log events are dropped
-
maxRetries
public final int maxRetries
Max number of attempts to send a batch to Loki before it will be dropped. A failed batch send could be retried only in case of ConnectException or 503 status from Loki. All other exceptions and 4xx-5xx statuses do not cause a retry in order to avoid duplicates.
-
retryTimeoutMs
public final long retryTimeoutMs
Time in milliseconds to wait before the next attempt to re-send a failed batch.
-
internalQueuesCheckTimeoutMs
public final long internalQueuesCheckTimeoutMs
A timeout for Loki4j threads to sleep if encode or send queues are empty. Decreasing this value means lower latency at cost of higher CPU usage.
-
useDirectBuffers
public final boolean useDirectBuffers
Use off-heap memory for storing intermediate data
-
drainOnStop
public final boolean drainOnStop
If true, the pipeline will try to send all the remaining events on shutdown, so the proper shutdown procedure might take longer. Otherwise, the pipeline will drop the unsent events
-
metricsEnabled
public final boolean metricsEnabled
If true, the pipeline will report its metrics using Micrometer
-
writerFactory
public final PipelineConfig.WriterFactory writerFactory
A factory for Writer
-
httpConfig
public final HttpConfig httpConfig
Configuration properties for HTTP clients
-
httpClientFactory
public final java.util.function.Function<HttpConfig,Loki4jHttpClient> httpClientFactory
A factory for HTTP client for sending logs to Loki. Argument is a config required for constructing an HTTP client
-
internalLoggingFactory
public final java.util.function.Function<java.lang.Object,Loki4jLogger> internalLoggingFactory
A factory for an internal logger. Argument is a source class to report log messages from
-
-
Constructor Detail
-
PipelineConfig
public PipelineConfig(java.lang.String name, int batchMaxItems, int batchMaxBytes, long batchTimeoutMs, boolean sortByTime, boolean staticLabels, long sendQueueMaxBytes, int maxRetries, long retryTimeoutMs, long internalQueuesCheckTimeoutMs, boolean useDirectBuffers, boolean drainOnStop, boolean metricsEnabled, PipelineConfig.WriterFactory writerFactory, HttpConfig httpConfig, java.util.function.Function<HttpConfig,Loki4jHttpClient> httpClientFactory, java.util.function.Function<java.lang.Object,Loki4jLogger> internalLoggingFactory)
-
-
Method Detail
-
apache
public static HttpConfig.Builder apache(int maxConnections, long connectionKeepAliveMs)
-
java
public static HttpConfig.Builder java(long innerThreadsExpirationMs)
-
builder
public static final PipelineConfig.Builder builder()
-
-