title: How to query cloudwatch logs using boto3 in python
body: <p>I have a lambda function that writes metrics to Cloudwatch. While, it writes metrics, It generates some logs in a log-group.</p>
  <pre><code>INFO:: username: simran+test@example.com ClinicID: 7667 nodename: MacBook-Pro-2.local
  
  INFO:: username: simran+test2@example.com ClinicID: 7667 nodename: MacBook-Pro-2.local
  
  INFO:: username: simran+test@example.com ClinicID: 7668 nodename: MacBook-Pro-2.local
  
  INFO:: username: simran+test3@example.com ClinicID: 7667 nodename: MacBook-Pro-2.local
  </code></pre>
  <p>I would like to query AWS logs in past <code>x</code> hours where x could be anywhere between 12 to 24 hours, based on any of the params.</p>
  <p>For ex:</p>
  <ol>
  <li>Query Cloudwatch logs in last 5 hours where <code>ClinicID=7667</code></li>
  </ol>
  <p>or</p>
  <ol start="2">
  <li>Query Cloudwatch logs in last 5 hours where <code>ClinicID=7667</code> and <code>username='simran+test@example.com'</code></li>
  </ol>
  <p>or</p>
  <ol start="3">
  <li>Query Cloudwatch logs in last 5 hours where <code>username='simran+test@example.com'</code></li>
  </ol>
  <p>I am using <code>boto3</code> in Python.</p>