I'm trying to select some values, from the status of the cloud routers to show the bgp peerings, however while I can return the ASN number correctly, trying to get any other value from the same output is failing, and I don't know why.
My command: gcloud compute routers get-status router-2 --region northamerica-northeast1 --project my-project --format="value[separator=' → '](result.bestRoutes.asPaths.asLists,result.bestRoutes.asPaths.destRange,result.bestRoutes.asPaths.nextHopIp,result.bestRoutes.asPaths.priority)"
Results in the following, showing the correct ASN, but then the other values I'm expecting returned are missing. Also, the way the values are listed isn't really what I'm looking for. I want to get the 'ASN -> destRange -> nextHopIP' and then list the next ASN, and the same details.
[[65123]];[[65123]];[[65123]] ? ;; ? ;; ? ;;
When I do the extract, without formatting it, I can see the values all exist:
result:
bestRoutes:
- asPaths:
- asLists:
- 65123
pathSegmentType: AS_SEQUENCE
creationTimestamp: '2025-02-18T05:51:30.490-08:00'
destRange: 10.0.0.0/8
kind: compute#route
network:
nextHopIp: 169.254.0.1
nextHopOrigin: INCOMPLETE
nextHopVpnTunnel:
priority: 100
routeType: BGP
- asPaths:
- asLists:
- 65123
pathSegmentType: AS_SEQUENCE
creationTimestamp: '2025-02-18T05:51:30.490-08:00'
destRange: 192.168.0.0/16
kind: compute#route
network:
nextHopIp: 169.254.0.1
nextHopOrigin: INCOMPLETE
nextHopVpnTunnel:
priority: 100
routeType: BGP
EDIT: I've sinced realised I need to use flatten, against the result.bestRoutes[] to get each ASN on it's own line, which has worked,
[65123] ? ? ? ;;;;;;;;;
[65123] ? ? ? ;;;;;;;;;
[65123] ? ? ? ;;;;;;;;;
But I still can't pull the other values that I also want?
I'm trying to select some values, from the status of the cloud routers to show the bgp peerings, however while I can return the ASN number correctly, trying to get any other value from the same output is failing, and I don't know why.
My command: gcloud compute routers get-status router-2 --region northamerica-northeast1 --project my-project --format="value[separator=' → '](result.bestRoutes.asPaths.asLists,result.bestRoutes.asPaths.destRange,result.bestRoutes.asPaths.nextHopIp,result.bestRoutes.asPaths.priority)"
Results in the following, showing the correct ASN, but then the other values I'm expecting returned are missing. Also, the way the values are listed isn't really what I'm looking for. I want to get the 'ASN -> destRange -> nextHopIP' and then list the next ASN, and the same details.
[[65123]];[[65123]];[[65123]] ? ;; ? ;; ? ;;
When I do the extract, without formatting it, I can see the values all exist:
result:
bestRoutes:
- asPaths:
- asLists:
- 65123
pathSegmentType: AS_SEQUENCE
creationTimestamp: '2025-02-18T05:51:30.490-08:00'
destRange: 10.0.0.0/8
kind: compute#route
network: https://www.googleapis/compute/v1/projects/my-project/global/networks/my-vpc
nextHopIp: 169.254.0.1
nextHopOrigin: INCOMPLETE
nextHopVpnTunnel: https://www.googleapis/compute/v1/projects/my-project/regions/northamerica-northeast1/vpnTunnels/my-tunnel-1
priority: 100
routeType: BGP
- asPaths:
- asLists:
- 65123
pathSegmentType: AS_SEQUENCE
creationTimestamp: '2025-02-18T05:51:30.490-08:00'
destRange: 192.168.0.0/16
kind: compute#route
network: https://www.googleapis/compute/v1/projects/my-project/global/networks/my-vpc
nextHopIp: 169.254.0.1
nextHopOrigin: INCOMPLETE
nextHopVpnTunnel: https://www.googleapis/compute/v1/projects/my-project/regions/northamerica-northeast1/vpnTunnels/my-tunnel-1
priority: 100
routeType: BGP
EDIT: I've sinced realised I need to use flatten, against the result.bestRoutes[] to get each ASN on it's own line, which has worked,
[65123] ? ? ? ;;;;;;;;;
[65123] ? ? ? ;;;;;;;;;
[65123] ? ? ? ;;;;;;;;;
But I still can't pull the other values that I also want?
Share Improve this question edited 10 hours ago djsmiley2kStaysInside asked 13 hours ago djsmiley2kStaysInsidedjsmiley2kStaysInside 3162 silver badges16 bronze badges1 Answer
Reset to default 2I finally figured out that the values I was trying to extract weren't infact inunder the asPaths list, as I'd first read it.
Instead, using the correct formatting string worked
format="get(result.bestRoutes.asPaths.asLists,result.bestRoutes.destRange,result.bestRoutes.nextHopIp,result.bestRoutes.priority)"