Anthos Service Mesh
Introduction
Anthos Service Mesh (Cloud Service Mesh) is Google's managed Istio distribution. It provides mTLS, traffic management and telemetry for services on GKE and Google Distributed Cloud. This O11ySource collects service-to-service traffic, istiod control-plane health, workload certificate and sidecar injection signals, and ingress gateway certificate validity.
Getting Started
Compatibility
The Anthos Service Mesh O11ySource is validated on GKE with Cloud Service Mesh / ASM 1.22.8 and an in-cluster istiod control plane. It is expected to work for the same mesh on Google Distributed Cloud (Anthos on-prem) clusters that send telemetry to Cloud Monitoring; the on-prem commands are not yet validated.
Data Collection Method
The mesh writes istio.io/service request, error and latency metrics to Cloud Monitoring. vuSmartMaps pulls them from the Cloud Monitoring API, so no inbound connection to the mesh cluster is needed. Optionally, Managed Service for Prometheus can also scrape the istiod and sidecar metrics in the mesh cluster and store them in Cloud Monitoring, from where vuSmartMaps reads them too; Google bills this as Managed Prometheus ingestion. When Gateway Endpoints are set, vuSmartMaps also connects to the ingress gateways to read the expiry dates of their TLS certificates.
Prerequisites
Dependent Configuration
To configure this O11ySource, create a 'credential' of type 'gcp_service_account_json' under the 'Definition' tab.
Inputs for Configuring Data Source
- Mesh Cluster Name: Value of the cluster_name label on the mesh's istio.io/service metrics (normally the Kubernetes cluster name). Identifies the source.
- GCP Project ID: Google Cloud project that receives the mesh telemetry.
- GCP Service Account JSON: Service account key (JSON) with roles/monitoring.viewer. Add it under the Definition tab as a credential of type GCP Service Account JSON, then select it here.
- Polling Frequency: Interval in seconds between Cloud Monitoring queries.
- Gateway Endpoints: Optional comma-separated host:port list of ingress gateway TLS endpoints whose certificate expiry is tracked. The certificate chain is not verified.
- Gateway TLS Server Name: Optional SNI host name to send when probing the gateway endpoints.
Firewall Requirement
To collect data from this O11ySource, ensure the following ports are opened:
| Source IP | Destination IP | Destination Port | Protocol | Direction |
|---|---|---|---|---|
| vuSmartMaps node egress IPs | monitoring.googleapis.com (required) | 443 | TCP (HTTPS) | Outbound |
| vuSmartMaps node egress IPs | oauth2.googleapis.com (required) | 443 | TCP (HTTPS) | Outbound |
| vuSmartMaps node egress IPs | Ingress gateway addresses listed in Gateway Endpoints (optional, only for the certificate expiry check) | Port listed in Gateway Endpoints (usually 443) | TCP (TLS) | Outbound |
| Mesh cluster nodes | monitoring.googleapis.com, oauth2.googleapis.com (the mesh's own telemetry path, normally already open) | 443 | TCP (HTTPS) | Outbound |
Required: the first two rows, from the vuSmartMaps nodes. Optional: the gateway row, only when Gateway Endpoints are set. Already in place: the mesh cluster row, which the mesh needs to send its telemetry to Cloud Monitoring. The vuSmartMaps agent connects to Google APIs directly; the source has no proxy setting and a proxy through environment variables is not validated. Either allow the vuSmartMaps nodes to reach these host names on the internet (Google serves them from changing IP addresses, listed at https://www.gstatic.com/ipranges/goog.json), or resolve *.googleapis.com to private.googleapis.com (199.36.153.8/30) over Cloud Interconnect or VPN with Private Google Access.
*Before providing the firewall requirements, please update the port based on the customer environment.
Configuring the Target
- Service account for vuSmartMaps vuSmartMaps reads mesh metrics from Cloud Monitoring with a Google Cloud service account key. Run the commands in Cloud Shell or on a host with the gcloud CLI. Log in first with gcloud auth login as a user who can enable APIs, create service accounts and keys and grant project roles. If the organization policy iam.disableServiceAccountKeyCreation is enforced, the GCP administrator must allow key creation for this account.
- Set PROJECT_ID to the project that receives the mesh metrics in Cloud Monitoring, then create the service account, grant it roles/monitoring.viewer and download its key. The pause gives IAM time to see the new account.
PROJECT_ID=my-gcp-project
SA=vsmaps-asm@$PROJECT_ID.iam.gserviceaccount.com
gcloud services enable monitoring.googleapis.com --project=$PROJECT_ID
gcloud iam service-accounts create vsmaps-asm --project=$PROJECT_ID
sleep 30
gcloud projects add-iam-policy-binding $PROJECT_ID --member="serviceAccount:$SA" \
--role=roles/monitoring.viewer --condition=None --format=none
gcloud iam service-accounts keys create vsmaps-asm-key.json --iam-account=$SA --project=$PROJECT_ID
- In vuSmartMaps, add
vsmaps-asm-key.jsonas a credential of type GCP Service Account JSON under the Definition tab. Treat the key as a secret: after uploading it, delete every other copy (including in Cloud Shell) and rotate it per your organization's key policy (new key, update the credential, delete the old key).
- Mesh metrics in Cloud Monitoring The dashboards and alerts use the istio.io/service metrics that the mesh's stackdriver metrics provider writes to Cloud Monitoring (asmcli installs it with --option stackdriver). Check every mesh cluster.
- Point kubectl at the mesh cluster and check the context it prints. On Google Distributed Cloud (Anthos on-prem) use the user cluster kubeconfig, never the admin cluster's.
export KUBECONFIG=/path/to/user-cluster-kubeconfig
kubectl config current-context
- List the Telemetry resources and the mesh default metrics providers. stackdriver must be a metrics provider, either in defaultProviders or in a mesh-wide Telemetry resource in istio-system. If it is not, apply the Telemetry resource from section 3 without its prometheus line (unless section 3 is used), plus any providers already listed, or ask the mesh owner to enable Cloud Monitoring telemetry.
kubectl get telemetry -A
kubectl -n istio-system get configmap -o yaml | grep -A6 defaultProviders
- Run this with gcloud logged in as in section 1. It prints one cluster_name per mesh cluster that sent request metrics in the last 15 minutes; each value is a Mesh Cluster Name for a source. No output means no requests passed through the mesh in that time, or the stackdriver provider is not active; an error with code 403 means the logged-in user cannot read Cloud Monitoring in the project.
PROJECT_ID=my-gcp-project
curl -s -G -H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://monitoring.googleapis.com/v3/projects/$PROJECT_ID/timeSeries" \
--data-urlencode 'filter=metric.type="istio.io/service/server/request_count" AND resource.type="k8s_container"' \
--data-urlencode "interval.startTime=$(date -u -d '-15 min' +%FT%TZ)" \
--data-urlencode "interval.endTime=$(date -u +%FT%TZ)" --data-urlencode view=HEADERS \
| grep -o '"cluster_name": "[^"]*"' | sort -u
- istiod and sidecar Prometheus metrics (optional) The source also collects istiod control-plane metrics (pilot_, citadel_), workload certificate expiry and sidecar injection counts through Google Cloud Managed Service for Prometheus. The shipped dashboards and alerts do not use them yet; they are stored in the ASM table for ad hoc queries. Skip this section unless they are needed: it changes the mesh telemetry configuration and adds Managed Prometheus ingestion, which Google bills. Use the same kubeconfig as section 2.
- Add the prometheus metrics provider next to stackdriver. If no mesh-wide Telemetry resource exists in istio-system, save this as
asm-telemetry.yamland apply it with kubectl apply -f asm-telemetry.yaml, after adding any other provider that defaultProviders lists. If one exists, add prometheus to its providers instead. A namespace-level Telemetry resource overrides the mesh-wide one for its namespace and needs the same change. Meshes older than Istio 1.22 use apiVersion telemetry.istio.io/v1alpha1.
apiVersion: telemetry.istio.io/v1
kind: Telemetry
metadata:
name: mesh-default
namespace: istio-system
spec:
metrics:
- providers:
- name: prometheus
- name: stackdriver
- Enable Managed Service for Prometheus for applications. On Google Distributed Cloud (Anthos on-prem), patch the stackdriver resource of the user cluster:
kubectl -n kube-system patch stackdriver stackdriver --type merge \
-p '\{"spec":\{"enableGMPForApplications":true\}\}'
- On GKE, run this instead, with the cluster name and its region or zone:
gcloud container clusters update CLUSTER_NAME --location=LOCATION --enable-managed-prometheus
- Check that the Managed Prometheus collectors run and its resources are installed:
kubectl -n gmp-system get pods
kubectl get crd clusterpodmonitorings.monitoring.googleapis.com podmonitorings.monitoring.googleapis.com
- Save the scrape configuration as
asm-podmonitoring.yamland apply it with kubectl apply -f asm-podmonitoring.yaml. It scrapes every sidecar (port 15020) and istiod (port 15014) and keeps only the listed metrics, including the _bucket, _sum and count series of histograms. Keep each regex on a single line. citadel* metrics exist only when istiod is the mesh certificate authority.
apiVersion: monitoring.googleapis.com/v1
kind: ClusterPodMonitoring
metadata:
... (38 lines in total, use the copy icon to copy all of them)
Configuration Steps
Enablethe Anthos Service Mesh O11ySource.- Select the Sources tab and press the
+button to add a mesh cluster. Add one source per cluster. - Provide the following values:
- *Mesh Cluster Name: a cluster_name printed by the check in section 2 of Configuring the Target.
- *GCP Project ID: the PROJECT_ID used in Configuring the Target.
- *GCP Service Account JSON: the credential added in section 1 of Configuring the Target.
- *Polling Frequency: seconds between Cloud Monitoring queries, 60 to 300 (default 60).
- *Gateway Endpoints (optional): comma-separated host:port list of ingress gateway TLS endpoints whose certificate expiry is tracked, for example 10.0.0.10:443,10.0.1.10:443. The certificate chain is not verified.
- *Gateway TLS Server Name (optional): the host name the gateways expect in the TLS handshake (SNI) when they serve a different certificate per host name.
- Click
Finish. Cloud Monitoring publishes mesh metrics about 5 minutes after they are recorded, so the Anthos Service Mesh dashboards fill in after 5 to 10 minutes. - If the dashboards stay empty, check the agent logs on the vuSmartMaps cluster with kubectl -n vsmaps logs deploy/telegraf-anthos-service-mesh-1-1-1-1 (the numeric suffix can differ). PermissionDenied usually points to roles/monitoring.viewer missing on the project, or not yet in effect; no errors and no data usually means the Mesh Cluster Name or project does not match the check in section 2.
Metrics Collected
| Name | Description | Data Type |
|---|---|---|
| api_name | API name label from mesh telemetry | String |
| api_version | API version label from mesh telemetry | String |
| asm_signal_domain | ASM signal domain: data_plane, control_plane or security | LowCardinality(String) |
| cluster_name | Kubernetes cluster that emitted the time series | LowCardinality(String) |
| collection_mode | Collection mode (remote = pulled from Cloud Monitoring) | LowCardinality(String) |
| container_name | Container that emitted the time series | String |
| destination_canonical_revision | Canonical revision of the destination service | String |
| destination_canonical_service_name | Canonical name of the destination service | String |
| destination_canonical_service_namespace | Namespace of the destination canonical service | String |
| destination_owner | Owner reference of the destination workload | String |
| destination_port | Destination port | UInt64 |
| destination_principal | SPIFFE identity of the destination workload | String |
| destination_service_name | Destination service name | String |
| destination_service_namespace | Destination service namespace | String |
| destination_workload_name | Destination workload name | String |
| destination_workload_namespace | Destination workload namespace | String |
| gcp_project | Google Cloud project configured for the source | String |
| location | Google Cloud region of the monitored resource | LowCardinality(String) |
| lt | Upper bound of the latency histogram bucket (le) for bucketed rows | Float64 |
| mesh_uid | Mesh identifier | String |
| name | Cloud Monitoring metric family the row belongs to | String |
| namespace_name | Kubernetes namespace of the emitting pod | LowCardinality(String) |
| o11ysource | O11ySource that collected the row | LowCardinality(String) |
| pod_name | Pod that emitted the time series | String |
| project_id | Google Cloud project that owns the monitored resource | String |
| proxy_version | Envoy proxy version | String |
| request_operation | Request operation label | LowCardinality(String) |
| request_protocol | Request protocol (http, grpc, tcp) | LowCardinality(String) |
| resource_type | Cloud Monitoring monitored-resource type | LowCardinality(String) |
| response_code | HTTP response status code | LowCardinality(String) |
| response_latencies_bucket | Response latencies distribution: histogram bucket count | Float64 |
| service_authentication_policy | Authentication policy applied (MUTUAL_TLS or NONE) | LowCardinality(String) |
| source_canonical_revision | Canonical revision of the source service | String |
| source_canonical_service_name | Canonical name of the source service | String |
| source_canonical_service_namespace | Namespace of the source canonical service | String |
| source_owner | Owner reference of the source workload | String |
| source_principal | SPIFFE identity of the source workload | String |
| source_workload_name | Source workload name | String |
| source_workload_namespace | Source workload namespace | String |
| timestamp | Time of the data point (UTC) | DateTime64(3) |
| request_bytes_bucket | Request bytes distribution: histogram bucket count | Float64 |
| request_bytes_mean | Request bytes distribution: mean value | Float64 |
| request_bytes_sum_of_squared_deviation | Request bytes distribution: sum of squared deviation | Float64 |
| response_latencies_sum_of_squared_deviation | Response latencies distribution: sum of squared deviation | Float64 |
| response_bytes_mean | Response bytes distribution: mean value | Float64 |
| response_latencies_mean | Response latencies distribution: mean value | Float64 |
| response_bytes_bucket | Response bytes distribution: histogram bucket count | Float64 |
| type | Sub-type label of the series (the upstream endpoint type; for certificate rows leaf, intermediate or root) | String |
| age | Seconds since the certificate was issued | UInt64 |
| enddate | Certificate expiry time (epoch seconds) | UInt64 |
| expiry | Seconds until the certificate expires | UInt64 |
| issuer_common_name | Certificate issuer common name | String |
| issuer_serial_number | Certificate issuer serial number | String |
| cert_target | Endpoint whose certificate was probed | LowCardinality(String) |
| ocsp_stapled | Whether an OCSP response was stapled | LowCardinality(String) |
| organization | Certificate subject organization | String |
| public_key_algorithm | Certificate public key algorithm | LowCardinality(String) |
| san | Certificate subject alternative names | String |
| serial_number | Certificate serial number | String |
| startdate | Certificate validity start (epoch seconds) | UInt64 |
| signature_algorithm | Certificate signature algorithm | LowCardinality(String) |
| verification | Certificate chain verification result | LowCardinality(String) |
| verification_code | Certificate verification result code | UInt64 |
| verification_error | Certificate verification error, if any | String |
| metric_family | ASM metric family classification | LowCardinality(String) |
