@ -45,17 +45,18 @@ type receivedReq struct {
func TestClient_Handle ( t * testing . T ) {
tests := map [ string ] struct {
clientBatchSize int
clientBatchWait time . Duration
clientMaxRetries int
clientMaxLineSize int
clientTenantID string
clientDropRateLimited bool
serverResponseStatus int
inputEntries [ ] api . Entry
inputDelay time . Duration
expectedReqs [ ] receivedReq
expectedMetrics string
clientBatchSize int
clientBatchWait time . Duration
clientMaxRetries int
clientMaxLineSize int
clientMaxLineSizeTruncate bool
clientTenantID string
clientDropRateLimited bool
serverResponseStatus int
inputEntries [ ] api . Entry
inputDelay time . Duration
expectedReqs [ ] receivedReq
expectedMetrics string
} {
"batch log entries together until the batch size is reached" : {
clientBatchSize : 10 ,
@ -80,17 +81,31 @@ func TestClient_Handle(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
` ,
} ,
"log entries have max_line_size exceeded" : {
clientBatchSize : 10 ,
clientBatchWait : 100 * time . Millisecond ,
clientMaxRetries : 3 ,
clientMaxLineSize : 10 , // any log line more than this length should be discarded
serverResponseStatus : 200 ,
inputEntries : [ ] api . Entry { logEntries [ 0 ] , logEntries [ 1 ] , logEntries [ 6 ] } , // this logEntries[6] entries has line more than size 10
"dropping log entries that have max_line_size exceeded" : {
clientBatchSize : 10 ,
clientBatchWait : 100 * time . Millisecond ,
clientMaxRetries : 3 ,
clientMaxLineSize : 10 , // any log line more than this length should be discarded
clientMaxLineSizeTruncate : false ,
serverResponseStatus : 200 ,
inputEntries : [ ] api . Entry { logEntries [ 0 ] , logEntries [ 1 ] , logEntries [ 6 ] } , // this logEntries[6] entries has line more than size 10
expectedReqs : [ ] receivedReq {
{
tenantID : "" ,
@ -104,9 +119,66 @@ func TestClient_Handle(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 1
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "max_line_size_limited" , tenant = "" } 1
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
` ,
} ,
"truncating log entries that have max_line_size exceeded" : {
clientBatchSize : 10 ,
clientBatchWait : 100 * time . Millisecond ,
clientMaxRetries : 3 ,
clientMaxLineSize : 10 ,
clientMaxLineSizeTruncate : true ,
serverResponseStatus : 200 ,
inputEntries : [ ] api . Entry { logEntries [ 0 ] , logEntries [ 1 ] , logEntries [ 6 ] } , // logEntries[6]'s line is greater than 10 bytes
expectedReqs : [ ] receivedReq {
{
tenantID : "" ,
pushReq : logproto . PushRequest { Streams : [ ] logproto . Stream { { Labels : "{}" , Entries : [ ] logproto . Entry {
logEntries [ 0 ] . Entry ,
logEntries [ 1 ] . Entry ,
{
Timestamp : logEntries [ 6 ] . Entry . Timestamp ,
Line : logEntries [ 6 ] . Line [ : 10 ] ,
} ,
} } } } ,
} ,
} ,
expectedMetrics : `
# HELP promtail_sent_entries_total Number of log entries sent to the ingester .
# TYPE promtail_sent_entries_total counter
promtail_sent_entries_total { host = "__HOST__" } 3.0
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 1
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 4
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
` ,
} ,
@ -134,8 +206,21 @@ func TestClient_Handle(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
` ,
} ,
"retry send a batch up to backoff's max retries in case the server responds with a 5xx" : {
@ -162,8 +247,21 @@ func TestClient_Handle(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 1
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_sent_entries_total Number of log entries sent to the ingester .
# TYPE promtail_sent_entries_total counter
promtail_sent_entries_total { host = "__HOST__" } 0
@ -185,8 +283,21 @@ func TestClient_Handle(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 1
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_sent_entries_total Number of log entries sent to the ingester .
# TYPE promtail_sent_entries_total counter
promtail_sent_entries_total { host = "__HOST__" } 0
@ -216,8 +327,21 @@ func TestClient_Handle(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 1
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_sent_entries_total Number of log entries sent to the ingester .
# TYPE promtail_sent_entries_total counter
promtail_sent_entries_total { host = "__HOST__" } 0
@ -240,8 +364,21 @@ func TestClient_Handle(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 1
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_sent_entries_total Number of log entries sent to the ingester .
# TYPE promtail_sent_entries_total counter
promtail_sent_entries_total { host = "__HOST__" } 0
@ -267,8 +404,21 @@ func TestClient_Handle(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-default" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-default" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-default" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-default" } 0
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-default" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-default" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-default" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-default" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-default" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-default" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-default" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-default" } 0
` ,
} ,
"batch log entries together honoring the tenant ID overridden while processing the pipeline stages" : {
@ -301,12 +451,43 @@ func TestClient_Handle(t *testing.T) {
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-1" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-2" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-default" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-1" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-2" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-default" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-1" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-2" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-default" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-1" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-2" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-default" } 0
# HELP promtail_mutated_entries_total The total number of log entries that have been mutated .
# TYPE promtail_mutated_entries_total counter
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-1" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-2" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-default" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-1" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-2" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-default" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-1" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-2" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-default" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-1" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-2" } 0
promtail_mutated_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-default" } 0
# HELP promtail_mutated_bytes_total The total number of bytes that have been mutated .
# TYPE promtail_mutated_bytes_total counter
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-1" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-2" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "ingester_error" , tenant = "tenant-default" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-1" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-2" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "line_too_long" , tenant = "tenant-default" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-1" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-2" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "rate_limited" , tenant = "tenant-default" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-1" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-2" } 0
promtail_mutated_bytes_total { host = "__HOST__" , reason = "stream_limited" , tenant = "tenant-default" } 0
` ,
} ,
}
@ -342,7 +523,7 @@ func TestClient_Handle(t *testing.T) {
}
m := NewMetrics ( reg )
c , err := New ( m , cfg , 0 , testData . clientMaxLineSize , log . NewNopLogger ( ) )
c , err := New ( m , cfg , 0 , testData . clientMaxLineSize , testData . clientMaxLineSizeTruncate , log . NewNopLogger ( ) )
require . NoError ( t , err )
// Send all the input log entries
@ -378,7 +559,7 @@ func TestClient_Handle(t *testing.T) {
fmt . Printf ( "Expected reqs: %#v\n" , testData . expectedReqs )
expectedMetrics := strings . Replace ( testData . expectedMetrics , "__HOST__" , serverURL . Host , - 1 )
err = testutil . GatherAndCompare ( reg , strings . NewReader ( expectedMetrics ) , "promtail_sent_entries_total" , "promtail_dropped_entries_total" )
err = testutil . GatherAndCompare ( reg , strings . NewReader ( expectedMetrics ) , "promtail_sent_entries_total" , "promtail_dropped_entries_total" , "promtail_mutated_entries_total" , "promtail_mutated_bytes_total" )
assert . NoError ( t , err )
} )
}
@ -421,6 +602,7 @@ func TestClient_StopNow(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
` ,
@ -442,6 +624,7 @@ func TestClient_StopNow(t *testing.T) {
# HELP promtail_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries .
# TYPE promtail_dropped_entries_total counter
promtail_dropped_entries_total { host = "__HOST__" , reason = "ingester_error" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "line_too_long" , tenant = "" } 0
promtail_dropped_entries_total { host = "__HOST__" , reason = "rate_limited" , tenant = "" } 1
promtail_dropped_entries_total { host = "__HOST__" , reason = "stream_limited" , tenant = "" } 0
# HELP promtail_sent_entries_total Number of log entries sent to the ingester .
@ -481,7 +664,7 @@ func TestClient_StopNow(t *testing.T) {
}
m := NewMetrics ( reg )
cl , err := New ( m , cfg , 0 , 0 , log . NewNopLogger ( ) )
cl , err := New ( m , cfg , 0 , 0 , false , log . NewNopLogger ( ) )
require . NoError ( t , err )
// Send all the input log entries
@ -557,7 +740,7 @@ func Test_Tripperware(t *testing.T) {
var called bool
c , err := NewWithTripperware ( metrics , Config {
URL : flagext . URLValue { URL : url } ,
} , 0 , 0 , log . NewNopLogger ( ) , func ( rt http . RoundTripper ) http . RoundTripper {
} , 0 , 0 , false , log . NewNopLogger ( ) , func ( rt http . RoundTripper ) http . RoundTripper {
return RoundTripperFunc ( func ( r * http . Request ) ( * http . Response , error ) {
require . Equal ( t , r . URL . String ( ) , "http://foo.com" )
called = true