Checkly Analytics API
With the Analytics API, you can query all check metrics and report on Checkly data in your preferred reporting tool! The Analytics APIs allows queries across different dimensions:
- Aggregated: get the p99, sum, standard deviation or whatever you like from DNS times for API checks, or First Content ful Paint (FCP) score for Browser checks.
- Non-aggregated: Get the raw data points so you can aggregate yourself how you want it.
Use powerful options like quickRange
to select time window presets like last30Days
or lastMonth
, and group results
per location
or per pageIndex
. For aggregated queries you can set the aggregationInterval
to get, for instance, data
aggregated per week over the last 30 days.
Dive straight into the API reference at developers.checklyhq.com or keep reading for more examples!
Analytics API basics
There are three main endpoints.
/v1/analytics/metrics/
: returns all the available metrics for a specific check-type (API
orBROWSER
)/v1/analytics/browser-checks/{checkId}
: returns metrics for Browser checks./v1/analytics/api-checks/{checkId}
: returns metrics for API checks.
The specific endpoints per check type return a JSON response that includes a check’s attributes, period requested,
grouped series
and a metadata
section where you’ll have additional information about the metrics to create rich reports.
The example below is from a Browser check that visits three pages in a typical e-commerce flow
/login
/cart
/cart/add
We can query the for this Browser check using a curl
command like:
This command add the following query params:
metrics=TTFB_avg,TTFB_p99
: return average and p99 aggregate of the TTFB (Time to First Byte)groupBy=pageIndex
: group by page index, i.e. the pages visited int the Browser check.quickRange=last7Days
: aggregate over the last 7 days.
The response looks as follows 👇
Using the Analytics API with Postman
Here you will see an example of a request using Postman where the /v1/analytics/browser-check
endpoint returns aggregated
data (TTFB_p50
and TTFB_p90
) for the last 7 days grouping by page.
You must add the X-Checkly-Account
and Authorization
headers to authenticate.
Building a Grafana dashboard
Following these instructions you’ll learn how to use the Analytics API within a Grafana dashboard:
- Creating the Data Source
First, you need to create the Data Source with the Analytics API connection. After installing the JSON API plugin you’ll be able to consume any REST API and handle JSON responses.
- Configuring a component
Next, you can pick a time series component and configure it by selecting the Checkly Analytics API
data source and
setting the required HTTP header and query parameters to fetch the JSON. You’ll find detailed docs on available parameters in the API docs
In the following image you’ll see all required configuration for a component:
-
Fields
-
Path
-
Query parameters
-
Header
-
Variables
(optional)
- Designing the dashboard
You can mix multiple components to create a beautiful dashboard. The following screenshot shows a dashboard with three types of results:
- aggregated
- non-aggregated
- and summarized grouped by location.
Creating reports with Google Sheets
You can start creating your reports by using our public Google Sheets report example template. The spreadsheet includes the =ChecklyAPI()
function to consume the Checkly Public API just entering configuring your credentials.
- Make a copy of our public Google Sheets template.
- Add your
Account Id
andAPI Key
in the Apps Script code (be careful if you’ll share your spreadsheet with your credentials) - Navigate the
Metrics
andChecks
pages to confirmCheckly Public API
requests are working - Go to the
Analytics Report
page, pick a check, pick a metric and see if the chart shows the correct information
You’ll find dropdown cells to select the check, number of results, quick time range presets, or grouping attribute.
Creating report using curl
and jq
You can even whip up a bash
script and use curl
and jq
to print useful analytics to your terminal. Here is an example
script that does the following:
- It fetches your checks from the
/v1/checks
endpoint. - Loops over your checks and based on the check type, calls the
v1/analytics/<checkType>
endpoint to gather useful data.
Save this script in a file called analytics.sh
and run it. You will get an output similar to:
Last updated on December 2, 2024. You can contribute to this documentation by editing this page on Github