AsyncMetrics
Bases: AsyncBaseRoute
A class for interacting with the Outline VPN server's metrics API asynchronously.
Provides methods to check whether metrics collection is enabled, toggle it, retrieve per-key data transfer statistics, and fetch detailed experimental server metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
management_url
|
str
|
The management URL used to communicate with the Outline server API. |
required |
ssl_verify
|
bool
|
Flag to enable or disable SSL certificate verification. Default is False. |
False
|
Source code in outline_vpn_api_client/async_client.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
change_enabled_state(state=False)
async
Enables or disables the sharing of metrics on the Outline VPN server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
bool
|
True to enable metrics sharing, False to disable. Default is False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the metrics sharing state was successfully updated. |
Raises:
| Type | Description |
|---|---|
ResponseNotOkException
|
If the server response indicates an error (status code >= 300). |
Source code in outline_vpn_api_client/async_client.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
check_enabled()
async
Returns whether metrics collection is enabled on the Outline VPN server.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if metrics collection is enabled, False otherwise. |
Raises:
| Type | Description |
|---|---|
ResponseNotOkException
|
If the server response indicates an error (status code >= 300). |
Source code in outline_vpn_api_client/async_client.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
get_data_transfer()
async
Returns the data transferred per access key on the Outline VPN server.
Returns:
| Type | Description |
|---|---|
BytesTransferredByUserId
|
models.BytesTransferredByUserId: Data transfer information for each access key. |
Raises:
| Type | Description |
|---|---|
ResponseNotOkException
|
If the server response indicates an error (status code >= 300). |
Source code in outline_vpn_api_client/async_client.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
get_server_metrics(since)
async
Returns detailed server metrics including tunnel time, data transferred, bandwidth, locations, and per-access-key statistics.
This is an experimental endpoint (GET /experimental/server/metrics).
Note: the endpoint and its response format may change in future server versions.
!!! warning "Experimental endpoint"
This method uses GET /experimental/server/metrics, which is an unstable
endpoint. Its availability and response format may change or break across
different Outline server versions. Use with caution in production.
Note
This endpoint requires metrics sharing to be enabled on the server
(client.metrics.change_enabled_state(True)). It will return an error
if metrics are disabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
since
|
datetime
|
The start of the time range for which to return metrics. |
required |
Returns:
| Type | Description |
|---|---|
ServerMetrics
|
models.ServerMetrics: Detailed server and per-key metrics. |
Raises:
| Type | Description |
|---|---|
ResponseNotOkException
|
If the server response indicates an error (status code >= 300). |
Example
from datetime import datetime, timezone, timedelta
metrics = await client.metrics.get_server_metrics(
since=datetime.now(timezone.utc) - timedelta(days=30)
)
print(metrics.server.dataTransferred.bytes)
Source code in outline_vpn_api_client/async_client.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
Note on get_server_metrics
The get_server_metrics method uses the GET /experimental/server/metrics endpoint,
which is experimental and may be unstable or unavailable depending on your Outline
server version.
Requirements:
- Metrics sharing must be enabled:
await client.metrics.change_enabled_state(True) - The endpoint behavior and response format may change without notice in future server releases