/metrics API
The metrics API returns an array of session statistics. Data covers a maximum of 1 week.
Private fleet customers
Call /metrics on your dedicated fleet URL (e.g., chrome.browserless.io), not on production-sfo.browserless.io. Using the shared fleet URL with a private fleet token will not return your fleet's data.
Metrics reset after a Relaunch. estimatedMonthlyUnits will be unreliable for several hours on a freshly launched fleet. For reliable unit consumption tracking, use the GraphQL exportMetrics query.
Gathering metrics from your workers
Issue a GET request to /metrics to retrieve session statistics:
- cURL
- Javascript
- Python
- Java
- C#
curl -X GET \
https://production-sfo.browserless.io/metrics?token=YOUR_API_TOKEN_HERE
const TOKEN = "YOUR_API_TOKEN_HERE";
const url = `https://production-sfo.browserless.io/metrics?token=${TOKEN}`;
const fetchMetrics = async () => {
const response = await fetch(url, {
method: 'GET'
});
const result = await response.json();
console.log(result);
};
fetchMetrics();
import requests
TOKEN = "YOUR_API_TOKEN_HERE"
url = f"https://production-sfo.browserless.io/metrics?token={TOKEN}"
response = requests.get(url)
result = response.json()
print(result)
import java.io.*;
import java.net.URI;
import java.net.http.*;
public class FetchMetrics {
public static void main(String[] args) {
String TOKEN = "YOUR_API_TOKEN_HERE";
String url = "https://production-sfo.browserless.io/metrics?token=" + TOKEN;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.GET()
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main(string[] args) {
string TOKEN = "YOUR_API_TOKEN_HERE";
string url = $"https://production-sfo.browserless.io/metrics?token={TOKEN}";
using var client = new HttpClient();
try {
var response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + result);
} catch (Exception ex) {
Console.WriteLine($"Error: {ex.Message}");
}
}
}
warning
Running this in the browser exposes your API key.
Running this request will result in an output like:
[
{
"error": 3,
"maxConcurrent": 4,
"queued": 0,
"rejected": 0,
"running": 3,
"sessionTimes": [992, 1041, 802],
"successful": 0,
"timedout": 0,
"unauthorized": 0,
"unhealthy": 0,
"maxTime": 1041,
"meanTime": 945,
"minTime": 802,
"totalTime": 2835,
"units": 3,
"date": 1709134233732,
"cpu": 0.024877870173220466,
"memory": 0.7784158564199399
},
// ...
]
/metrics/total
This route will output a similar payload, but with the total stats of all sessions.