Answers: <p>There are several ways for exporting logs from CloudWatch in searchable text format:</p>
  <p>The easiest way of downloading logs in text format is to go to a log group -&gt; Select a log stream -&gt; go to <strong>Actions</strong> and select <strong>Download search results as CSV</strong>:</p>
  <p><a href="https://i.sstatic.net/1G7f4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/1G7f4.png" alt="enter image description here" /></a></p>
  <p>This will download the logs in a <code>.csv</code> format which may or may not be what we want, nevertheless I think it is good for searching a analysis.</p>
  <p>A more involved way to export logs would be to select a log group and from the <strong>Actions</strong> and for that log group select <strong>Export Data to S3</strong>:</p>
  <p><a href="https://i.sstatic.net/o9XbJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/o9XbJ.png" alt="enter image description here" /></a></p>
  <p>This may export every stream from the log group to an S3 bucket, from which we can download the logs in text format. In order to be able to write to an S3 bucket, we need a policy. There is a full documentation on the AWS <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/S3ExportTasks.html" rel="nofollow noreferrer">docs</a> about how to do this.</p>
  <p>I need to mention the CloudWatch provides a way to analyze logs without being able to export them by using CloudWatch Logs Insights. CloudWatch Logs Insights has its own <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html" rel="nofollow noreferrer">query language</a>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-04-21T13:05:52.713Z
Answers: 2021-04-21T13:05:52.713Z
Answers: Ervin Szilagyi
Body: <p>A lambda that I have deployed has gone wrong. Therefore, I want to look on logs and find out whats wrong about it. Hence I look upon cloudwatch logs for any error message.</p>
  <p>But the cloudwatch environment allows no easy way to search for a string in logs. Therefore I need to download a portion of it in text format so I can <code>grep</code> string in it. Do you know how I can do that?</p>
  
Tags: <amazon-web-services><aws-lambda><amazon-cloudwatch>
Title: How I can retrieve aws lambda cloudwatch logs in txt format so I can search on them?
UserDisplayName: Dimitrios Desyllas
ThreadText: # How I can retrieve aws lambda cloudwatch logs in txt format so I can search on them?
  
  (Asked by: username_0 on 2020-12-15)
  
  A lambda that I have deployed has gone wrong. Therefore, I want to look on logs and find out whats wrong about it. Hence I look upon cloudwatch logs for any error message.
  
  But the cloudwatch environment allows no easy way to search for a string in logs. Therefore I need to download a portion of it in text format so I can `grep` string in it. Do you know how I can do that?
  
  **Tags:** amazon-web-services, aws-lambda, amazon-cloudwatch
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-04-21. Score: 1
  
  There are several ways for exporting logs from CloudWatch in searchable text format:
  
  The easiest way of downloading logs in text format is to go to a log group -> Select a log stream -> go to **Actions** and select **Download search results as CSV**:
  
  [![enter image description here](https://i.sstatic.net/1G7f4.png)](https://i.sstatic.net/1G7f4.png)
  
  This will download the logs in a `.csv` format which may or may not be what we want, nevertheless I think it is good for searching a analysis.
  
  A more involved way to export logs would be to select a log group and from the **Actions** and for that log group select **Export Data to S3**:
  
  [![enter image description here](https://i.sstatic.net/o9XbJ.png)](https://i.sstatic.net/o9XbJ.png)
  
  This may export every stream from the log group to an S3 bucket, from which we can download the logs in text format. In order to be able to write to an S3 bucket, we need a policy. There is a full documentation on the AWS [docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/S3ExportTasks.html) about how to do this.
  
  I need to mention the CloudWatch provides a way to analyze logs without being able to export them by using CloudWatch Logs Insights. CloudWatch Logs Insights has its own [query language](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html).
  
  
  ---
  
  