Stay organized with collectionsSave and categorize content based on your preferences.
This page describes how to enable and view logs for fleets. With fleet logging, multiple logs are aggregated and scoped together, enabling you to analyze the health of your applications in one consolidated view. This page is intended for:
Platform administrators who want to enable fleet logging and view logs in all namespaces.
Service operators who want to view logs in the specific namespaces to which they have access.
Overview
Fleet logs let you view logs at the entire fleet level, or for specific team scopes. Scopes are a team-management feature that let you define
subsets of fleet logs and other resources on a per-team basis, with each scope associated with
one or more fleet member clusters. For more information on scopes, seeManage teams for your fleet.
You can view two types of fleet logs:
Default logs: All Kubernetes logs (exceptAudit logs) that don't belong to any specific fleet scope with the followingresource types:
k8s_container
k8s_pod
k8s_node
k8s_cluster
k8s_control_plane_components
Fleet scope logs: Container and Pod logs for applications owned by a team deployed in a specificfleet scopewith multiple fleet-level namespaces.
Viewing fleet scope logs is optional. If you don't want to set up team management, you can still use fleet logging to view default logs.
Logs can be routed to differentlog bucketsin thefleet host projectwith different views for access control. The default retention period of a log bucket is 30 days. You canconfigure this periodif needed.
There are two modes supported for log routing where fleets contain clusters from multiple projects (cross-project registration):
MOVE: All logs are moved to the fleet host project. If a cluster in the fleet belongs to a different project, their logs arenotretained in the original Google Cloud project.
COPY: All logs are sent to the fleet host project. If a cluster in the fleet belongs to a different project, their logs are also retained in the original Google Cloud project.
If you don't have it installed already, install the Google Cloud CLI following theinstallation instructions. You need version 424.0.0 or higher to view your fleet logs.
Ensure that your fleet host project has all the required APIs enabled, including the Anthos API:
If you want to view fleet scope logs, you will need to create a fleet scope and a fleet
namespace, in addition to preparing workloads for log collection.
Before you continue, set the default project for the Google Cloud CLI by running the following command:
gcloud config set projectFLEET_HOST_PROJECT_ID
Create scopes and namespaces
If you want to view logs at the scope level, and haven't already set up scopes, follow the instructions inManage teams for your fleetto create scopes, add clusters to scopes, and set up fleet namespaces.
Prepare workloads
To view log data from your applications, you will need to deploy your workloads in a cluster to the fleet namespace configured in the preceding step. This step is applicable whether you choose to view default logs, fleet scope logs, or both. Here is an example to configure your workload:
After deploying the resource, you may see an error if the fleet namespace failed to create for some reason. In this case, run the following command to create the namespace again, and rerun the workload deployment command:
kubectl create namespaceNAMESPACE_NAME
Enable fleet logging
This section describes how to enable the fleet logging feature and grant team access to view logs.
gcloud
You can enable fleet logging using the Google Cloud CLI by specifying the configuration fields for the feature in a JSON or YAML file. Here is a example of a configuration for fleet logging in JSON format:
To view all the fields you can configure for this feature, see theAPI reference.
When thedefaultConfigorfleetScopeLogsConfigfields are enabled with theCOPYorMOVEmodes, as shown in the preceding example, a log sink is created with the prefixfleet-o11y-. This log sink is created under the Google Cloud project to route target logs from the cluster project to the fleet host project.
WhenfleetScopeLogsConfigis enabled, a log bucket with namefleet-o11y-scope-$SCOPE_NAMEis also created in theglobalregionunder the fleet host project, if it doesn't exist already. Note that you can't change the bucket's region.
In this example, default logs will be sent to the fleet host project and retained in the original Google Cloud project, while fleet scope logs will be sent to the fleet host project, and not retained in the Google Cloud project.
Add your chosen configuration to a JSON file, and update the fleet:
The fleet observability feature is enabled by default. If this is your first time using Terraform to manage the fleet observability feature, import the feature into Terraform by running the following command:
When thedefault_configorfleet_scope_logs_configfields are enabled with theCOPYorMOVEmodes, as shown in the preceding example, a log sink is created with the prefixfleet-o11y-. This log sink is created under the Google Cloud project to route target logs from the cluster project to the fleet host project.
Whenfleet_scope_logs_configis enabled, a log bucket with namefleet-o11y-scope-$SCOPE_NAMEis also created under the fleet host project, if it doesn't exist already.
In this example, default logs will be sent to the fleet host project and retained in the original Google Cloud project, while fleet scope logs will be sent to the fleet host project, and not retained in the Google Cloud project.
Any changes made to thefleetobservabilityspec might take a few minutes to apply.
Set up cross-project logging permissions
This section is only required if you are registering a cluster to a fleet in a different project (also known ascross-project registration). In order to route logs from cluster projects to the fleet host project, you must grant the roleroles/logging.bucketWriterto the logging service account from each cluster project.
To obtain the service account credentials from sinks in cluster projects, run the following command:
If the command returns an error that the log sink cannot be found, try re-running the command after a minute or two. You can view the service account in thewriterIdentityfield of the sink description as shown in the following example:
Platform administrators have access to view all logs in all namespaces.
Default logs
To view all default logs in the_Defaultbucket in your fleet host project, fill in the variables in the following URL, copy and paste it to your browser:
Service operators can view logs in the namespaces to which they have access. To view logs for all namespaces in a specific fleet scope, complete the following steps:
With yourfleet host projectselected, go to theTeamssection in the Google Cloud console.
Any changes made to thefleetobservabilityspec might take a few minutes to apply.
After disabling fleet logging, log sinks and exclusion filters will be removed from your projects. However, all log buckets created for the scope, and log views created under the log bucket will be preserved. To delete the log bucket in your fleet host project, seeDelete a bucket.
Update retention period for log buckets
The default retention period of a log bucket is 30 days. To update this period, run the following command:
RETENTION_DAYSis the number of days of the new retention period. For more options on configuring log buckets, seeManage buckets.
If you extend a bucket's retention period, then the retention rules apply going forward and not retroactively. Logs can't be recovered after the applicable retention period ends.
API reference
This section provides information on the possible fields you can add to yourfleetobservabilityobject.
fleetobservability
fleetobservabilitydefines the fleet observability configuration.
Field
Description
Schema
Optional
loggingConfig
Specified if the fleet logging feature is
enabled for the entire fleet.
If unspecified, the fleet logging feature is
disabled for the entire fleet.
routingConfigdefines the configuration of the log routing mode in the fleet logging feature.
Field
Description
Schema
Optional
mode
Specified to enable logs routing, and unspecified or MODE_UNSPECIFIED to disable logs routing.
If set to COPY, logs will be copied to the destination project.
If set to MOVE, logs will be moved to the destination project.
String; One of: MOVE, COPY and MODE_UNSPECIFIED
True
Naming restrictions
When fleet observability is enabled, the fleet observability controller reserves the following names for the logs objects it creates. To avoid unwanted or unexpected behavior, you should avoid using these names when you create your ownlog buckets,sinks, andset exclusion filters.
Feature enabled
Object created
Name used by fleet observability
defaultConfig
Sink
fleet-o11y-FLEET_PROJECT_NUMBER-default
Exclusion filter.
fleet-o11y-FLEET_PROJECT_NUMBER-default-exclusion. This name is reserved under the_Defaultsink of the cluster project.
fleetScopeLogsConfig
Log bucket
fleet-o11y-scope-SCOPE_NAME
Logs view for container logs in the bucket
fleet-o11y-scope-SCOPE_NAME-k8s_container
Logs view for Pod logs in the bucket
fleet-o11y-scope-SCOPE_NAME-k8s_pod
Sink
fleet-o11y-FLEET_PROJECT_NUMBER-scope-SCOPE_NAME
Exclusion filter
fleet-o11y-FLEET_PROJECT_NUMBER-scope-exclusion
Troubleshooting
This section describes how to resolve fleet logging related issues.
Email notification about sink configuration error
If you received an email with the title[ACTION REQUIRED] Cloud Logging sink configuration error in <Your GCP Project>, then the service account of your log sink does not have permission to write logs to the destination of the sink. To resolve this, follow the steps inCross-project logging permissions.
Unknown error message from Cloud Logging UI
If you see the following error in the Cloud Logging UI, double-check that theproject_idandscopevariables entered in the URL are correct.
Error: There is an unknown error while executing this operation.
Membership not found error
You might see the following error:
ERROR: (gcloud.alpha.container.fleet.memberships.bindings.create) NOT_FOUND: Resource 'parent resource not found for projects/...' was not found
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,[]]