{"id":9886,"date":"2024-03-20T06:06:36","date_gmt":"2024-03-20T06:06:36","guid":{"rendered":"https:\/\/www.bacancytechnology.com\/qanda\/?p=9886"},"modified":"2024-03-20T06:06:36","modified_gmt":"2024-03-20T06:06:36","slug":"boto3-for-cloudwatch-logs-in-python","status":"publish","type":"post","link":"https:\/\/www.bacancytechnology.com\/qanda\/cloud\/boto3-for-cloudwatch-logs-in-python","title":{"rendered":"How to Query Cloudwatch Logs Using Boto3 in Python"},"content":{"rendered":"<p>I used awslogs. if you install it, you can do. &#8211;watch will tail the new logs.<br \/>\n<code>awslogs get \/aws\/lambda\/log-group-1 --start=\"5h ago\" --watch<\/code><\/p>\n<p>You can install it using<br \/>\n<code>pip install awslogs<\/code><\/p>\n<p>to filter you can do:<br \/>\n<code>awslogs get \/aws\/lambda\/log-group-1 --filter-pattern '\"ClinicID=7667\"' --start \"5h ago\" --timestamp<\/code><\/p>\n<p>It supports multiple filter patterns as well.<br \/>\n<code>awslogs get \/aws\/lambda\/log-group-1 --filter-pattern '\"ClinicID=7667\"' --filter-pattern '\" username=simran+test@abc.com\"' --start \"5h ago\" --timestamp<\/code><\/p>\n<h3>References:<\/h3>\n<p><strong><a href=\"https:\/\/github.com\/jorgebastida\/awslogs\" target=\"_blank\" rel=\"noopener\">awslogs<\/a><\/strong><br \/>\n<strong><a href=\"https:\/\/pypi.org\/project\/awslogs\/\" target=\"_blank\" rel=\"noopener\">awslogs . PyPI<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I used awslogs. if you install it, you can do. &#8211;watch will tail the new logs. awslogs get \/aws\/lambda\/log-group-1 &#8211;start=&#8221;5h ago&#8221; &#8211;watch You can install it using pip install awslogs to filter you can do: awslogs get \/aws\/lambda\/log-group-1 &#8211;filter-pattern &#8216;&#8221;ClinicID=7667&#8243;&#8216; &#8211;start &#8220;5h ago&#8221; &#8211;timestamp It supports multiple filter patterns as well. awslogs get \/aws\/lambda\/log-group-1 &#8211;filter-pattern [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9877,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[17],"tags":[],"class_list":["post-9886","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/9886"}],"collection":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/comments?post=9886"}],"version-history":[{"count":2,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/9886\/revisions"}],"predecessor-version":[{"id":9888,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/9886\/revisions\/9888"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media\/9877"}],"wp:attachment":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media?parent=9886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/categories?post=9886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/tags?post=9886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}