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
)
metrics_list = client.cloud.instances.metrics.list(
instance_id="instance_id",
project_id=0,
region_id=0,
time_interval=6,
time_unit="hour",
)
print(metrics_list.count)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cloud"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
metricsList, err := client.Cloud.Instances.Metrics.List(
context.TODO(),
"instance_id",
cloud.InstanceMetricListParams{
ProjectID: gcore.Int(0),
RegionID: gcore.Int(0),
TimeInterval: 6,
TimeUnit: cloud.InstanceMetricsTimeUnitHour,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", metricsList.Count)
}curl --request POST \
--url https://api.gcore.com/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"time_interval": 6
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({time_interval: 6})
};
fetch('https://api.gcore.com/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics', 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/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'time_interval' => 6
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.gcore.com/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"time_interval\": 6\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"time_interval\": 6\n}"
response = http.request(request)
puts response.read_body{
"count": 1,
"results": [
{
"time": "2020-07-07T12:57:00Z",
"cpu_util": 8,
"disks": [
{
"disk_Bps_read": 16384,
"disk_Bps_write": 86016,
"disk_iops_read": 3,
"disk_iops_write": 12,
"disk_name": "sda"
},
{
"disk_Bps_read": 163840,
"disk_Bps_write": 860160,
"disk_iops_read": 30,
"disk_iops_write": 120,
"disk_name": "sdb"
}
],
"memory_util": 33.28411162695459,
"network_Bps_egress": 102,
"network_Bps_ingress": 102,
"network_pps_egress": 0.7,
"network_pps_ingress": 0.7
}
]
}Instances
Get instance metrics
Get instance metrics, including cpu, memory, network and disk metrics
POST
/
cloud
/
v1
/
instances
/
{project_id}
/
{region_id}
/
{instance_id}
/
metrics
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
)
metrics_list = client.cloud.instances.metrics.list(
instance_id="instance_id",
project_id=0,
region_id=0,
time_interval=6,
time_unit="hour",
)
print(metrics_list.count)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cloud"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
metricsList, err := client.Cloud.Instances.Metrics.List(
context.TODO(),
"instance_id",
cloud.InstanceMetricListParams{
ProjectID: gcore.Int(0),
RegionID: gcore.Int(0),
TimeInterval: 6,
TimeUnit: cloud.InstanceMetricsTimeUnitHour,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", metricsList.Count)
}curl --request POST \
--url https://api.gcore.com/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"time_interval": 6
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({time_interval: 6})
};
fetch('https://api.gcore.com/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics', 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/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'time_interval' => 6
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.gcore.com/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"time_interval\": 6\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/instances/{project_id}/{region_id}/{instance_id}/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"time_interval\": 6\n}"
response = http.request(request)
puts response.read_body{
"count": 1,
"results": [
{
"time": "2020-07-07T12:57:00Z",
"cpu_util": 8,
"disks": [
{
"disk_Bps_read": 16384,
"disk_Bps_write": 86016,
"disk_iops_read": 3,
"disk_iops_write": 12,
"disk_name": "sda"
},
{
"disk_Bps_read": 163840,
"disk_Bps_write": 860160,
"disk_iops_read": 30,
"disk_iops_write": 120,
"disk_name": "sdb"
}
],
"memory_util": 33.28411162695459,
"network_Bps_egress": 102,
"network_Bps_ingress": 102,
"network_pps_egress": 0.7,
"network_pps_ingress": 0.7
}
]
}Authorizations
API key for authentication. Make sure to include the word apikey, followed by a single space and then your token.
Example: apikey 1234$abcdef
Path Parameters
Project ID
Region ID
Instance ID
Body
application/json
Time range and time unit, required to obtain instance metrics. Available intervals are 1h, 6h, 24h, 7 days, 14 days. Time delta in the results is fixed and depends on the time range: 1h - 15 seconds, 6h - 20 seconds, 24h - 2 minutes, 7 days - 10 minutes, 14 days - 20 minutes.
Was this page helpful?
⌘I