API show bgp summary

,

hi everyone!
can anyone help me.
how to show bgp summary from API, like command from vtysh:

sw-01# show bgp summary json
{
"ipv4Unicast":{
  "routerId":"192.0.0.70",
  "as":65002,
  "vrfId":0,
  "vrfName":"Default",
  "tableVersion":75,
  "ribCount":27,
  "ribMemory":4104,
  "peerCount":1,
  "peerMemory":62064,
  "peers":{
    "192.0.5.1":{
      "hostname":"evpn-lab01",
      "remoteAs":1000,
      "version":4,
      "msgRcvd":113,
      "msgSent":268,
      "tableVersion":0,
      "outq":0,
      "inq":0,
      "peerUptime":"00:00:05",
      "peerUptimeMsec":5000,
      "peerUptimeEstablishedEpoch":1530104760,
      "prefixReceivedCount":3,
      "state":"Idle (PfxCt)",
      "idType":"ipv4"
    },
  },
  "totalPeers":1,
  "dynamicPeers":0,
  "bestPath":{
    "multiPathRelax":"false"
  }
}
}

Hi!

Do you mean like this?

vyos@vyos:~$ sudo vtysh -c “show bgp summary json”
{
“ipv4Unicast”:{
“routerId”:“11.11.11.11”,
“as”:100,
“vrfId”:0,
“vrfName”:“default”,
“tableVersion”:0,
“ribCount”:0,
“ribMemory”:0,
“peerCount”:1,
“peerMemory”:741976,
“peers”:{
“10.10.0.2”:{
“hostname”:“vyos”,
“remoteAs”:200,
“localAs”:100,
“version”:4,
“msgRcvd”:8,
“msgSent”:8,
“tableVersion”:0,
“outq”:0,
“inq”:0,
“peerUptime”:“00:05:49”,
“peerUptimeMsec”:349000,
“peerUptimeEstablishedEpoch”:1690990840,
“pfxRcd”:0,
“pfxSnt”:0,
“state”:“Established”,
“peerState”:“OK”,
“connectionsEstablished”:1,
“connectionsDropped”:0,
“idType”:“ipv4”
}
},
“failedPeers”:0,
“displayedPeers”:1,
“totalPeers”:1,
“dynamicPeers”:0,
“bestPath”:{
“multiPathRelax”:“false”
}
}

yes, but calling this from API
I want to show bgp summary to web page using api

Unfortunately, the vyos http api didn’t support with it.

curl -k -s  --connect-timeout ${TIMEOUT} \
    --location --request POST "https://${REMOTE_SERVER}:${REMOTE_PORT}/retrieve" \
    --form key="${REMOTE_API_KEY}" \
    --form data='{"op": "showConfig", "path": ["bgp","summary"]}'  --form key="${REMOTE_API_KEY}"
{"success": false, "error": "Specified configuration path is not valid\n", "data": null}

Previously I also tried the method above, and it didn’t work. maybe there is another solution?

You can get it from GraphQL

set service https api graphql
set service https api keys id KID key 'foo'
set service https api socket

Request

curl -k --raw 'https://192.0.2.1/graphql' -H 'Content-Type: application/json' -d '{"query":" {\n ShowSummaryBgp (data: {key: \"foo\"}) {success errors data {result}}}"}'

Example

vyos@r14:~$ curl -k --raw 'https://192.0.2.1/graphql' -H 'Content-Type: application/json' -d '{"query":" {\n ShowSummaryBgp (data: {key: \"foo\"}) {success errors data {result}}}"}'
{"data":{"ShowSummaryBgp":{"success":true,"errors":null,"data":{"result":{"ipv4_unicast":{"router_id":"192.168.122.14","as":65001,"vrf_id":0,"vrf_name":"default","table_version":0,"rib_count":0,"rib_memory":0,"peer_count":1,"peer_memory":20864,"peers":{"192_0_2_2":{"remote_as":65001,"local_as":65001,"version":4,"msg_rcvd":0,"msg_sent":0,"table_version":0,"outq":0,"inq":0,"peer_uptime":"never","peer_uptime_msec":0,"pfx_rcd":0,"pfx_snt":0,"state":"Active","peer_state":"OK","connections_established":0,"connections_dropped":0,"id_type":"ipv4"}},"failed_peers":1,"displayed_peers":1,"total_peers":1,"dynamic_peers":0,"best_path":{"multi_path_relax":"false"}}}}}}}vyos@r14:~$ 
vyos@r14:~$ 

The solution didn’t support VyOS 1.3.3.:frowning:

# set service https api graphql

  Configuration path: service https api [graphql] is not valid
  Set failed

All goodies only in 1.4 :wink: