This document shows you how to configure and use Cloud Logging with HTTP(S) Load Balancing and Cloud CDN.
External HTTP(S) Load Balancing logging
You can enable, disable, and view logs for an HTTP(S) Load Balancing backend service. For HTTP(S) Load Balancing with backend buckets, logging is automatically enabled and cannot be disabled.
You enable or disable logging for each backend service. You can configure whether to log all requests or a randomly sampled fraction.
You must ensure that you don't have a logs exclusion that applies to external HTTP(S) load balancer. For instructions about how to verify that Cloud HTTP Load Balancer logs are allowed, see Viewing resource-type exclusions.
Note: If the backend service is created after the General Availability release of Logging for HTTP(S) Load Balancing, logging is disabled for a backend service. If you enabled logging during the alpha release or beta release, logging continues to be enabled for the backend service.
Enabling logging on a new backend service from console
- In the Google Cloud console, go to the Load Balancing page.
- Click the name of your load balancer.
- Click Edit.
- Click Backend Configuration.
- Select Create a backend service.
- Complete the required backend service fields.
- Click Enable logging.
- In the Sample rate field, set the sampling probability. You can set a number from 0.0 through 1.0, where 0.0 means that no requests are logged and 1.0 means that 100% of the requests are logged. The default value is 1.0.
- To finish editing the backend service, click Update.
- To finish editing the load balancer, click Update.
Enabling logging on an existing backend service from console
- In the Google Cloud console, go to the Load Balancing page.
- Click the name of your load balancer.
- Click Edit.
- Click Backend Configuration.
- Click Edit next to your backend service.
- Click Enable logging.
- In the Sample rate field, set the sampling probability. You can set a number from 0.0 through i, where 0.0 means that no requests are logged and 1.0 means that 100% of the requests are logged. The default value is 1.0.
- To finish editing the backend service, click Update.
- To finish editing the load balancer, click Update.
Disabling or modifying logging on an existing backend service from console
- In the Google Cloud console, go to the Load Balancing page.
- Click the name of your load balancer.
- Click Edit.
- Click Backend Configuration.
- Click Edit next to your backend service.
- Clear Enable logging to disable logging entirely.
- If you leave logging enabled, you can set a different sampling probability in the Sample rate field. You can set a number from 0.0 through 1.0, where 0.0 means that no requests are logged and 1.0 means that 100% of the requests are logged. The default value is 1.0.To reduce the number of stored logs to 20%, set the value to 0.2.
- To finish editing the backend service, click Update.
- To finish editing the load balancer, click Update.
Internal HTTP(S) Load Balancing logging
This document provides you with the information you need to understand logging and monitoring metrics for Internal HTTP(S) Load Balancing.
You can enable logging on a per-backend service basis. A single internal HTTP(S) load balancer's URL map can reference more than one backend service. You might need to enable logging for multiple backend services, depending on your configuration.
Enabling logging on an existing backend service from console
- In the Google Cloud console, go to the Load balancing page.
- Click the name of your load balancer.
- Click Edit.
- Click Backend Configuration.
- Click Edit next to your backend service.
- Click Advanced configurations (Session affinity, connection draining timeout).
- Click Enable logging.
- Set a Sample rate fraction. You can set it to anything from 0.0 through 1.0 (default).
- Click Update.
External TCP/UDP Network Load Balancing logging
This section shows you how to configure and use Cloud Logging for Network Load Balancing.
There are no additional charges for using logs. Based on how you ingest logs, standard pricing for Cloud Logging, BigQuery, or Pub/Sub apply. Enabling logs has no effect on the performance of the load balancer.
Enabling logging on a new backend service from gcloud
Create the backend service to enable logging with the gcloud beta compute backend-services create command.
gcloud beta compute backend-services create BACKEND_SERVICE \
--region=REGION \
--enable-logging \
--logging-sample-rate=SAMPLE_RATE
Replace the following:
BACKEND_SERVICE: the name of the backend service.
REGION: Region of the backend service to create.
SAMPLE_RATE: This field can only be specified if logging is enabled for this backend service. The value of the field must be from 0.0 to 1.0, where 0.0 means no logs are reported and 1.0 means all logged requests are reported. Enabling logging but setting the sampling rate to 0.0 is equivalent to disabling logging. The default value is 1.0.
Enabling logging on an existing backend service from gcloud
Enable logging on an existing backend service with the gcloud beta compute backend-services update command.
gcloud beta compute backend-services update BACKEND_SERVICE \
--region=REGION \
--enable-logging \
--logging-sample-rate=SAMPLE_RATE
Replace the following:
BACKEND_SERVICE: the name of the backend service.
REGION: Region of the backend service to create.
SAMPLE_RATE: This field can only be specified if logging is enabled for this backend service. The value of the field must be from 0.0 to 1.0, where 0.0 means no logs are reported and 1.0 means all logged requests are reported. Enabling logging but setting the sampling rate to 0.0 is equivalent to disabling logging. The default value is 1.0.
Disable logging on an existing backend service from gcloud
Disable logging on the backend service with the gcloud beta compute backend-services update command. Set the sample rate to 0.0 to disable logging.
gcloud beta compute backend-services update BACKEND_SERVICE \
--region=REGION \
--logging-sample-rate=0.0
Internal TCP/UDP Load Balancing logging
This section shows you how to configure and use Cloud Logging for Internal TCP/UDP Load Balancing.
There are no additional charges for using logs. Based on how you ingest logs, standard pricing for Cloud Logging, BigQuery, or Pub/Sub apply. Enabling logs has no effect on the performance of the load balancer.
Enabling logging on a new backend service from gcloud
Create a backend service and enable logging with the gcloud beta compute backend-services create command.
gcloud beta compute backend-services create BACKEND_SERVICE \
--region=REGION \
--enable-logging \
--logging-sample-rate=SAMPLE_RATE
Replace the following:
BACKEND_SERVICE: the name of the backend service.
REGION: Region of the backend service to create.
SAMPLE_RATE: This field can only be specified if logging is enabled for this backend service. The value of the field must be from 0.0 to 1.0, where 0.0 means no logs are reported and 1.0 means all logged requests are reported. Enabling logging but setting the sampling rate to 0.0 is equivalent to disabling logging. The default value is 1.0.
Enabling logging on an existing backend service from gcloud
Enable logging on an existing backend service with the gcloud beta compute backend-services update command.
gcloud beta compute backend-services update BACKEND_SERVICE \
--region=REGION \
--enable-logging \
--logging-sample-rate=SAMPLE_RATE
Replace the following:
BACKEND_SERVICE: the name of the backend service.
REGION: Region of the backend service to create.
SAMPLE_RATE: This field can only be specified if logging is enabled for this backend service. The value of the field must be from 0.0 to 1.0, where 0.0 means no logs are reported and 1.0 means all logged requests are reported. Enabling logging but setting the sampling rate to 0.0 is equivalent to disabling logging. The default value is 1.0.
Disable logging on an existing backend service from gcloud
Disable logging on the backend service with the gcloud beta compute backend-services update command.
gcloud beta compute backend-services update BACKEND_SERVICE \
--region=REGION \
--no-enable-logging
Replace the following:
BACKEND_SERVICE: the name of the backend service.
REGION: Region of the backend service to create.
Comments
0 comments
Please sign in to leave a comment.