How to Use Log Analytics in Cloud Logging to gain deeper network insights
Mary Colley
Product Manager
Charles Baer
Product Manager, Google Cloud
Network logs serve a critical purpose in Google Cloud by helping users troubleshoot, manage, and optimize their networks. Cloud Logging provides a logging pipeline to reliably ingest network logs like VPC Flow Logs at scale and tools to quickly find and analyze network logs. Since Log Analytics launched as Generally Available (GA) in January, network admins now have entirely new capabilities to search and aggregate network logs to easily gain insights into network trends, discover anomalies, and troubleshoot potential networking issues. Since the cost for Log Analytics is included in the Cloud Logging ingestion cost, you can now get more insight and value out of your network logs without the additional cost.
From logs to insightsÂ
VPC Flow Logs provide detailed information to help troubleshoot, monitor, and optimize your network. Log entries contain round trip time latency (TCP), packet count and byte count along with the metadata describing the source and destination. Any logging solution used to observe your network, perform forensics, monitor real-time security, and optimize networking expenses needs to be able to process logs at scale, centralize logs, and provide rich tools to analyze the log data. Cloud Logging helps in several important ways:
-
Aggregate logs with centralized log storage â Centralize logs with the Logs Router, which provides a secure, compliant, scalable, and reliable log routing platform.
Ad hoc log analysis â Analyze network performance using Log Analytics for ad-hoc, query-time log analysis over time as a part of network troubleshooting. In this case, metrics often donât work well due to the high cardinality values in network logs.
Aggregated network log insights â Gain insights into the top network traffic, top egress/ingress traffic with dashboards with data from Log Analytics to help best manage your network over time. Using aggregation, users can create top-level dashboards and then drill down via ad hoc reporting when necessary.
In this blog post, weâll cover a few examples of how to analyze your network logs with Log Analytics in Cloud Logging. If you havenât yet already, upgrade your log buckets to use Log Analytics.
Example 1: Analyze network egress by destination countryÂ
Understanding network egress by region can help to surface unexpected network traffic. VPC Flow logs capture the necessary traffic and metadata that can be used to track the egress bytes, packets and latency by region. This may be useful in identifying differences in tracking unexpected changes that may signal a traffic failure or a security event. With Log Analytics, you can easily aggregate data by country and use ad hoc queries to drill down to the underlying details to investigate further.
The following query tracks all external traffic by country served from virtual machines. Each VPC flow log includes a reporter
field which denotes whether the log is written by the source or destination. The dest_location
field provides the available geographic location of the log if it was external to the network.
See the query in our sample github repo.
To use the queries shown in this document on the Log Analytics page, replace the contents of the FROM clause with the name of the table that corresponds to the view that you want to query. The table name has the format project_ID.region.bucket_ID.view_ID. You can find the table name for a view on the Log Analytics page; the default query for a log view lists the table name in the FROM statement. For information about how to access the default query, see Query a log view.
Log Analytics has a built-in charting capability thatâs currently available in Preview (sign-up here). Running this query in a demo project, provides interesting insights into the source patterns for the traffic.
To better understand traffic egressing to a specific country, it might be interesting to also analyze the bytes and packets sent over the past week for one specific country code (âgbrâ). For example:
Example 2: Total external traffic by IPÂ
Understanding traffic by IP address enables you to analyze unexpected traffic and troubleshoot potential network issues. Log Analytics helps streamline this workflow by enabling aggregation of network traffic by high cardinality fields, such as IP addresses.Â
In the following query, we join two distinct queries to centralize the source and destination logs into a single results table. It contains not only internet traffic, but also traffic to Google services and other projects. Using the query, itâs easy to quickly identify the virtual machines with the most ingress and egress traffic.
See the query in our sample github repo.
Example 3: âTop Talkersâ VM instances sending the most trafficÂ
The top talkers network report can be useful because it allows you to identify the hosts on a network that are consuming the most bandwidth. This information can be used to optimize network performance, troubleshoot network problems, and identify security threats.
For example, if a particular host is consuming a large amount of bandwidth, you can investigate to see if the host is infected with malware or if it is being used for unauthorized activities. Another common use case is to prioritize network traffic and ensure that critical applications have the bandwidth they need.
The top talkers network report can also be used to identify trends in network usage. For example, if the amount of bandwidth consumed by a particular application is increasing, you can investigate to see if the application is being used more frequently or if it is consuming more bandwidth per user. This information can be used to plan for future network capacity needs.
See the query in our sample github repo.
Network log trends over timeÂ
By analyzing network logs over time, you can better identify trends and gain insights. Scheduling reports and sharing insights via email helps ensure your team is receiving insights when â and where â they need them.
The Cloud Logging product team is currently working on designing and building embedded charting and dashboarding options for Log Analytics (Preview sign-up here), which weâll cover in a future blog post. Analytical tools like Looker and Looker Studio provide excellent analytical capabilities, including charting and dashboarding. One of the key features of Log Analytics is that you can use log data in any of the tools available in the BigQuery ecosystem through the use of the linked dataset. You can visualize the same networking queries using Looker and Looker Studio dashboards.
Get started today
To get started with VPC Flow logs, enable VPC Flow Logs for a new or existing subnet. To get started with Log Analytics, you can upgrade your log buckets to use Log Analytics and check out our sample networking queries.Â
A special thank you to Przemek Sroka for his contributions to this blog post.