Internal HTTP(S) logging and monitoring

This document provides you with the information you need to understand Stackdriver logging and monitoring metrics for Internal HTTP(S) Load Balancing.

Logging

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, so you might need to enable logging for more than one backend service, depending on your configuration.

Enabling logging on an existing backend service

gcloud

gcloud beta compute backend-services update l7-ilb-backend-service \
    --enable-logging \
    --logging-sample-rate=1.0 \
    --region=us-west1

where

  • --enable-logging enables logging for that backend service.
  • --logging-sample-rate lets you specify a value from 0.0 through 1.0, where 0.0 means no packets are logged and 1.0 means 100% of packets are logged. Only meaningful with the --enable-logging parameter. Enabling logging but setting the sampling rate to 0.0 is equivalent to disabling logging.

After you enable logging on the backend service, each HTTP(S) request is logged via Stackdriver Logging.

How to view logs

To view logs, go to the Logs Viewer.

Internal HTTP(S) load balancer logs are indexed first by network and then by region.

  • To see logs for all internal HTTP(S) load balancers, in the first pull-down menu select Internal HTTP/S Load Balancing Rule.
  • To see logs for only one network, select Internal HTTP/S Load Balancing Rule, and then select the name of a network.
  • To see logs for just one region of the network, select Internal HTTP/S Load Balancing Rule > network > region.

Log fields of type boolean typically only appear if they have a value of true. If a boolean field has a value of false, that field is omitted from the log.

UTF-8 encoding is enforced for log fields. Characters that are not UTF-8 characters are replaced with question marks.

