{"id":3626,"date":"2022-11-22T11:25:09","date_gmt":"2022-11-22T11:25:09","guid":{"rendered":"https:\/\/www.checkmateq.com\/blog\/?p=3626"},"modified":"2023-08-04T10:18:53","modified_gmt":"2023-08-04T10:18:53","slug":"export-logs-to-bigquery","status":"publish","type":"post","link":"https:\/\/www.checkmateq.com\/blog\/export-logs-to-bigquery","title":{"rendered":"How to Export logs to Big Query (GCP)"},"content":{"rendered":"<h3><strong>Creating a Data Set in\u00a0<\/strong>Big Query<\/h3>\n<p>Big Query is designed to make large-scale data analysis accessible to everyone, if you are a developer or <a href=\"https:\/\/www.checkmateq.com\/python-development\">data analyst<\/a> you are probably working with data, if your startups has small amount of data, you might be able to store it in spreadsheet, but as your amount of data grows to gigabytes, terabytes or even petabytes, you will need to have a more efficient system like a data warehouse where you can not only store data but also analyze it.<\/p>\n<p>Traditionally larger sets of data mean longer times between asking your question and getting answers, have you ever needed to wait hours or days for an analytics report to be run?\u00a0 <strong>Big Query<\/strong> is designed to run massive amounts of data, such as log data from thousands of retail systems or IOT data from millions of vehicle sensors across the globe, it&#8217;s a fully managed and serverless data warehouse which allows you to focus on analytics instead of managing infrastructure, in big query data is stored in a structured table, which means that you can use standard SQL for easy querying and data analysis.<\/p>\n<p>On your console go to Big Query and enable the API if you are using it for the first time and follow below steps\u00a0 to create a data set.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-3607\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions--300x153.jpeg\" alt=\"Google Cloud\" width=\"831\" height=\"424\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions--300x153.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions--1024x523.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions--768x392.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions--1536x784.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions--1200x613.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-solutions-.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>Give a unique name to your dataset and select a location in which you want to store your table,<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-3608\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-engineering-services-300x152.jpeg\" alt=\"Google Cloud\" width=\"819\" height=\"415\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-engineering-services-300x152.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-engineering-services-1024x520.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-engineering-services-768x390.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-engineering-services-1536x780.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-engineering-services-1200x609.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-engineering-services.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>you can also set an expiration for the data set just by enabling Table expiration and providing it number of days in which you want the table to be expired.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3609 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-2-300x152.jpeg\" alt=\"\" width=\"851\" height=\"431\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-2-300x152.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-2-1024x520.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-2-768x390.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-2-1536x780.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-2-1200x609.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-DevOps-support-2.jpeg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>As we have the data set ready let&#8217;s create a sink to export logs to this data set in big query<\/p>\n<h3>Create Logs Routing Sink<\/h3>\n<p>To create a logs routing sink to export logs to your big query data set, go to Log Route from your logging dashboard to and follow below given process to create a sink.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3610 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-300x152.jpeg\" alt=\"\" width=\"791\" height=\"401\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-300x152.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-1024x519.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-768x389.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-1536x778.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services-1200x608.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-google-cloud-services.jpeg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3611 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-2-300x152.jpeg\" alt=\"\" width=\"772\" height=\"391\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-2-300x152.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-2-1024x520.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-2-768x390.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-2-1536x780.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-2-1200x609.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-support-2.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>Start with giving a name to your sink and click on next to do the further configuration like selecting the destination and applying the filters to selectively export logs,<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3612 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Infrastructure-management-solutions-300x152.jpeg\" alt=\"\" width=\"787\" height=\"399\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Infrastructure-management-solutions-300x152.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Infrastructure-management-solutions-1024x520.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Infrastructure-management-solutions-768x390.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Infrastructure-management-solutions-1536x780.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Infrastructure-management-solutions-1200x609.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-Infrastructure-management-solutions.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>Now select the destination between Cloud Storage, Pub\/Sub, Big Query and the also select the name of the data set to which you want to store logs to.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3613 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-computing-services-300x153.jpeg\" alt=\"\" width=\"790\" height=\"403\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-computing-services-300x153.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-computing-services-1024x524.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-computing-services-768x393.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-computing-services-1536x786.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-computing-services-1200x614.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-computing-services.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>Sometimes we only need logs of a specific service and sometimes we don&#8217;t need logs of a specific service to be exported for this Log route also allows you to apply filters, if you do not apply any filters all the generated logs will be exported, and it may consume more space which leads to growth in unwanted infrastructure cost.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3614 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-offshore-it-service-1-300x153.jpeg\" alt=\"\" width=\"767\" height=\"391\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-offshore-it-service-1-300x153.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-offshore-it-service-1-1024x522.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-offshore-it-service-1-768x391.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-offshore-it-service-1-1536x782.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-offshore-it-service-1-1200x611.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-offshore-it-service-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>below given code filters logs by only selecting logs of Google App Engine and with severity <strong>INFO<\/strong>, to learn GCP logging and to know how this code snippet is generated refer our blog on <a href=\"https:\/\/www.checkmateq.com\/blog\/logging-in-google-cloud-platform\/\">Cloud Logging<\/a> and then create the sink.<\/p>\n<pre>severity=INFO\r\nresource.type=\"gae_app\"\r\n<\/pre>\n<div><img loading=\"lazy\" class=\"aligncenter wp-image-3615\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-infrastructure-service-300x153.jpeg\" alt=\"Big Query\" width=\"784\" height=\"400\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-infrastructure-service-300x153.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-infrastructure-service-1024x521.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-infrastructure-service-768x391.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-infrastructure-service-1536x782.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-infrastructure-service-1200x611.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Checkmate-cloud-infrastructure-service.jpeg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/div>\n<p>&nbsp;<\/p>\n<p>Once the sink is created the final step you have to do is give necessary IAM permissions required for writing to selected resource, go to your Logs Router dashboard and follow the steps as given below.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3619 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-DevOps-Engineer-300x153.jpeg\" alt=\"\" width=\"744\" height=\"379\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-DevOps-Engineer-300x153.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-DevOps-Engineer-1024x521.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-DevOps-Engineer-768x391.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-DevOps-Engineer-1536x782.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-DevOps-Engineer-1200x611.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Hire-DevOps-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>then copy the service account details and go to IAM dashboard to check whether required permissions are given to the service account linked with your sink, if not please grant those permissions.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-3620 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-1076-300x153.jpeg\" alt=\"\" width=\"779\" height=\"397\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-1076-300x153.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-1076.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>This blog is written by Amit Kumar, Head of Engineering, <a href=\"https:\/\/www.checkmateq.com\">Checkmate Global Technologies<\/a>. Connect with him to understand startup&#8217;s MVP development best practices.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a Data Set in\u00a0Big Query Big Query is designed to make large-scale data analysis accessible to everyone, if you are a developer or data analyst you are probably working with data, if your startups has small amount of data, you might be able to store it in spreadsheet, but as your amount of data &hellip; <a href=\"https:\/\/www.checkmateq.com\/blog\/export-logs-to-bigquery\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Export logs to Big Query (GCP)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":3628,"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\/3626"}],"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=3626"}],"version-history":[{"count":11,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/3626\/revisions"}],"predecessor-version":[{"id":4207,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/3626\/revisions\/4207"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media\/3628"}],"wp:attachment":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media?parent=3626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/categories?post=3626"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/tags?post=3626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}