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
)
page = client.cdn.logs.list(
from_="from",
to="to",
)
page = page.data[0]
print(page.resource_id)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"),
)
page, err := client.CDN.Logs.List(context.TODO(), cdn.LogListParams{
From: "from",
To: "to",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
curl --request GET \
--url https://api.gcore.com/cdn/advanced/v1/logs \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cdn/advanced/v1/logs', 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/advanced/v1/logs",
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/advanced/v1/logs")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/advanced/v1/logs")
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{
"data": [
{
"timestamp": 1633914371,
"client_ip": "192.0.2.10",
"cname": "cdn.example.com",
"resource_id": 100,
"path": "/awesome-site",
"method": "GET",
"user_agent": "Mozilla/5.0 (compatible; MSIE 6.0; Windows 95; Trident/3.1)",
"status": 200,
"size": 17340162,
"cache_status": "HIT",
"datacenter": "m9",
"referer": "https://www.example.com/",
"sent_http_content_type": "image/jpeg",
"tcpinfo_rtt": 70
}
],
"meta": {
"count": 129874732
}
}Log viewer
Get CDN logs
Get CDN logs for up to 3 days starting today.
You can filter logs using query parameters by client IP, CDN resource, date, path and etc.
To filter the CDN logs by 2xx status codes, use:
- &
status__gte=200&status__lt=300
GET
/
cdn
/
advanced
/
v1
/
logs
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
)
page = client.cdn.logs.list(
from_="from",
to="to",
)
page = page.data[0]
print(page.resource_id)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"),
)
page, err := client.CDN.Logs.List(context.TODO(), cdn.LogListParams{
From: "from",
To: "to",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
curl --request GET \
--url https://api.gcore.com/cdn/advanced/v1/logs \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cdn/advanced/v1/logs', 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/advanced/v1/logs",
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/advanced/v1/logs")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/advanced/v1/logs")
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{
"data": [
{
"timestamp": 1633914371,
"client_ip": "192.0.2.10",
"cname": "cdn.example.com",
"resource_id": 100,
"path": "/awesome-site",
"method": "GET",
"user_agent": "Mozilla/5.0 (compatible; MSIE 6.0; Windows 95; Trident/3.1)",
"status": 200,
"size": 17340162,
"cache_status": "HIT",
"datacenter": "m9",
"referer": "https://www.example.com/",
"sent_http_content_type": "image/jpeg",
"tcpinfo_rtt": 70
}
],
"meta": {
"count": 129874732
}
}Authorizations
Query Parameters
Sorting rules.
Possible values:
- method - Request HTTP method.
client_ip- IP address of the client who sent the request.- status - Status code in the response.
- size - Response size in bytes.
- cname - Custom domain of the requested resource.
resource_id- ID of the requested CDN resource.cache_status- Caching status.- datacenter - Data center where request was processed.
- timestamp - Date and time when the request was made.
Parameter may have multiple values separated by a comma.
By default, ascending sorting is applied. To sort in descending order, add '-' prefix.
Example:
- &ordering=-timestamp,status
Was this page helpful?