How to retrieve Metrics

Metrics are derived from events tracked by the Enterprise Stack. To explore the different types of events available, please click here. By utilizing the events/query endpoint, we can not only fetch the events that have occurred, but we can also aggregate these events into metrics through our group by function.

In the following section, we will see how to retrieve the number all successful issuance events

Retrieve Metrics

We will use the /events/query endpoint to specify a filter. This filter will ensure that we only retrieve the events we want to include in our metric. Also, we specify a group by function that should be applied to a specified field in our filtered events.

CURL

Endpoint: /v1/events/query | API Reference

Ensure the organization is set to one your user has read access on when filtering for events.

Example Request

curl -X 'POST' \
  'https://{orgID}.enterprise-sandbox.waltid.dev/v1/events/query?organization={orgID}&groupBy={pathToField}' \
  -H 'accept: */*' \
  -H 'Authorization: Bearer {yourToken}' \
  -H 'Content-Type: application/json' \
  -d '{
  "target": [
    "waltid.mycustomer.issuer2"
  ]
}'

Path Parameters

  • orgID: - When performing operations within an organization, it is essential to use the organization's Base URL or another valid host alias. For example, if your organization is named test, your default Base URL will be test.enterprise-sandbox.walt.dev when using the sandbox environment.
  • pathToField: Specifies the field of the events we want to group by, in our example status.type.

Body

{
  "target": [
    "waltid.mycustomer.issuer2"
  ]
}

Here we specify that we only want to receive events that happened in a specific target. Learn more about how to craft your filter here


Response

  • 200 - Events with group option retrieved successfully.

Example Response

[
  {
    "_id": "Open",
    "count": 2
  },
  {
    "_id": "Success",
    "count": 2
  }
]

Now in the response we can see that we have issued two credentials successfully:

{
  "_id": "Success",
  "count": 2
}