How do I get the same responses as from the former api-metrics?

The API contract that replaces api-metrics is different.

Compared to when it was embedded in the platform, the new Analytics is now much more flexible, giving you more possibilities for query customization.

Instead of the api-metrics, you now have the endpoint {/analytics/v1/products/api-gateway/traces/query}.

See below an example:

Getting the total calls for the day with the endpoint traces/query

This information is also available in video. See (video 1) at the end of this page.

  1. In the tool of your choice (e.g., Postman), select the POST method and enter your URL with the endpoint {/analytics/v1/products/api-gateway/traces/query}.

  2. In Headers, enter the sensedia-auth key value.
    See here how to get this value.
    image from postman with fields of interest for step 2

  3. Write your query in the body of the request.
    You can use DQL or Lucene.
    There are easy ways to get the query, either from a General Trace filter or from a Dashboard visualization.
    image from Postman with fields of interest for step 3

  4. Click SEND and see the result in the body of the response.
    image from Postman with fields of interest for step 4


Here are some tips to save you time.

You can build the query using Analytics' graphical interface and then copy and paste it in step 3 above.

See below how to do that.

Queries made accessing the /traces/query endpoint have some limitations such as timeout and rate limit. Therefore, it is indicated only for specific searches. For more comprehensive data extraction, use Data Streaming.

General Trace Filters

Follow the example steps below to generate a query from the General Trace GUI.

The steps can be used with any combination of filters, defined in step 1 below.

Example of a shortcut to write a query using Generarl Trace

This information is also available in video. See (video 2) at the end of this page.

  1. In Analytics, under General Trace, create a search using the available filters and fields.
    For this example, let’s define a filter using the field for status code and a time range of 1 week, as shown in the image below. image of general trace highlighting filters

  2. Once the filters are created, click Inspect.
    image of general trace with inspect link

  3. Click Request and look for the query.
    image of general trace with request link

  4. Select and copy the query from Inspect > Request from General Trace.

  5. This query is used in step 3 of the first example, that is:

    1. Go to Postman and paste the query in the appropriate place in the request’s Body.
      Pay attention to the beginning and end of the braces.
      image of general trace and postman screens

    2. Still in Postman, click SEND and check the result in the body of the response.

Aggregations from Visualize or Dashboards

Follow the steps from the example below to generate a query from the Dashboard or Visualize graphical interface.

These steps can be used with any visualization.

You can tailor the search to bring up what you need using the features of Visualize or Dashboards.

Example of shortcut to write a query with aggregation using Dashboards

This information is also available in video. See (video 3) at the end of this page.

  1. In Analytics, enter Dashboards.

  2. In the list with your Dashboards, find and open the Dashboard that contains the visualization with the aggregation you want.

  3. Click the icon in the upper-right corner of the panel containing the chosen visualization and click More > Inspect.
    Then click View:Data > Requests > Request and copy the entire query.

    animation showing the steps and icon to copy the query

  4. Go to Postman and paste the query into the Body of the request.

  5. Still in Postman, click SEND and check the result in the body of the response.

    animation with steps 4 and 5

For simpler searches, you can write the query directly in the step 3 of the first example.

See the page about Query DSL in the OpenSearch documentation for examples of basic queries.

Shorts

Here you have the same steps mentioned above, now in short videos.

1. Endpoint traces/query

2. Query from General Trace

3. Query from Dashboards

video1 thumbnail

video2 thumbnail

video3 thumbnail

Thanks for your feedback!
EDIT

Share your suggestions with us!
Click here and then [+ Submit idea]