Creating custom tags in Google Cloud Logs
In Google Cloud Logging, it can be difficult to easily determine where your logs are coming from, but we have a solution that will make organizing your logs (by service, host, location, etc) incredibly simple!
If we leverage the ability to customize FluentD configurations for a given log source that is deployed, we can include custom fields, or "tags", to help sort through logs after they've been sent to Google Cloud Logging.
In the following example we will be using our MySQL log source:
- Read Customize FluentD Config to allow for customizations
- Scroll down to the
<match>
tag and, within that tag, find the<record>
tag. - Within the
<record>
tag, include a custom field, or fields, that resemble the ones in the image below. These custom fields will be included in thejsonPayload
of the log entries.
- Within Google Cloud Logging, using an advanced filter, filter for the logs related to the particular source technology that you've added custom fields to. An example is below:
- Next, click on Save Search at the top
- Ensure that the Custom Fields portion of the form includes the two custom fields that were created. This will include these in the summary lines, highlighted in a light-blue color.
- Congratulations! You've successfully created a saved filter that highlights specific logs from your environment based on custom fields that were added to the FluentD configuration used to collect those logs!
Updated almost 4 years ago