You can configure export of Stackdriver logs based metrics for resource logs (resource.type="internal_http_lb_rule). The metrics created are based on the "Internal HTTP/S Load Balancing Rule (Logs-based Metrics)" resource, which is available under Stackdriver Monitoring dashboards:

Go to Monitoring

What is logged

Internal HTTP(S) Load Balancing log entries contain information useful for monitoring and debugging your HTTP(S) traffic. Log entries contain the following types of information:

  • General information shown in most GCP logs, such as severity, project ID, project number, timestamp, and so on.
  • HttpRequest log fields.

Log fields

Stackdriver logs present in the form of a LogEntry proto.

Field Type Description
logName string The resource name of the log to which this log entry belongs.
In the form "projects/[PROJECT_ID]/logs/requests".
timestamp Timestamp format The time when the request began.
severity LogSeverity format The severity of the log entry. Defaults to LogSeverity.DEFAULT.
httpRequest HttpRequest object An HttpRequest proto which describes the HTTP(S) request being logged.
trace string The resource name of the trace associated with the log entry, if any. If it contains a relative resource name, the name is assumed to be relative to https://tracing.googleapis.com. Example: projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824.
spanId string The span ID within the trace associated with the log entry. For Trace spans, this is the same format that the Trace API v2 uses: a 16-character hexadecimal encoding of an 8-byte array, such as 000000000000004a.
resource MonitoredResource object The monitored resource associated with this log entry. See MonitoredResource object.

MonitoredResource

Field Type Description
networkName string The name of the load balancer's VPC network.
region string The name of the load balancer's Google Cloud region.
urlMapName string The name of the URL map object configured to select a backend service.
forwardingRuleName string The name of the forwarding rule object.
targetProxyName string The name of the target proxy object referenced by the forwarding rule.
matchedUrlPathRule string The URL map path rule or route rule configured as part of the URL map key. Can be UNMATCHED or UNKNOWN as fallbacks.
  • UNMATCHED refers to a request that matches no URL path rules, and so uses the default path rule.
  • UNKNOWN indicates an internal error.
backendTargetName string The name of the backend selected to handle the request, based on the URL map path rule or route rule that matches the request.
backendTargetType string The type of the backend target (BACKEND_SERVICE / UNKNOWN).
backendName string The name of the backend instance group or NEG.
backendType string The type of the backend, either instance group or NEG.
backendScope string The scope of the backend (either zone name or region name). Might be UNKNOWN whenever backendName is unknown.
backendScopeType string The scope of the backend (REGION/ZONE). Might be "UNKNOWN" whenever backendName is unknown.

Monitoring

Internal HTTP(S) Load Balancing exports monitoring data to Stackdriver.

Monitoring metrics can be used for the following purposes:

  • Evaluating a load balancer's configuration, usage, and performance
  • Troubleshooting problems
  • Improving resource utilization and user experience

In addition to the predefined dashboards in Stackdriver, you can create custom dashboards, set up alerts, and query the metrics through the Stackdriver monitoring API.

Viewing Stackdriver monitoring dashboards

  1. Go to Monitoring in the Google Cloud Platform Console.
    Go to Monitoring
  2. Select Resources > Google Cloud Load Balancers.
  3. Click the name of your load balancer.

In the left pane, you can see various details for this load balancer. In the right pane you can see timeseries graphs. Click the Breakdowns link to see specific breakdowns.

Defining Stackdriver alerts

You can define Stackdriver alerts over various Internal HTTP(S)Load Balancing metrics:

  1. Go to Monitoring in the Google Cloud Platform Console.
    Go to Monitoring
  2. Select Alerting > Create a Policy.
  3. Click on Add Condition and select condition type.
  4. Select metrics and filters. For metrics, the resource type is Internal HTTP/S Load Balancer.
  5. Click Save Condition.
  6. Enter policy name and click Save Policy.

Defining Stackdriver custom dashboards

You can create custom Stackdriver dashboards over HTTP(S) Load Balancing metrics:

  1. Go to Monitoring in the Google Cloud Platform Console.
    Go to Monitoring
  2. Select Dashboards > Create Dashboard.
  3. Click on Add Chart.
  4. Give the chart a title.
  5. Select metrics and filters. For metrics, the resource type is Internal HTTP/S Load Balancer.
  6. Click Save.

Metric reporting frequency and retention

Metrics for the load balancers are exported to Stackdriver in 1-minute granularity batches. Monitoring data is retained for six (6) weeks. The dashboard provides data analysis in default intervals of 1H (one hour), 6H (six hours), 1D (one day), 1W (one week), and 6W (six weeks). You can manually request analysis in any interval from 6W to 1 minute.

Monitoring metrics for internal HTTP(S) load balancers

The following metrics for internal HTTP(S) load balancers are reported into Stackdriver:

The following metrics are reported into Stackdriver:

Metric Description
Request count The number of requests served by the internal HTTP(S) load balancer
Request bytes count The number of bytes sent as requests from clients to the internal HTTP(S) load balancer
Response bytes count The number of bytes sent as responses from the internal HTTP(S) load balancer to the client
Total latencies A distribution of the latency measured from the time the first byte of the request is received by the proxy to the time when the last byte of the response is sent by the proxy. Typically reduced to 95th percentile in Stackdriver views.
Backend latencies A distribution of the latency measured from when the first byte of the request is sent by to the backend by the proxy to when the last byte of the response is received by the proxy from the backend. Typically reduced to 95th percentile in Stackdriver views.

Filtering dimensions for internal HTTP(S) load balancer metrics

Metrics are aggregated for each internal HTTP(S) load balancer. You can filter aggregated metrics by the following dimensions.

Property Description
BACKEND_SCOPE The Google Cloud Platform zone or region of the backend group that served the client request, or special string for cases in which backend group wasn't assigned. Examples: us-central1-a, europe-west1-b, asia-east1, UNKNOWN.
PROXY_REGION Region of the internal HTTP(S) load balancer, client, and backend. Examples: us-central1, europe-west1 or asia-east1
BACKEND The name of the backend instance group or NEG that served the client request
BACKEND_TARGET The name of the backend service that served the client request
MATCHED_URL_RULE The URL map path rule or route rule that matched the prefix of the client HTTP(S) request (up to 50 characters)

The Response code class fraction metric is supported for the entire load balancer. No further granularity is supported.

What's next

¿Te sirvió esta página? Envíanos tu opinión:

Enviar comentarios sobre…