0

I am trying to send the logs (being generated as a part of my on-premise device and the message being sent or received using devices onboarded on greengrass) to AWS.

How is it possible?

I wanted to check SDKs also but found no documentation stating how to do it online.

Software Engineer
  • 15,457
  • 7
  • 74
  • 102
MMA
  • 41
  • 5
  • 1
    Here is one way: [Collecting Metrics and Logs from Amazon EC2 Instances and On-Premises Servers with the CloudWatch Agent](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html). – srk Apr 07 '21 at 19:37
  • That probably assumes you are already writing to log files on local disk or similar. Is that true for you? Or do you not have any logging yet? – srk Apr 07 '21 at 20:07
  • @srk I am not writing to an log files. Azure offers Application Insights which can be used to publish console.log statements to the cloud directly using the Application Insights lib for the code language. Is it possible to do something like that with AWS ? With least additional memory being occupied as I will be using edge devices. – MMA Apr 08 '21 at 05:27
  • What language/framework are you using? – srk Apr 08 '21 at 12:43
  • @srk as of now I am not bound by any language. I can pick any language or framework – MMA Apr 08 '21 at 18:25
  • I am able to get connection logs for Aws IoT using cloudwatch . However, I want to print code level messages for debugging or messages being exchanges using Matt to cloudwatch. Is that possible ? – MMA Apr 08 '21 at 18:33

2 Answers2

2

You should use a logging framework or some other abstraction so your code is not tightly coupled to AWS CloudWatch. Then you can easily change the log destination (CloudWatch, file, database) without changing your code.

For example, let's say you're using .NET. Here is how you can configure popular .NET logging frameworks to send logs to CloudWatch. Or here is a solution for Python. I'm sure there are similar solutions in other languages/frameworks.

If you are already generating log files, another option is to use the CloudWatch Agent to send those existing logs to CloudWatch.

srk
  • 1,625
  • 1
  • 10
  • 26
  • This approach works for me. Are you aware if its available for python. – MMA Apr 09 '21 at 05:12
  • Added a link for Python to my answer. Have you done any research? Where are you stuck in your research? All of these links are from straightforward Google searches like "python send logs to cloudwatch"... – srk Apr 09 '21 at 12:59
  • I was trying to implement sending code logs to cloudwatch using IAM policies. So all my research was into that direction. – MMA Apr 11 '21 at 12:04
0

In order to send logs to Cloudwatch just use Cloudwatch agentю Install Cloudwatch agent

You can send logs to Elasticsearch using logstash as well.

Voronin Roman
  • 257
  • 1
  • 4