Skip to content

Commit

Permalink
loki: add "url" to error messages and also log about connection errors
Browse files Browse the repository at this point in the history
Signed-off-by: Balazs Scheidler <[email protected]>
  • Loading branch information
bazsi committed May 15, 2024
1 parent 9d3c3c3 commit e9833cf
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions modules/grpc/loki/loki-worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,18 @@ DestinationWorker::init()
auto credentials = owner->credentials_builder.build();
if (!credentials)
{
msg_error("Error querying Loki credentials", log_pipe_location_tag((LogPipe *) this->super->super.owner));
msg_error("Error querying Loki credentials",
evt_tag_str("url", owner->get_url().c_str()),
log_pipe_location_tag((LogPipe *) this->super->super.owner));
return false;
}

this->channel = ::grpc::CreateCustomChannel(owner->get_url(), credentials, args);
if (!this->channel)
{
msg_error("Error creating Loki gRPC channel", log_pipe_location_tag((LogPipe *) this->super->super.owner));
msg_error("Error creating Loki gRPC channel",
evt_tag_str("url", owner->get_url().c_str()),
log_pipe_location_tag((LogPipe *) this->super->super.owner));
return false;
}

Expand All @@ -110,6 +114,8 @@ DestinationWorker::deinit()
bool
DestinationWorker::connect()
{
DestinationDriver *owner = this->get_owner();

this->prepare_batch();

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

if (!this->channel->WaitForConnected(connect_timeout))
return false;
{
msg_error("Time out connecting to Loki",
evt_tag_str("url", owner->get_url().c_str()),
log_pipe_location_tag((LogPipe *) this->super->super.owner));
return false;
}

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

0 comments on commit e9833cf

Please sign in to comment.