Skip to content

PutLogEvents not showing in console #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jimmyt857 opened this issue Jul 19, 2016 · 9 comments
Closed

PutLogEvents not showing in console #240

jimmyt857 opened this issue Jul 19, 2016 · 9 comments

Comments

@jimmyt857
Copy link

I am calling PutLogEvents, and the log shows a successful request with status 200. However, the log events are not showing up in my aws console. I am making the call as follows:

Aws::Vector<Aws::CloudWatchLogs::Model::InputLogEvent> logEvents;
std::string message = "something";
auto logEvent = Aws::CloudWatchLogs::Model::InputLogEvent()
.WithMessage(message.c_str())
.WithTimestamp(time(nullptr));
logEvents.push_back(logEvent);

Aws::CloudWatchLogs::CloudWatchLogsClient cwlClient(localCredentials, clientConfig);
auto request = Aws::CloudWatchLogs::Model::PutLogEventsRequest()
.WithLogGroupName(logGroupName.c_str())
.WithLogStreamName(logStreamName.c_str())
.WithLogEvents(logEvents);
if (sequenceToken != "")
      request.SetSequenceToken(sequenceToken);

auto outcome = cwlClient.PutLogEvents(request);
logEvents.clear();
@JonathanHenson
Copy link
Contributor

.WithTimestamp(time(nullptr));

you could just use DateTime::Now()

Could you show me your log output?

@jimmyt857
Copy link
Author

If I use DateTime::Now(), I get no known conversion for argument 1 from ‘Aws::Utils::DateTime’ to ‘long long int’, so I'm using DateTime::CurrentTimeMillis() instead.

