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_usage_stats = client.cdn.statistics.get_resource_usage_series(
from_="from",
granularity="granularity",
metrics="metrics",
service="service",
to="to",
)
print(resource_usage_stats._1_example)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"),
)
resourceUsageStats, err := client.CDN.Statistics.GetResourceUsageSeries(context.TODO(), cdn.StatisticGetResourceUsageSeriesParams{
From: "from",
Granularity: "granularity",
Metrics: "metrics",
Service: "service",
To: "to",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", resourceUsageStats.Number1Example)
}
curl --request GET \
--url https://api.gcore.com/cdn/statistics/series \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cdn/statistics/series', 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/series",
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/series")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/statistics/series")
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": {
"asia": {
"metrics": {
"sent_bytes": [
[
1543622400,
17329220573
]
],
"total_bytes": [
[
1543622400,
17384617989
]
],
"backblaze_bytes": [
[
1543622400,
17384617989
]
],
"upstream_bytes": [
[
1543622400,
55397416
]
]
}
},
"cis": {
"metrics": {
"sent_bytes": [
[
1543622400,
234582406061
]
],
"total_bytes": [
[
1543622400,
234677982848
]
],
"backblaze_bytes": [
[
1543622400,
234677982848
]
],
"upstream_bytes": [
[
1543622400,
95576787
]
]
}
},
"eu": {
"metrics": {
"sent_bytes": [
[
1543622400,
243212514764
]
],
"total_bytes": [
[
1543622400,
243297296511
]
],
"backblaze_bytes": [
[
1543622400,
243297296511
]
],
"upstream_bytes": [
[
1543622400,
84781747
]
]
}
},
"latam": {
"metrics": {
"sent_bytes": [
[
1543622400,
59819837564
]
],
"total_bytes": [
[
1543622400,
59927133387
]
],
"backblaze_bytes": [
[
1543622400,
59927133387
]
],
"upstream_bytes": [
[
1543622400,
107295823
]
]
}
},
"me": {
"metrics": {
"sent_bytes": [
[
1543622400,
13643432427
]
],
"total_bytes": [
[
1543622400,
13644762375
]
],
"backblaze_bytes": [
[
1543622400,
13644762375
]
],
"upstream_bytes": [
[
1543622400,
1329948
]
]
}
},
"na": {
"metrics": {
"sent_bytes": [
[
1543622400,
234004049506
]
],
"total_bytes": [
[
1543622400,
234655863540
]
],
"backblaze_bytes": [
[
1543622400,
234655863540
]
],
"upstream_bytes": [
[
1543622400,
651814034
]
]
}
}
}
},
"4777": {
"region": {
"au": {
"metrics": {
"sent_bytes": [
[
1543622400,
490800672
]
]
}
}
}
}
}
}Statistics
CDN resource statistics
Get CDN resources statistics for up to 365 days starting today.
GET
/
cdn
/
statistics
/
series
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_usage_stats = client.cdn.statistics.get_resource_usage_series(
from_="from",
granularity="granularity",
metrics="metrics",
service="service",
to="to",
)
print(resource_usage_stats._1_example)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"),
)
resourceUsageStats, err := client.CDN.Statistics.GetResourceUsageSeries(context.TODO(), cdn.StatisticGetResourceUsageSeriesParams{
From: "from",
Granularity: "granularity",
Metrics: "metrics",
Service: "service",
To: "to",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", resourceUsageStats.Number1Example)
}
curl --request GET \
--url https://api.gcore.com/cdn/statistics/series \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cdn/statistics/series', 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/series",
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/series")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/statistics/series")
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": {
"asia": {
"metrics": {
"sent_bytes": [
[
1543622400,
17329220573
]
],
"total_bytes": [
[
1543622400,
17384617989
]
],
"backblaze_bytes": [
[
1543622400,
17384617989
]
],
"upstream_bytes": [
[
1543622400,
55397416
]
]
}
},
"cis": {
"metrics": {
"sent_bytes": [
[
1543622400,
234582406061
]
],
"total_bytes": [
[
1543622400,
234677982848
]
],
"backblaze_bytes": [
[
1543622400,
234677982848
]
],
"upstream_bytes": [
[
1543622400,
95576787
]
]
}
},
"eu": {
"metrics": {
"sent_bytes": [
[
1543622400,
243212514764
]
],
"total_bytes": [
[
1543622400,
243297296511
]
],
"backblaze_bytes": [
[
1543622400,
243297296511
]
],
"upstream_bytes": [
[
1543622400,
84781747
]
]
}
},
"latam": {
"metrics": {
"sent_bytes": [
[
1543622400,
59819837564
]
],
"total_bytes": [
[
1543622400,
59927133387
]
],
"backblaze_bytes": [
[
1543622400,
59927133387
]
],
"upstream_bytes": [
[
1543622400,
107295823
]
]
}
},
"me": {
"metrics": {
"sent_bytes": [
[
1543622400,
13643432427
]
],
"total_bytes": [
[
1543622400,
13644762375
]
],
"backblaze_bytes": [
[
1543622400,
13644762375
]
],
"upstream_bytes": [
[
1543622400,
1329948
]
]
}
},
"na": {
"metrics": {
"sent_bytes": [
[
1543622400,
234004049506
]
],
"total_bytes": [
[
1543622400,
234655863540
]
],
"backblaze_bytes": [
[
1543622400,
234655863540
]
],
"upstream_bytes": [
[
1543622400,
651814034
]
]
}
}
}
},
"4777": {
"region": {
"au": {
"metrics": {
"sent_bytes": [
[
1543622400,
490800672
]
]
}
}
}
}
}
}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.backblaze_bytes- Traffic in bytes from Backblaze origin.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.response_types– Statistics by content type. It returns a number of responses for content with different MIME types.cache_hit_traffic_ratio– Formula: 1 -upstream_bytes/sent_bytes. We deduct the non-cached traffic from the total traffic amount.cache_hit_requests_ratio– Formula:responses_hit/ requests. The share of sending cached content.shield_traffic_ratio– Formula: (shield_bytes-upstream_bytes) /shield_bytes. The efficiency of the Origin Shielding: how much more traffic is sent from the Origin Shielding than from the origin.image_processed- Number of images transformed on the Image optimization service.request_time- Time elapsed between the first bytes of a request were processed and logging after the last bytes were sent to a user.upstream_response_time- Number of milliseconds it took to receive a response from an origin. If upstreamresponse_time_contains several indications for one request (in case of more than 1 origin), we summarize them. In case of aggregating several queries, the average of this amount is calculated.
Metrics upstream_response_time and request_time should be requested separately from other metrics
Output data grouping.
Possible values:
- resource – Data is grouped by CDN resources IDs.
- 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.- protocol - Data is grouped by http protocol version.
To request multiple values, use:
- &
group_by=region&group_by=resource
Names of countries for which data should be displayed. English short name from ISO 3166 standard without the definite article ("the") should be used.
To request multiple values, use:
- &countries=france&countries=denmark
Response
Successful.
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.backblaze_bytes- Traffic in bytes from Backblaze origin.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.response_types– Statistics by content type. It returns a number of responses for content with different MIME types.cache_hit_traffic_ratio– Formula: 1 -upstream_bytes/sent_bytes. We deduct the non-cached traffic from the total traffic amount.cache_hit_requests_ratio– Formula:responses_hit/ requests. The share of sending cached content.shield_traffic_ratio– Formula: (shield_bytes-upstream_bytes) /shield_bytes. The efficiency of the Origin Shielding: how much more traffic is sent from the Origin Shielding than from the origin.image_processed- Number of images transformed on the Image optimization service.request_time- Time elapsed between the first bytes of a request were processed and logging after the last bytes were sent to a user.upstream_response_time- Number of milliseconds it took to receive a response from an origin. If upstreamresponse_time_contains several indications for one request (in case of more than 1 origin), we summarize them. In case of aggregating several queries, the average of this amount is calculated.
Metrics upstream_response_time and request_time should be requested separately from other metrics
Was this page helpful?