Comment on page
Before to get started with the plugin configuration, make sure to obtain the proper credentials to get access to the service. We strongly recommend to use a common JSON credentials file, reference link:
Your goal is to obtain a credentials JSON file that will be used later by Fluent Bit Stackdriver output plugin.
If you are using a Google Cloud Credentials File, the following configuration is enough to get started:
Example configuration file for k8s resource type:
local_resource_id is used by stackdriver output plugin to set the labels field for different k8s resource types. Stackdriver plugin will try to find the local_resource_id field in the log entry. If there is no field logging.googleapis.com/local_resource_id in the log, the plugin will then construct it by using the tag value of the log.
The local_resource_id should be in format:
This implies that if there is no local_resource_id in the log entry then the tag of logs should match this format. Note that we have an option tag_prefix so it is not mandatory to use k8s_container(node/pod) as the prefix for tag.
Currently, there are four ways which fluent-bit uses to assign fields into the resource/labels section.
- 1.Resource Labels API
- 2.Monitored Resource API
- 3.Local Resource Id
- 4.Credentials / Config Parameters
resource_labelsis correctly configured, then fluent-bit will attempt to populate all resource/labels using the entries specified. Otherwise, fluent-bit will attempt to use the monitored resource API. Similarly, if the monitored resource API cannot be used, then fluent-bit will attempt to populate resource/labels using configuration parameters and/or credentials specific to the resource type. As mentioned in the Configuration File section, fluent-bit will attempt to use or construct a local resource ID for a K8s resource type which does not use the resource labels or monitored resource API.
Note that the
project_idresource label will always be set from the service credentials or fetched from the metadata server and cannot be overridden.
resource_labelsconfiguration parameter offers an alternative API for assigning the resource labels. To use, input a list of comma separated strings specifying resource labels plaintext assignments (
new=value), mappings from an original field in the log entry to a destination field (
destination=$original) and/or environment variable assignments (
For instance, consider the following log entry:
Combined with the following Stackdriver configuration:
This will produce the following log:
This makes the
resource_labelsAPI the recommended choice for supporting new or existing resource types that have all resource labels known before runtime or available on the payload during runtime.
For instance, for a K8s resource type,
resource_labelscan be used in tandem with the Kubernetes filter to pack all six resource labels. Below is an example of what this could look like for a
resource_labelsalso supports validation for required labels based on the input resource type. This allows fluent-bit to check if all specified labels are present for a given configuration before runtime. If validation is not currently supported for a resource type that you would like to use this API with, we encourage you to open a pull request for it. Adding validation for a new resource type is simple - all that is needed is to specify the resources associated with the type alongside the required labels here.
An upstream connection error means Fluent Bit was not able to reach Google services, the error looks like this:
[2019/01/07 23:24:09] [error] [oauth2] could not get an upstream connection
This belongs to a network issue by the environment where Fluent Bit is running, make sure that from the Host, Container or Pod you can reach the following Google end-points:
The error looks like this:
[2020/08/04 14:43:03] [error] [output:stackdriver:stackdriver.0] fail to process local_resource_id from log entry for k8s_container
Do following check:
- If the log entry does not contain the local_resource_id field, does the tag of the log match for format?
- If tag_prefix is configured, does the prefix of tag specified in the input plugin match the tag_prefix?Other implementations
Last modified 2mo ago