Forum Discussion

Smeets's avatar
Smeets
Comet
2 months ago
Solved

AccountMetrics - Cannot query field "tunnelAge" on type "Metrics"

We would like to query connectivity metrics using the accountMetrics API. This works as expected for metrics such as bytesUpstream, bytesDownstream. However, it fails for some other metrics such as tunnelAge and lastMilePacketLoss.

Request URL: https://api.catonetworks.com/api/v1/graphql2

Request body:

{
    "query": "{ accountMetrics(accountID:XXXX timeFrame: \"utc.xxxx/{15:50:00--16:00:00}\" groupInterfaces:false groupDevices:false) { sites { interfaces { metrics { tunnelAge } timeseries(buckets: 10 labels: [tunnelAge]) { data label units } } } } }"
}

Exception: 422 Unprocessable Entity

{
    "errors": [
        {
            "message": "Cannot query field \"tunnelAge\" on type \"Metrics\".",
            "locations": [
                {
                    "line": 1,
                    "column": 157
                }
            ],
            "extensions": {
                "code": "GRAPHQL_VALIDATION_FAILED"
            }
        }
    ],
    "data": null
}

According to the documentation, this should work: Cato API - AccountMetrics > Timeseries – Cato Learning Center

Why is it that this request does not work for 'tunnelAge' but does work for 'bytesUpstream'?

  • Hello Smeets,

    The request doesn't work because tunnelAge is not defined in the API schema as a valid metric for that part of the request. The valid metrics are visible here: https://api.catonetworks.com/documentation/#definition-Metrics

    Not being defined in the schema usually means that it was a deliberate decision, so if you would like to see this metric there, you can submit an RFE via Cato Support to ask for it to be added.

    tunnelAge is available as a timeseries metric (which is a different part of the schema), so that might get you going in the meantime?

     

  • peter's avatar
    peter
    Icon for Cato Employee rankCato Employee

    Hello Smeets,

    The request doesn't work because tunnelAge is not defined in the API schema as a valid metric for that part of the request. The valid metrics are visible here: https://api.catonetworks.com/documentation/#definition-Metrics

    Not being defined in the schema usually means that it was a deliberate decision, so if you would like to see this metric there, you can submit an RFE via Cato Support to ask for it to be added.

    tunnelAge is available as a timeseries metric (which is a different part of the schema), so that might get you going in the meantime?

     

    • Smeets's avatar
      Smeets
      Comet

      Removing the metrics field and only using the tunnelAge in the timeseries part indeed solved my issue.

      Thank you!