Turns out the problem was me, the CloudWatchLogs console filter was set after the logs and I wasn't seeing them because of that. I switched to the async version of PutLogEvents and now I am getting a segfault with the following stack trace:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffee7bd700 (LWP 18853)]
0x00007ffff5b6f4a3 in std::basic_string<char, std::char_traits, std::allocator >::basic_string(std::string const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0 0x00007ffff5b6f4a3 in std::basic_string<char, std::char_traits, std::allocator >::basic_string(std::string const&) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x0000000001b23787 in Aws::Http::Standard::StandardHttpRequest::StandardHttpRequest(Aws::Http::URI const&, Aws::Http::HttpMethod) ()
#2 0x0000000001b22949 in Aws::Http::DefaultHttpClientFactory::CreateHttpRequest(Aws::Http::URI const&, Aws::Http::HttpMethod, std::function<std::iostream* ()> const&) const ()
#3 0x00000000019b77fa in Aws::CloudWatchLogs::CloudWatchLogsClient::PutLogEventsAsyncHelper(Aws::CloudWatchLogs::Model::PutLogEventsRequest const&, std::function<void (Aws::CloudWatchLogs::CloudWatchLogsClient const*, Aws::CloudWatchLogs::Model::PutLogEventsRequest const&, Aws::Utils::Outcome<Aws::CloudWatchLogs::Model::PutLogEventsResult, Aws::Client::AWSErrorAws::CloudWatchLogs::CloudWatchLogsErrors > const&, std::shared_ptr<Aws::Client::AsyncCallerContext const> const&)> const&, std::shared_ptr<Aws::Client::AsyncCallerContext const> const&) const ()
#4 0x00007ffff5b65a60 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff724f182 in start_thread (arg=0x7fffee7bd700) at pthread_create.c:312
#6 0x00007ffff52cd47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

@JonathanHenson
Copy link
Contributor

It looks like segfaults are a common theme for you. Any chance you could send me your code so I can have a look at how everything is configured?

@jimmyt857
Copy link
Author

I decided to write a minimal example, and it actually works. Running that same minimal example from my project fails, however, so it is certainly a problem with my setup. My minimal example is passing only constant values to the PutLogEvents request, so this feels like some sort of memory issue to me. However, valgrind reports tons of errors (such as the one below) even in my working example so it is hard to separate what is different. Is there a way to run this library in a valgrind-clean way?

==30342== Conditional jump or move depends on uninitialised value(s)
==30342== at 0x4CD46E: Aws::External::Json::Reader::getNextChar() (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x4CD54F: Aws::External::Json::Reader::readString() (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x4CFEAE: Aws::External::Json::Reader::readToken(Aws::External::Json::Reader::Token&) (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x4D8C62: Aws::External::Json::Reader::readObject(Aws::External::Json::Reader::Token&) (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x4D91FA: Aws::External::Json::Reader::readValue() (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x4D992C: Aws::External::Json::Reader::parse(char const_, char const_, Aws::External::Json::Value&, bool) (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x4D9C29: Aws::External::Json::Reader::parse(std::istream&, Aws::External::Json::Value&, bool) (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x4B2E20: Aws::Utils::Json::JsonValue::JsonValue(std::istream&) (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x4A34FF: Aws::Client::AWSJsonClient::MakeRequest(std::string const&, Aws::AmazonWebServiceRequest const&, Aws::Http::HttpMethod) const (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x46AF10: Aws::CloudWatchLogs::CloudWatchLogsClient::PutLogEvents(Aws::CloudWatchLogs::Model::PutLogEventsRequest const&) const (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x467C5E: Aws::CloudWatchLogs::CloudWatchLogsClient::PutLogEventsAsyncHelper(Aws::CloudWatchLogs::Model::PutLogEventsRequest const&, std::function<void (Aws::CloudWatchLogs::CloudWatchLogsClient const*, Aws::CloudWatchLogs::Model::PutLogEventsRequest const&, Aws::Utils::Outcome<Aws::CloudWatchLogs::Model::PutLogEventsResult, Aws::Client::AWSErrorAws::CloudWatchLogs::CloudWatchLogsErrors > const&, std::shared_ptr<Aws::Client::AsyncCallerContext const> const&)> const&, std::shared_ptr<Aws::Client::AsyncCallerContext const> const&) const (in /home/ubuntu/colossi-servers/cpp/test/Test.exe)
==30342== by 0x572834F: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22)
==30342== Uninitialised value was created by a stack allocation
==30342== at 0x4EBAE77: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)

@jimmyt857
Copy link
Author

I finally figured it out. There is no bug, I was just writing my async functions incorrectly.

In my code I have helper functions for all of my aws calls, The helper function creates its own client object and then uses that to perform the request. For the async calls, the client object goes out of scope because it is a local variable, so bad things happen when the callback is invoked.

Before I close this issue, I have a quick question: what is the recommended way of managing clients? I.e. should I use a separate client for each request or have a global client object for each service?

@jimmyt857
Copy link
Author

To clarify, I often call the same request multiple times simultaneously, so my real question is whether a single client can handle this or must I instead create separate clients for each request.

@JonathanHenson
Copy link
Contributor

One client per service and configuration.

The client is passed to your callbacks.

Sent from my iPhone

On Oct 14, 2016, at 9:44 PM, jimmyt857 [email protected] wrote:

I finally figured it out. There is no bug, I was just writing my async functions incorrectly.

In my code I have helper functions for all of my aws calls, The helper function creates its own client object and then uses that to perform the request. For the async calls, the client object goes out of scope because it is a local variable, so bad things happen when the callback is invoked.

Before I close this issue, I have a quick question: what is the recommended way of managing clients? I.e. should I use a separate client for each request or have a global client object for each service?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@JonathanHenson
Copy link
Contributor

Always only one client.

Sent from my iPhone

On Oct 14, 2016, at 10:04 PM, jimmyt857 [email protected] wrote:

To clarify, I often call the same request multiple times simultaneously, so my real question is whether a single client can handle this or must I instead create separate clients for each request.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@jimmyt857
Copy link
Author

Awesome, thanks!

cobookman pushed a commit to cobookman/aws-sdk-cpp that referenced this issue Jan 17, 2022
* Custom keychain support for macOS TLS (aws#204)
* Update submodules and pull in keychain path override API PR

Co-authored-by: Eero Kurimo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants