Please have a look the documentation HTTP(S) Load Balancing Logging and Monitoring:
You can enable, disable, and view logs for an HTTP(S) Load Balancing
backend service.
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.
You enable or disable logging for each backend service. You can
configure whether to log all requests or a randomly sampled fraction.
To enable logging on a new backend service you can use Console UI or gcloud
command:
gcloud compute backend-services create BACKEND_SERVICE \
--global \
--enable-logging \
--logging-sample-rate=VALUE \
... other values
for an existing backend service:
gcloud compute backend-services update BACKEND_SERVICE \
--global \
--enable-logging \
--logging-sample-rate=VALUE
To enable monitoring you should follow the documentation:
You can configure export of logs-based metrics for external HTTP(S)
load balancer resource logs (resource.type=http_load_balancer
).
The metrics created are based on the "Google Cloud HTTP Load Balancing
Rule (Logs-based Metrics)" resource (l7_lb_rule
), which is available
under Cloud Monitoring dashboards instead of under the https_lb_rule resource
.
Furthermore, please have a look at the documentation Monitoring Network Load Balancing:
Network Load Balancing exports key metrics to Monitoring.
Monitoring metrics can be used for the following purposes:
- Evaluate a load balancer's configuration, usage, and performance
- Troubleshoot problems
- Improve resource utilization and user experience
You can create custom dashboards, set up alerts, and query metrics
through Monitoring.
More information and step by step instructions you can find at the documentation section Defining Monitoring alerts and Metrics.