Monitoring API
The Zaraz Monitoring API allows users to retrieve detailed data on Zaraz events through the GraphQL Analytics API. Using this API, you can monitor events, pageviews, triggers, actions, and server-side request statuses, including any errors and successes. The data available through the API mirrors what is shown on the Zaraz Monitoring page in the dashboard, but with the API, you can query it programmatically to create alerts and notifications for unexpected deviations.
To get started, you'll need to generate an Analytics API token by following the API token authentication guide.
The Monitoring API includes the following core entities, which each provide distinct insights:
- zarazTrackAdaptiveGroups: Contains data on Zaraz events, such as event counts and timestamps.
- zarazActionsAdaptiveGroups: Provides information on Zaraz Actions.
- zarazTriggersAdaptiveGroups: Tracks data on Zaraz Triggers.
- zarazFetchAdaptiveGroups: Captures server-side request data, including URLs and returning status codes for third-party requests made by Zaraz.
You can construct any query you'd like using the above datasets, but here are some example queries you can use.
Query for the count of Zaraz events, grouped by time.
Query for the count of Zaraz loads, grouped by time.
Query for the total execution count of each trigger processed by Zaraz.
Query for the count of 400 server-side responses, grouped by time and URL.
Be sure to customize the zoneTag to match your specific zone, along with setting the desired start and end dates
- zoneTag: Unique identifier of your Cloudflare zone.
- limit: Maximum number of results to return.
- start and end: Define the date range for the query in ISO 8601 format.
- orderBy: Determines the sorting order, such as by ascending or descending datetime.
Use this curl
command to query the Zaraz Monitoring API for the number of events processed by Zaraz. Replace $TOKEN
with your API token, $ZONE_TAG
with your zone tag, and adjust the start and end dates as needed.
- Authorization: The
Authorization
header requires a Bearer token. Replace$TOKEN
with your actual API token. - Content-Type: Set
application/json
to indicate a JSON payload. - Data Payload: This payload includes the GraphQL query and variable parameters, such as
zoneTag
,start
,end
,limit
, andorderBy
.
This curl
example will return a JSON response containing event counts and timestamps within the specified date range. Modify the variables
values as needed for your use case.
Refer to the full GraphQL Analytics API documentation for more details on available fields, filters, and further customization options for Zaraz Monitoring API queries.