API Client unable to pull data from Tanzu Observability (TO)

This article applies to:

Browsing Data, Visualizing Data, Querying, Usage Monitoring, Alerting.

Product edition: All version

Feature Category: API Client, API calls.

 

 

Problem Description:

Many times, when using an API client and to pull data from TO, we may finds ourselves unable to obtain the information desired due to a number of reasons. Most of them can be remedied with the below suggestions...

 

Cause:

As first step, we need to break this into pieces as to understand  where the potential cause may rely:

  • The query itself.
  • The Tobs API service or any other API parameter on Tobs' end.
  • The API client.

 

Resolution:

To begin ruling out options, we first need to ask ourselves :

  • Can I run the actual query from the TO's UI ?

If there's a query syntax error, the TO's UI on many occasions will give us a hint as what's going on. This by showing in red/orange letters a legend just below the query itself.

 

If there's no problem running the query from the UI, then the next step will be checking the TO's API Documentation:  https://<your_cluster_name>.com/api-docs/ui/

 

Here, you'll look for the type of API call you are attempting to run,  expand the option in question, click on "Try it out " and finally, enter the query and other API details .

 

As when using the TO's UI to run the query, the API Doc page will as well provide you a more explicit error message if there's a situation either with the query or with the API construct.

 

For example, if you are attempting to run a query that ran fine from the UI but it includes Alias or Variables, this won't work when making the API Call. Instead, from the TO's API Doc page you'll get a 400 error along with a similar error message as follows:

 

From the API's the query expression to execute:

${Sum}/${Rawsum}

We would get something like this: 

Error: response status is 400:
error='parameter_error'
message='Required variable [Sum] not found'
trackingId=d50ce37c-5d76-4eb7-9cec-c906406893b3

From this particular type of scenario, Alias nor Variables cannot be used on the API query. Instead you'll need to enter manually the actual referenced value.

Another example would be in case there's a syntax error:

From the API's the query expression to execute:

align(1m, ts(~proxy.buffer.fill-rate)) / align(1m, ts(~proxy.buffer.flush-count)

The API doc page would be showing an error message as the one below:

{
"query": "align(1m, ts(~proxy.buffer.fill-rate)) / align(1m, ts(~proxy.buffer.flush-count)",
"errorType": "QuerySyntaxError",
"errorMessage": "Query syntax error: rule stack: [program, query, expression, expression, math, movingstatistic, align]\nline 1:80,1:85 (text='<EOF>'): - missing ')' at '<EOF>'\n"
}

 

The above is just a couple of common examples of many potential API construct situations. The key takeaway from the above it is to know that via the API Documentation or the UI, you'll have messages that will either guide you to correct the situation on your own, or it will provide key information that you can later share with us when opening a ticket for support.

 

If the query output is valid in the UI or through the cluster’s API Documentation Swagger UI, verify your settings on the API client side. An example would be a typo in the URL string\encoding.

 

See also: 

API Code:400 Returned when using unescaped JSON characters

 

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk