# Network › Load Balancer › Metrics API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Network product's sections: https://developers.eu.ovhcloud.com/reference/network/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 3 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/network/load-balancer/metrics/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/network/load-balancer/metrics.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/network/load-balancer/metrics.json?format=openapi3

## Operations

- `GET /ipLoadbalancing/{serviceName}/metricsToken` — Get the metrics token and endpoint
- `GET /ipLoadbalancing/{serviceName}/status` — Get the global status
- `GET /ipLoadbalancing/{serviceName}/instancesState` — Get the effective state of instances

## Get the metrics token and endpoint

`GET /1.0/ipLoadbalancing/{serviceName}/metricsToken`

Link: https://developers.eu.ovhcloud.com/reference/network/load-balancer/metrics/#get-iploadbalancing-servicename-metricstoken

**Status:** Stable production version  
**IAM actions:** `loadbalancer:apiovh:metricsToken/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | The internal name of your IP load balancing |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | ipLoadbalancing.MetricsToken | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `endpoint` | string |  | The metrics endpoint |
| `token` | string (password) |  | The metrics token |

```json
{
  "endpoint": "string",
  "token": "string"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/ipLoadbalancing/{serviceName}/metricsToken" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/ipLoadbalancing/{serviceName}/metricsToken")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/ipLoadbalancing/{serviceName}/metricsToken");

print_r($result);
?>
```

## Get the global status

`GET /1.0/ipLoadbalancing/{serviceName}/status`

Link: https://developers.eu.ovhcloud.com/reference/network/load-balancer/metrics/#get-iploadbalancing-servicename-status

**Status:** Stable production version  
**IAM actions:** `loadbalancer:apiovh:status/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | The internal name of your IP load balancing |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | ipLoadbalancing.Status | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `farms` | ipLoadbalancing.status.Component |  | The Load Balancer farms status informations |
| `farms.status` | ipLoadbalancing.status.ComponentStatus |  | The global status of your Load Balancer component |
| `farms.status.error` | integer |  | The number of component with status error |
| `farms.status.ok` | integer |  | The number of component with status ok |
| `farms.status.unknown` | integer |  | The number of component with status unknown |
| `farms.status.warn` | integer |  | The number of component with status warn |
| `farms.total` | integer |  | The Load Balancer total component count |
| `frontends` | ipLoadbalancing.status.Component |  | The Load Balancer frontends status informations |
| `frontends.status` | ipLoadbalancing.status.ComponentStatus |  | The global status of your Load Balancer component |
| `frontends.status.error` | integer |  | The number of component with status error |
| `frontends.status.ok` | integer |  | The number of component with status ok |
| `frontends.status.unknown` | integer |  | The number of component with status unknown |
| `frontends.status.warn` | integer |  | The number of component with status warn |
| `frontends.total` | integer |  | The Load Balancer total component count |
| `servers` | ipLoadbalancing.status.Component |  | The Load Balancer servers status informations |
| `servers.status` | ipLoadbalancing.status.ComponentStatus |  | The global status of your Load Balancer component |
| `servers.status.error` | integer |  | The number of component with status error |
| `servers.status.ok` | integer |  | The number of component with status ok |
| `servers.status.unknown` | integer |  | The number of component with status unknown |
| `servers.status.warn` | integer |  | The number of component with status warn |
| `servers.total` | integer |  | The Load Balancer total component count |
| `service` | ipLoadbalancing.status.Service |  | The Load Balancer service status informations |
| `service.status` | ipLoadbalancing.status.Enum |  | The status of your Load Balancer billing domain — one of `error`, `ok`, `unknown`, `warn` |

```json
{
  "farms": {
    "status": {
      "error": 0,
      "ok": 0,
      "unknown": 0,
      "warn": 0
    },
    "total": 0
  },
  "frontends": {
    "status": {
      "error": 0,
      "ok": 0,
      "unknown": 0,
      "warn": 0
    },
    "total": 0
  },
  "servers": {
    "status": {
      "error": 0,
      "ok": 0,
      "unknown": 0,
      "warn": 0
    },
    "total": 0
  },
  "service": {
    "status": "error"
  }
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/ipLoadbalancing/{serviceName}/status" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/ipLoadbalancing/{serviceName}/status")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/ipLoadbalancing/{serviceName}/status");

print_r($result);
?>
```

## Get the effective state of instances

`GET /1.0/ipLoadbalancing/{serviceName}/instancesState`

Link: https://developers.eu.ovhcloud.com/reference/network/load-balancer/metrics/#get-iploadbalancing-servicename-instancesstate

**Status:** Deprecated, will be removed  
**Deprecated** since 2018-09-17, removed on 2018-10-17.  
**IAM actions:** `loadbalancer:apiovh:instancesState/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | The internal name of your IP load balancing |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | ipLoadbalancing.InstancesState[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `internalId` | integer |  | Internal ID of this IPLB instance |
| `lastUpdateDate` | string (date-time) |  | Last update date |
| `state` | string |  | Current state of this IPLB instance |
| `zone` | string |  | zone of this IPLB instance |

```json
[
  {
    "internalId": 0,
    "lastUpdateDate": "2024-01-01T12:00:00Z",
    "state": "string",
    "zone": "string"
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/ipLoadbalancing/{serviceName}/instancesState" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/ipLoadbalancing/{serviceName}/instancesState")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/ipLoadbalancing/{serviceName}/instancesState");

print_r($result);
?>
```
