Count metrics API
Count metrics let you measure the number of objects that satisfy a particular set of conditions every day. To integrate data of count metrics with external systems, the Portal provides an API to query the details of count metrics. The details of count metrics list the objects that took part in the count, along with any additional display fields that were selected for the metric.
The client of the Count Metrics API must trust the certificate in the primary Appliance (the Portal).
To authenticate the client, the Count Metrics API uses Basic Authentication. Nexthink recommends creating a local account to exclusively authenticate clients of the API.
Finding out available metrics
To interactively look for the details of count metrics that are available through the API:
Point a web browser to the following address:
Substitute <Portal_DNS_FQDN> for the actual name of the Portal.
Log in to the discovery tool of the API as a user with the right to see count metrics (either because the user can see all metrics or because the metric is part of a module that is included in the roles of the user).
Type in the user credentials whenever asked by the web browser.
The discovery tool displays only the available metrics in the view domain of the user.
Depending on the data privacy settings of the user, the names and other identifying attributes of the objects in the details of the count metrics may be anonymized.
Select a metric from the table.
Select an available hierarchy.
Optional: Select a node (in the Select Path column) to restrict the output to a node of the hierarchy. Repeat for each level of the hierarchy.
Optional: To select particular time scope, click the link under the Scopes column. The choice of scope is also displayed when you navigate down the hierarchy and you reach the lowest level (the Entity level).
Under Select scope choose among:
Depending on the selected scope, choose the Period. To retrieve data from the past, ensure that you reserved enough disk space for the details of count metrics. Three options which demonstrate the three different ways of specifying a period are available:
default period - last <scope>
offset - three <scopes> ago
Click any of the links under the columns labeled API link (<format>) to get the details of the count metric for the selected path, scope, and period. If you did not select any scope or period, the default values are applied (see table below in querying the API).
table (HTML table)
Once you have reached the desired details of the metric, note down the URL built by the discovery tool to programmatically query the API later with the same request or use it as a base for your own requests.
Querying the API
To query the Count metrics API, send a GET request to a URL that includes the following parameters:
UID of the desired metric
Name of a hierarchy
The name of the first hierarchy in the Portal
The period depends on the scope defined.
Name of a node in the hierarchy to limit the output. Chain several path elements to limit the output further down in the hierarchy levels.
The highest node in the view domain of the user
Output format, one of:
Example of a query URL:
https://<Portal_DNS_FQDN>/api/metrics/v1/details? metric=7bfae274-6c0d-406f-8c02-d1932fdf6e89& hierarchy=DefaultHierarchy& path=Europe&path=Switzerland&path=Lausanne& scope=day& period=2019-08-22& format=table
The Count Metrics API uses Basic Authentication. To test the API from a Nexthink appliance, you can use
curl, for instance:
curl https://<Portal_DNS_FQDN>/api/metrics/v1/details?... -u username:password
Output of the Count Metrics API
The output of the API is similar to the details of count metrics that you can explore in the Portal.
Find below the complete list of outputs of the Count Metrics API:
The value of the period selected as input. The column is labeled with the associated scope:
The name of the hierarchy selected as input parameter.
The chain of nodes specified as path parameters in the input, where each node is displayed on a separate column that has the label of the corresponding hierarchy level.
The attributes of the objects that constitute the details of the count metric and specified as display fields in the definition of the metric. Each value is displayed in a separate column and labeled with the name of the attribute.