Use the Recommender CLI and API

Stay organized with collections Save and categorize content based on your preferences.

Network Analyzer uses Recommender commands. Recommender is a Google Cloud service that provides usage recommendations for Google Cloud products and services.

Request insights

gcloud

To list insights for a Google Cloud project, run the following command:

gcloud recommender insights list \
    --project=PROJECT_ID \
    --location=LOCATION \
    --insight-type=INSIGHT_TYPE \
    --filter=EXPRESSION \
    --limit=LIMIT \
    --page-size=PAGE_SIZE \
    --sort-by=SORT_BY \
    --format=json

Replace the following with values for your network:

  • PROJECT_ID: the project ID that you want to list insights for. You can also list all insights for a folder, organization, or a billing account.
  • LOCATION: the location to list insights for, such as global, europe, asia-east1, or us-central1-a.
  • INSIGHT_TYPE: the Network Analyzer insight type to request, such as google.networkanalyzer.vpcnetwork.connectivityInsight.

    For a complete list of insight types, see Insight types.

The following fields are optional:

  • EXPRESSION: apply this Boolean filter to each resource that you want to list.

    If the expression evaluates as True, that item is listed. For more details and examples of filter expressions, run $ gcloud topic filters or see the gcloud topic filters documentation.

  • LIMIT: the maximum number of resources to list; the default number of resources listed is unlimited.

  • PAGE_SIZE: the maximum number of resources to list per page.

    The default page size is determined by the service; otherwise, there is no paging. Paging might be applied before or after FILTER and LIMIT.

  • SORT_BY: a list of comma-separated field key names to sort by for a resource.

    The default order is ascending. To specify a descending order, prefix a field with ~ (a tilde).

API

To get insights for a Google Cloud project, make a GET request to the projects.locations.insightTypes.insights method:

https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/INSIGHT_TYPE/insights

Replace the following values:

  • PROJECT_ID: the project ID.
  • LOCATION: the location to list insights for, such as global, europe, asia-east1, or us-central1-a.
  • INSIGHT_TYPE: the Network Analyzer insight type to list, such as google.networkanalyzer.vpcnetwork.connectivityInsight.

    For a complete list of insight types, see Insight types.

The following example shows a sample response for this command:

{
  "name": "projects/{project_number}/locations/{location}/insightTypes/google.networkanalyzer.hybridconnectivity.dynamicRouteInsight/insights/{insight_id}",
  "description": "Dynamic route is fully shadowed by a peering subnet route",
  "content": {
    "networkUri": "//compute.googleapis.com/projects/{project_id}/global/networks/{network_name}",
    "region": "{location}",
    "ipRange": "{ip_range}",
    "priority": 100,
    "nextHopUri": "//compute.googleapis.com/projects/{project_id}/regions/{location}/vpnTunnels/{tunnel_name}",
    "cloudRouterUri": "//compute.googleapis.com/projects/{project_id}/regions/{location}/routers/{router_name}",
    "shadowingRouteUris": [
      "//compute.googleapis.com/projects/{project_id}/global/routes/{route_name}"
    ],
    "shadowingRouteType": "PEERING_SUBNET"
  },
  "lastRefreshTime": "2022-09-15T21:10:57.187942979Z",
  "observationPeriod": "611870.625920374s",
  "stateInfo": {
    "state": "ACTIVE"
  },
  "category": "PERFORMANCE",
  "targetResources": [
    "//compute.googleapis.com/projects/{project_id}/regions/{location}/vpnTunnels/{tunnel_name}"
  ],
  "insightSubtype": "DYNAMIC_ROUTE_FULLY_SHADOWED",
  "severity": "MEDIUM"
}

Describe insight details

gcloud

To list details of a particular insight, run the following command:

gcloud recommender insights describe INSIGHT_ID \
    --project=PROJECT_ID \
    --location=LOCATION \
    --insight-type=INSIGHT_TYPE

Replace the following with values for your network:

  • INSIGHT_ID: the ID of the insight to describe.
  • PROJECT_ID: the ID of the project containing the insight.
  • LOCATION: the location to list insights for.
  • INSIGHT_TYPE: the Network Analyzer insight type of the insight, such as google.networkanalyzer.vpcnetwork.connectivityInsight.

    For a complete list of insight types, see Insight types.

API

To get details for an insight, make a GET request to the projects.locations.insightTypes.insights method:

https://recommender.googleapis.com/v1/projects/PROJECT/locations/LOCATION/insightTypes/INSIGHT_TYPE/insights/INSIGHT_ID

Replace the following values:

  • PROJECT_ID: the project ID.
  • LOCATION: the location of the insight.
  • INSIGHT_TYPE: the Network Analyzer insight type of the insight, such as google.networkanalyzer.vpcnetwork.connectivityInsight.

    For a complete list of insight types, see Insight types.

  • INSIGHT_ID: the insight ID for the insight.

Insight types

Network Analyzer insights are grouped under the following Recommender insight types.

Network Analyzer insight type IAM permission Recommender insight type (prefix: google.networkanalyzer)
Cloud Load Balancing networkAnalyzerLoadBalancerInsights networkservices.loadBalancerInsight
GKE IP address utilization networkAnalyzerGkeIpAddressInsights container.ipAddressInsight

GKE connectivity insights

networkAnalyzerGkeConnectivityInsights container.connectivityInsight

IP address insights

networkAnalyzerIpAddressInsights vpcnetwork.ipAddressInsight
Shadowed dynamic routes networkAnalyzerDynamicRouteInsights hybridconnectivity.dynamicRouteInsight
Routes with an invalid next hop networkAnalyzerConnectivityInsights vpcnetwork.connectivityInsight
Cloud SQL connectivity networkAnalyzerCloudSqlInsights managedservices.cloudSqlInsight