{"id":3578,"date":"2022-11-17T03:24:41","date_gmt":"2022-11-17T03:24:41","guid":{"rendered":"https:\/\/www.checkmateq.com\/blog\/?p=3578"},"modified":"2023-08-04T10:31:52","modified_gmt":"2023-08-04T10:31:52","slug":"logging-in-google-cloud-platform","status":"publish","type":"post","link":"https:\/\/www.checkmateq.com\/blog\/logging-in-google-cloud-platform","title":{"rendered":"How to Setup Logging in Google Cloud Platform?"},"content":{"rendered":"<h1>Logging in Google Cloud Platform<\/h1>\n<p>Logging provides us information like what is the execution flow, what event is happening at what time and all the information of errors warnings if something goes, logs help us to debug the problem step by step, usually in common practice we will try to write logs related to that program flow or execution into a file or some other database so which would help us in trouble shooting , in the same way <a href=\"https:\/\/www.checkmateq.com\/google-cloud\">Google Cloud<\/a>\u00a0 Platform provides<strong> Logging<\/strong> as a managed service and it is part of Google Cloud <strong>Operations Suite<\/strong>.<\/p>\n<h2><strong>Cloud Logging in GCP<\/strong><\/h2>\n<p>It provides the log information related to any service available in the google cloud platform it&#8217;s not constrained to a particular group of services, so you can keep an eye on everything that&#8217;s happening in your organization GCP account and GCP also provides you with APIs to manage logs programmatically, so basically it just lets us to <strong>View<\/strong>,<strong> Query<\/strong> and <strong>Download<\/strong> the logs.<\/p>\n<p>Below is an example log provided for your understanding.<\/p>\n<pre>{\r\nhttpRequest: {1}\r\ninsertId: \"6375e32e0002d2cd0d2df081\"\r\nlabels: {1}\r\nlogName: \"projects\/rock-partition-363003\/logs\/<strong>appengine.googleapis<\/strong>.com%2Frequest_log\"\r\noperation: {4}\r\nprotoPayload: {28}\r\nreceiveTimestamp: \"2022-11-17T07:30:54.185767503Z\"\r\nresource: {2}\r\nseverity: \"INFO\"\r\nspanId: \"8272484813176817280\"\r\n<strong>timestamp: \"2022-11-17T07:30:53.051635Z\"<\/strong>\r\ntrace: \"projects\/rock-partition-363003\/traces\/a8909f84c4f1f49a014d3a804cf4b117\"\r\ntraceSampled: true\r\n}\r\n<\/pre>\n<p>The basic\u00a0 information inside this a log entry are <strong>Time Stamp<\/strong>\u00a0 gives details of event occurrence time and date like when the event is happened related to any particular service and\u00a0<strong>Resource<\/strong>\u00a0 from where that\u00a0 particular\u00a0 log information is generated for example let&#8217;s say if you are trying to access\u00a0 big query so that related\u00a0 information should have big query\u00a0 as a resource\u00a0 and detail information will be provided in\u00a0 <strong>Payload<\/strong>\u00a0 , payload is been removed from the above given log as a payload will have many line<\/p>\n<p>In <a href=\"https:\/\/www.checkmateq.com\/cloud\">Cloud<\/a> Logging logs are available in Json format, for a single log entry in order to analyze this Json file you need to manually go through the whole Json syntax, Noo, that&#8217;s a terrific task right, to help you with this GCP also allows you to export these logs to some other google cloud services like Big Query, Google Cloud Storage for further processing or analysis.<\/p>\n<h2>Types of audit logs in Cloud Computing<\/h2>\n<p>Now let&#8217;s see what the different type of audit logs are we have<\/p>\n<p><strong>Admin activity:<\/strong>\u00a0 \u00a0Operations like creating, modifying or deleting a resource comes under this admin related activity, so all these related activities are captured under admin activity logs. You can also look into AWS cloudtails to find out action related every API.<\/p>\n<p><strong>Data access<\/strong>:\u00a0 \u00a0Logs generated from the activities made for accessing data are captured under Data access logs, logs are generated even when data is not accessed and captured.<\/p>\n<p><strong>System event:<\/strong> system event means for example let&#8217;s say, you have scheduled something to happen in a specified time like a life cycle for objects stored in Cloud Storage, whenever the life cycle rules applied on the objects, logs will be generated, and these logs will be captured as <strong>System event logs. <\/strong>Such as Linux operating system logs would be available at \/var\/log\/messages about every system activity.<\/p>\n<p>&nbsp;<\/p>\n<p>Now let&#8217;s explore how this logging interface looks like, on your GCP web console go to logging under operations,<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3583 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions-300x169.jpg\" alt=\"\" width=\"813\" height=\"458\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions-300x169.jpg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions-1024x576.jpg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions-768x432.jpg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions-1536x864.jpg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions-1200x675.jpg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions.jpg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>You will be landing on<strong> Logs explorer<\/strong> page, here you can View and Query logs, and also apply various filters and severities, just expand a log to analyze it, you can also simply share the log link to your team member to discuss on it (he\/she can only see the log if the GCP account they are using has the required IAM privileges)<\/p>\n<p>IAM role required for viewing a log is log.viewer .<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3584 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-300x169.jpg\" alt=\"\" width=\"802\" height=\"452\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-300x169.jpg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-1024x576.jpg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-768x432.jpg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-1536x864.jpg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-1200x675.jpg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services.jpg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3593 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-1-300x153.jpeg\" alt=\"\" width=\"823\" height=\"420\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-1-300x153.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-1-1024x522.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-1-768x391.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-1-1536x782.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-1-1200x611.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-1.jpeg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Now let&#8217;s apply some filters from the console itself and understand the auto generated queries, select a resource and the severity of the event to filter the logs. I am just selecting info logs of service <a href=\"https:\/\/www.checkmateq.com\/google-cloud\">Google App Engine<\/a> as I do not have any errors or warnings from it.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3586 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-1-300x153.jpeg\" alt=\"\" width=\"745\" height=\"380\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-1-300x153.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-1-1024x524.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-1-768x393.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-1-1536x786.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-1-1200x614.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-1.jpeg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3587 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Devops-Support-300x152.jpeg\" alt=\"\" width=\"769\" height=\"390\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Devops-Support-300x152.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Devops-Support-1024x520.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Devops-Support-768x390.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Devops-Support-1536x780.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Devops-Support-1200x609.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Devops-Support.jpeg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>below is the auto generated query from the applied filters.<\/p>\n<pre>severity=INFO\r\nresource.type=\"gae_app\"\r\n<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-3588 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-Checkmate-cloud-engineer-300x152.jpeg\" alt=\"\" width=\"807\" height=\"409\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-Checkmate-cloud-engineer-300x152.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-Checkmate-cloud-engineer-1024x518.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-Checkmate-cloud-engineer-768x388.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-Checkmate-cloud-engineer-1536x777.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-Checkmate-cloud-engineer-1200x607.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-Checkmate-cloud-engineer.jpeg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>as mentioned, you can also save this query for future use by just clicking on the save button on the top right corner and you can also set the specific time frame to get the logs as shown below.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3589 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-migration-services-300x151.jpeg\" alt=\"\" width=\"731\" height=\"368\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-migration-services-300x151.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-migration-services-1024x515.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-migration-services-768x386.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-migration-services-1536x773.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-migration-services-1200x604.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-migration-services.jpeg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>Setting the time frame, you can set the time frame from the histogram tab or by ,<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3590 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-outsourcing-company-300x145.jpeg\" alt=\"\" width=\"833\" height=\"402\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-outsourcing-company-300x145.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-outsourcing-company-1024x496.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-outsourcing-company-768x372.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-outsourcing-company-1536x744.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-outsourcing-company-2048x992.jpeg 2048w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-outsourcing-company-1200x581.jpeg 1200w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>This blog is written by Amit Kumar, Head of engineering at <a href=\"https:\/\/www.checkmateq.com\">Checkmate Global Technologies<\/a>. You can lease reach to him to hire Google Cloud Engineer and learn about <a href=\"https:\/\/www.checkmateq.com\/google-cloud\">Cloud Monitoring<\/a> best practices.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Logging in Google Cloud Platform Logging provides us information like what is the execution flow, what event is happening at what time and all the information of errors warnings if something goes, logs help us to debug the problem step by step, usually in common practice we will try to write logs related to that &hellip; <a href=\"https:\/\/www.checkmateq.com\/blog\/logging-in-google-cloud-platform\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Setup Logging in Google Cloud Platform?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":3598,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[3,93,79,2,71,70,69,68,59,11,78,63,23,16,24,80,8],"_links":{"self":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/3578"}],"collection":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/comments?post=3578"}],"version-history":[{"count":18,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/3578\/revisions"}],"predecessor-version":[{"id":4210,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/3578\/revisions\/4210"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media\/3598"}],"wp:attachment":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media?parent=3578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/categories?post=3578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/tags?post=3578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}