Skip to main content
Version: NG-2.16

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 IPDestination IPDestination PortProtocolDirection
vuSmartMaps node egress IPsmonitoring.googleapis.com (required)443TCP (HTTPS)Outbound
vuSmartMaps node egress IPsoauth2.googleapis.com (required)443TCP (HTTPS)Outbound
vuSmartMaps node egress IPsIngress 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 nodesmonitoring.googleapis.com, oauth2.googleapis.com (the mesh's own telemetry path, normally already open)443TCP (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​

  1. 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.json as 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).
  1. 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
  1. 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.yaml and 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.yaml and 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​

  • Enable the 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​

NameDescriptionData Type
api_nameAPI name label from mesh telemetryString
api_versionAPI version label from mesh telemetryString
asm_signal_domainASM signal domain: data_plane, control_plane or securityLowCardinality(String)
cluster_nameKubernetes cluster that emitted the time seriesLowCardinality(String)
collection_modeCollection mode (remote = pulled from Cloud Monitoring)LowCardinality(String)
container_nameContainer that emitted the time seriesString
destination_canonical_revisionCanonical revision of the destination serviceString
destination_canonical_service_nameCanonical name of the destination serviceString
destination_canonical_service_namespaceNamespace of the destination canonical serviceString
destination_ownerOwner reference of the destination workloadString
destination_portDestination portUInt64
destination_principalSPIFFE identity of the destination workloadString
destination_service_nameDestination service nameString
destination_service_namespaceDestination service namespaceString
destination_workload_nameDestination workload nameString
destination_workload_namespaceDestination workload namespaceString
gcp_projectGoogle Cloud project configured for the sourceString
locationGoogle Cloud region of the monitored resourceLowCardinality(String)
ltUpper bound of the latency histogram bucket (le) for bucketed rowsFloat64
mesh_uidMesh identifierString
nameCloud Monitoring metric family the row belongs toString
namespace_nameKubernetes namespace of the emitting podLowCardinality(String)
o11ysourceO11ySource that collected the rowLowCardinality(String)
pod_namePod that emitted the time seriesString
project_idGoogle Cloud project that owns the monitored resourceString
proxy_versionEnvoy proxy versionString
request_operationRequest operation labelLowCardinality(String)
request_protocolRequest protocol (http, grpc, tcp)LowCardinality(String)
resource_typeCloud Monitoring monitored-resource typeLowCardinality(String)
response_codeHTTP response status codeLowCardinality(String)
response_latencies_bucketResponse latencies distribution: histogram bucket countFloat64
service_authentication_policyAuthentication policy applied (MUTUAL_TLS or NONE)LowCardinality(String)
source_canonical_revisionCanonical revision of the source serviceString
source_canonical_service_nameCanonical name of the source serviceString
source_canonical_service_namespaceNamespace of the source canonical serviceString
source_ownerOwner reference of the source workloadString
source_principalSPIFFE identity of the source workloadString
source_workload_nameSource workload nameString
source_workload_namespaceSource workload namespaceString
timestampTime of the data point (UTC)DateTime64(3)
request_bytes_bucketRequest bytes distribution: histogram bucket countFloat64
request_bytes_meanRequest bytes distribution: mean valueFloat64
request_bytes_sum_of_squared_deviationRequest bytes distribution: sum of squared deviationFloat64
response_latencies_sum_of_squared_deviationResponse latencies distribution: sum of squared deviationFloat64
response_bytes_meanResponse bytes distribution: mean valueFloat64
response_latencies_meanResponse latencies distribution: mean valueFloat64
response_bytes_bucketResponse bytes distribution: histogram bucket countFloat64
typeSub-type label of the series (the upstream endpoint type; for certificate rows leaf, intermediate or root)String
ageSeconds since the certificate was issuedUInt64
enddateCertificate expiry time (epoch seconds)UInt64
expirySeconds until the certificate expiresUInt64
issuer_common_nameCertificate issuer common nameString
issuer_serial_numberCertificate issuer serial numberString
cert_targetEndpoint whose certificate was probedLowCardinality(String)
ocsp_stapledWhether an OCSP response was stapledLowCardinality(String)
organizationCertificate subject organizationString
public_key_algorithmCertificate public key algorithmLowCardinality(String)
sanCertificate subject alternative namesString
serial_numberCertificate serial numberString
startdateCertificate validity start (epoch seconds)UInt64
signature_algorithmCertificate signature algorithmLowCardinality(String)
verificationCertificate chain verification resultLowCardinality(String)
verification_codeCertificate verification result codeUInt64
verification_errorCertificate verification error, if anyString
metric_familyASM metric family classificationLowCardinality(String)