Skip to content

Servers::getMetrics

Danny Li edited this page Feb 4, 2018 · 1 revision

Get metrics for specified server.

Metrics are available for the last 30 days only.

If you do not provide the step argument the API will automatically adjust it so that a maximum of 100 samples are returned.

The API limits the number of samples returned to a maximum of 500 and will adjust the step parameter accordingly.

Parameters

Parameter Type Description Optional Default
$id int Server ID No -
$start int/string Start of period to get metrics for (can be UNIX timestamp or date string) No -
$end int/string End of period to get metrics for (can be UNIX timestamp or date string) No -
$types array Type of metrics to get (cpu, disk, network) No array('cpu', 'disk', 'network')
$step int/null Resolution of results in seconds. If you do not provide the step argument the API will automatically adjust it so that a maximum of 100 samples are returned. Yes null

Returns

object

Hetzner Cloud documentation:

For more information about the metrics object, please read the official documentation.

Example

<?php
use Exploriment\HetznerCloud;

// retrieve the metrics of the past hour
$metrics = HetznerCloud\Servers::getMetrics(1, time() - 3600, time());

var_dump($metrics);
Clone this wiki locally