Skip to content

Commit 11d8c90

Browse files
authored
Merge pull request syslog-ng#4966 from bazsi/improve-loki-error-messages
loki: add "url" to error messages and also log about connection errors
2 parents da8591d + e9833cf commit 11d8c90

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

modules/grpc/loki/loki-worker.cpp

+15-3
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,18 @@ DestinationWorker::init()
8585
auto credentials = owner->credentials_builder.build();
8686
if (!credentials)
8787
{
88-
msg_error("Error querying Loki credentials", log_pipe_location_tag((LogPipe *) this->super->super.owner));
88+
msg_error("Error querying Loki credentials",
89+
evt_tag_str("url", owner->get_url().c_str()),
90+
log_pipe_location_tag((LogPipe *) this->super->super.owner));
8991
return false;
9092
}
9193

9294
this->channel = ::grpc::CreateCustomChannel(owner->get_url(), credentials, args);
9395
if (!this->channel)
9496
{
95-
msg_error("Error creating Loki gRPC channel", log_pipe_location_tag((LogPipe *) this->super->super.owner));
97+
msg_error("Error creating Loki gRPC channel",
98+
evt_tag_str("url", owner->get_url().c_str()),
99+
log_pipe_location_tag((LogPipe *) this->super->super.owner));
96100
return false;
97101
}
98102

@@ -110,6 +114,8 @@ DestinationWorker::deinit()
110114
bool
111115
DestinationWorker::connect()
112116
{
117+
DestinationDriver *owner = this->get_owner();
118+
113119
this->prepare_batch();
114120

115121
msg_debug("Connecting to Loki", log_pipe_location_tag((LogPipe *) this->super->super.owner));
@@ -118,7 +124,12 @@ DestinationWorker::connect()
118124
std::chrono::system_clock::now() + std::chrono::seconds(10);
119125

120126
if (!this->channel->WaitForConnected(connect_timeout))
121-
return false;
127+
{
128+
msg_error("Time out connecting to Loki",
129+
evt_tag_str("url", owner->get_url().c_str()),
130+
log_pipe_location_tag((LogPipe *) this->super->super.owner));
131+
return false;
132+
}
122133

123134
this->connected = true;
124135
return true;
@@ -240,6 +251,7 @@ DestinationWorker::flush(LogThreadedFlushMode mode)
240251
if (!status.ok())
241252
{
242253
msg_error("Error sending Loki batch", evt_tag_str("error", status.error_message().c_str()),
254+
evt_tag_str("url", owner->get_url().c_str()),
243255
evt_tag_str("details", status.error_details().c_str()),
244256
log_pipe_location_tag((LogPipe *) this->super->super.owner));
245257
result = LTR_ERROR;

0 commit comments

Comments
 (0)