Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
resource_aggregated_stats = client.cdn.statistics.get_resource_usage_aggregated(
from_="from",
metrics="metrics",
service="service",
to="to",
)
print(resource_aggregated_stats.max_bandwidth)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cdn"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
resourceAggregatedStats, err := client.CDN.Statistics.GetResourceUsageAggregated(context.TODO(), cdn.StatisticGetResourceUsageAggregatedParams{
From: "from",
Metrics: "metrics",
Service: "service",
To: "to",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", resourceAggregatedStats.MaxBandwidth)
}
curl --request GET \
--url https://api.gcore.com/cdn/statistics/aggregate/stats \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cdn/statistics/aggregate/stats', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/cdn/statistics/aggregate/stats",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/cdn/statistics/aggregate/stats")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/statistics/aggregate/stats")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"resource": {
"1": {
"region": {
"cis": {
"metrics": {
"95_percentile": 20023536,
"cache_hit_traffic_ratio": 0.9958449964158854,
"max_bandwidth": 34794756,
"min_bandwidth": 379257,
"requests": 21575631,
"responses_2xx": 21095299,
"responses_3xx": 278225,
"responses_4xx\"": 202026,
"responses_5xx\"": 81,
"sent_bytes\"": 22014089592053,
"total_bytes\"": 22105558213209,
"upstream_bytes\"": 91468621156,
"responses_hit\"": 63368252,
"responses_miss\"": 866237
}
},
"eu": {
"metrics": {
"95_percentile": 14324356,
"cache_hit_traffic_ratio": 0.9852247660029627,
"max_bandwidth": 22215199,
"min_bandwidth": 299608,
"requests": 64234595,
"responses_2xx": 62616980,
"responses_3xx": 1196666,
"responses_4xx": 420718,
"responses_5xx": 216,
"sent_bytes": 16552226067556,
"total_bytes": 16796789080876,
"upstream_bytes": 244563013320,
"responses_hit": 21235829,
"responses_miss\"": 339566
}
}
}
}
}
}Statistics
Aggregated statistics
Get information about monthly CDN traffic data.
Request URL parameters should be added as a query string after the endpoint.
GET
/
cdn
/
statistics
/
aggregate
/
stats
Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
resource_aggregated_stats = client.cdn.statistics.get_resource_usage_aggregated(
from_="from",
metrics="metrics",
service="service",
to="to",
)
print(resource_aggregated_stats.max_bandwidth)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cdn"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
resourceAggregatedStats, err := client.CDN.Statistics.GetResourceUsageAggregated(context.TODO(), cdn.StatisticGetResourceUsageAggregatedParams{
From: "from",
Metrics: "metrics",
Service: "service",
To: "to",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", resourceAggregatedStats.MaxBandwidth)
}
curl --request GET \
--url https://api.gcore.com/cdn/statistics/aggregate/stats \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cdn/statistics/aggregate/stats', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/cdn/statistics/aggregate/stats",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/cdn/statistics/aggregate/stats")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/statistics/aggregate/stats")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"resource": {
"1": {
"region": {
"cis": {
"metrics": {
"95_percentile": 20023536,
"cache_hit_traffic_ratio": 0.9958449964158854,
"max_bandwidth": 34794756,
"min_bandwidth": 379257,
"requests": 21575631,
"responses_2xx": 21095299,
"responses_3xx": 278225,
"responses_4xx\"": 202026,
"responses_5xx\"": 81,
"sent_bytes\"": 22014089592053,
"total_bytes\"": 22105558213209,
"upstream_bytes\"": 91468621156,
"responses_hit\"": 63368252,
"responses_miss\"": 866237
}
},
"eu": {
"metrics": {
"95_percentile": 14324356,
"cache_hit_traffic_ratio": 0.9852247660029627,
"max_bandwidth": 22215199,
"min_bandwidth": 299608,
"requests": 64234595,
"responses_2xx": 62616980,
"responses_3xx": 1196666,
"responses_4xx": 420718,
"responses_5xx": 216,
"sent_bytes": 16552226067556,
"total_bytes": 16796789080876,
"upstream_bytes": 244563013320,
"responses_hit": 21235829,
"responses_miss\"": 339566
}
}
}
}
}
}Authorizations
Query Parameters
Types of statistics data.
Possible values:
upstream_bytes- Traffic in bytes from an origin server to CDN servers or to origin shielding when used.sent_bytes- Traffic in bytes from CDN servers to clients.shield_bytes- Traffic in bytes from origin shielding to CDN servers.total_bytes-shield_bytes,upstream_bytesandsent_bytescombined.cdn_bytes-sent_bytesandshield_bytescombined.- requests - Number of requests to edge servers.
responses_2xx- Number of 2xx response codes.responses_3xx- Number of 3xx response codes.responses_4xx- Number of 4xx response codes.responses_5xx- Number of 5xx response codes.responses_hit- Number of responses with the header Cache: HIT.responses_miss- Number of responses with the header Cache: MISS.cache_hit_traffic_ratio- Formula: 1 -upstream_bytes/sent_bytes. We deduct the non-cached traffic from the total traffic amount.shield_usage- Origin shielding usage. To get accurate results, you must use grouping or filtering by a client or by a CDN resource.raw_logs_usage- Logs uploader usage. To get accurate results, you should use grouping or filtering by a client or by a CDN resource.
Output data grouping.
Possible values:
- client - Data is grouped by clients.
- resource - Data is grouped by CDN resources.
- region - Data is grouped by regions of CDN edge servers.
- country - Data is grouped by countries of CDN edge servers.
- vhost - Data is grouped by resources CNAMEs.
client_country- Data is grouped by countries, based on end-users' location.
To request multiple values, use:
- &
group_by=client&group_by=resource
Names of countries for which data should be displayed.
English short names from ISO 3166 standard without the definite article ("the") should be used.
To request multiple values, use:
- &countries=france&countries=denmark
Response
Successful.
Was this page helpful?