diff --git a/src/Models/LoadBalancers/LoadBalancer.php b/src/Models/LoadBalancers/LoadBalancer.php index b893004a..53a44285 100644 --- a/src/Models/LoadBalancers/LoadBalancer.php +++ b/src/Models/LoadBalancers/LoadBalancer.php @@ -434,6 +434,23 @@ public function deleteService(int $listenPort): ?APIResponse return null; } + /** + * Get Metrics for specified Load Balancer. + * @see https://docs.hetzner.cloud/#load-balancer-actions-delete-service + * @throws APIException|GuzzleException + */ + public function metrics(string $type, string $start, string $end, ?int $step = null): ?APIResponse + { + $response = $this->httpClient->get($this->replaceServerIdInUri('load_balancers/{id}/metrics?') . http_build_query(compact('type', 'start', 'end', 'step'))); + if (!HetznerAPIClient::hasError($response)) { + return APIResponse::create([ + 'metrics' => json_decode((string)$response->getBody())->metrics, + ], $response->getHeaders()); + } + + return null; + } + /** * Detaches a Load Balancer from a network. *