Home » Cloud » Getting more value from your Stackdriver logs with structured data

Getting more value from your Stackdriver logs with structured data

By Mary Koes, Product Manager, and Bryan Moyles, Software Engineer

Logs contain some of the most valuable data available to developers, DevOps practitioners, Site Reliability Engineers (SREs) and security teams, particularly when troubleshooting an incident. It’s not always easy to extract and use, though. One common challenge is that many log entries are blobs of unstructured text, making it difficult to extract the relevant information when you need it. But structured log data is much more powerful, and enables you to extract the most valuable data from your logs. Google Stackdriver Logging just made it easier than ever to send and analyze structured log data.

We’ve just announced new features so you can better use structured log data. You’ve told us that you’d like to be able to customize which fields you see when searching through your logs. You can now add custom fields in the Logs Viewer in Stackdriver. It’s also now easier to generate structured log data using the Stackdriver Logging agent.

Why is structured logging better?

Using structured log data has some key benefits, including making it easier to quickly parse and understand your log data. The chart below shows the differences between unstructured and structured log data. 

You can see here how much more detail is available at a glance:

Unstructured log data
Structured log data
Example from custom logs
textPayload: A97A7743 purchased 4 widgets.
jsonPayload: {
 “customerIDHash”: “A97A7743”
 “action”: “purchased”
 “quantity”: “4”
 “item”: “widgets”
Example from Nginx logs—now available as structured data through the Stackdriver logging agent
textPayload: – [28/Feb/2018:12:00:00 +0900] “GET / HTTP/1.1″ 200 777 “-” “Chrome/66.0″
1362020400 (28/Feb/2018:12:00:00 +0900)

jsonPayload: {
 “remote” : “”,
 “host”   : “”,
 “user”   : “-“,
 “method” : “GET”,
 “path”   : “/”,
 “code”   : “200”,
 “size”   : “777”,
 “referer”: “-“,
 “agent”  : “Chrome/66.0″

Making structured logs work for you
You can send both structured and unstructured log data to Stackdriver Logging. Most logs Google Cloud Platform (GCP) services generate on your behalf, such as Cloud Audit Logging, Google App Engine logs or VPC Flow Logs, are sent to Stackdriver automatically as structured log data.
Since Stackdriver Logging also passes the structured log data through export sinks, sending structured logs makes it easier to work with the log data downstream if you’re processing it with services like BigQuery and Cloud Pub/Sub.
Using structured log data also makes it easier to alert on log data or create dashboards from your logs, particularly when creating a label or extracting a value with a distribution metric, both of which apply to a single field. (See our previous post on techniques for extracting values from Stackdriver logs for more information.)
Try Stackdriver Logging for yourself
To start using Stackdriver structured logging today, you’ll just need to install (or reinstall) the Stackdriver logging agent with the –structured flag. This also enables automatic parsing of common log formats, such as syslog, Nginx and Apache.
curl -sSO "https://dl.google.com/cloudagents/install-logging-agent.sh"
sudo bash ./install-logging-agent.sh --structured

For more information on installation and options, check out the Stackdriver structured logging installation documentation.

To test Stackdriver Logging and see the power of structured logs for yourself, you can try one of our most asked-for Qwiklab courses, Creating and alerting on logs-based metrics, for free, using a special offer of 15 credits. This offer is good through the end of May 2018. Or try our new structured logging features out on your existing GCP project by checking out our documentation.

Feed Source: Google Cloud Platform Blog
Article Source: Getting more value from your Stackdriver logs with structured data

About Admin

Powered by WP Robot