Skip to content

Commit

Permalink
add endpoints for app metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mdanzinger committed Oct 13, 2023
1 parent 5296e9e commit f29740a
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 0 deletions.
12 changes: 12 additions & 0 deletions specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,18 @@ paths:
get:
$ref: 'resources/monitoring/monitoring_get_dropletMemoryAvailableMetrics.yml'

/v2/monitoring/metrics/apps/memory_percentage:
get:
$ref: 'resources/monitoring/monitoring_get_appMemoryPercentageMetrics.yml'

/v2/monitoring/metrics/apps/cpu_percentage:
get:
$ref: 'resources/monitoring/monitoring_get_appCPUPercentageMetrics.yml'

/v2/monitoring/metrics/apps/restart_count:
get:
$ref: 'resources/monitoring/monitoring_get_appRestartCountMetrics.yml'

/v2/projects:
get:
$ref: 'resources/projects/projects_list.yml'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/monitoring/metrics/apps/cpu_percentage?app_id=2db3c021-15ad-4088-bfe8-99dc972b9cf6&component_id=sample-application&start=1636051668&end=1636051668"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/monitoring/metrics/apps/memory_percentage?app_id=2db3c021-15ad-4088-bfe8-99dc972b9cf6&component_id=sample-application&start=1636051668&end=1636051668"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/monitoring/metrics/apps/restart_count?app_id=2db3c021-15ad-4088-bfe8-99dc972b9cf6&component_id=sample-application&start=1636051668&end=1636051668"
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
operationId: monitoring_get_appCPUPercentageMetrics

summary: Get App CPU Percentage Metrics

description: >-
To retrieve cpu percentage metrics for a given app, send a GET request to `/v2/monitoring/metrics/apps/cpu_percentage`.
tags:
- Monitoring

responses:
'200':
$ref: 'responses/app_metric_response.yml'

'401':
$ref: '../../shared/responses/unauthorized.yml'

'429':
$ref: '../../shared/responses/too_many_requests.yml'

'500':
$ref: '../../shared/responses/server_error.yml'

default:
$ref: '../../shared/responses/unexpected_error.yml'


parameters:
- $ref: 'parameters.yml#/app_id'
- $ref: 'parameters.yml#/component_id'
- $ref: 'parameters.yml#/metric_timestamp_start'
- $ref: 'parameters.yml#/metric_timestamp_end'

x-codeSamples:
- $ref: 'examples/curl/monitoring_get_appCPUPercentageMetrics.yml'

security:
- bearer_auth:
- 'read'

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
operationId: monitoring_get_appMemoryPercentageMetrics

summary: Get App Memory Percentage Metrics

description: >-
To retrieve memory percentage metrics for a given app, send a GET request to `/v2/monitoring/metrics/apps/memory_percentage`.
tags:
- Monitoring

responses:
'200':
$ref: 'responses/app_metric_response.yml'

'401':
$ref: '../../shared/responses/unauthorized.yml'

'429':
$ref: '../../shared/responses/too_many_requests.yml'

'500':
$ref: '../../shared/responses/server_error.yml'

default:
$ref: '../../shared/responses/unexpected_error.yml'


parameters:
- $ref: 'parameters.yml#/app_id'
- $ref: 'parameters.yml#/component_id'
- $ref: 'parameters.yml#/metric_timestamp_start'
- $ref: 'parameters.yml#/metric_timestamp_end'

x-codeSamples:
- $ref: 'examples/curl/monitoring_get_appMemoryPercentageMetrics.yml'

security:
- bearer_auth:
- 'read'

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
operationId: monitoring_get_appRestartCountMetrics.yml

summary: Get App Restart Count Metrics

description: >-
To retrieve restart count metrics for a given app, send a GET request to `/v2/monitoring/metrics/apps/restart_count`.
tags:
- Monitoring

responses:
'200':
$ref: 'responses/app_metric_response.yml'

'401':
$ref: '../../shared/responses/unauthorized.yml'

'429':
$ref: '../../shared/responses/too_many_requests.yml'

'500':
$ref: '../../shared/responses/server_error.yml'

default:
$ref: '../../shared/responses/unexpected_error.yml'


parameters:
- $ref: 'parameters.yml#/app_id'
- $ref: 'parameters.yml#/component_id'
- $ref: 'parameters.yml#/metric_timestamp_start'
- $ref: 'parameters.yml#/metric_timestamp_end'

x-codeSamples:
- $ref: 'examples/curl/monitoring_get_appRestartCountMetrics.yml'

security:
- bearer_auth:
- 'read'

18 changes: 18 additions & 0 deletions specification/resources/monitoring/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ droplet_id:
schema:
type: string

app_id:
in: query
name: app_id
description: The App UUID.
example: "2db3c021-15ad-4088-bfe8-99dc972b9cf6"
required: true
schema:
type: string

component_id:
in: query
name: component_id
description: The App's component ID.
example: "sample-application"
required: true
schema:
type: string

network_interface:
in: query
name: interface
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
description: The response will be a JSON object with a key called `data` and `status`.

headers:
ratelimit-limit:
$ref: '../../../shared/headers.yml#/ratelimit-limit'
ratelimit-remaining:
$ref: '../../../shared/headers.yml#/ratelimit-remaining'
ratelimit-reset:
$ref: '../../../shared/headers.yml#/ratelimit-reset'

content:
application/json:
schema:
$ref: '../models/metrics.yml'

examples:
Memory:
$ref: './examples.yml#/app_memory_percentage'

20 changes: 20 additions & 0 deletions specification/resources/monitoring/responses/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,23 @@ droplet_filesystem:
- '25832407040'
- - 1635387120
- '25832407040'

app_memory_percentage:
value:
status: success
data:
resultType: matrix
result:
- metric:
app_component: sample-application
app_component_instance: sample-application-0
app_uuid: 'db3c021-15ad-4088-bfe8-99dc972b9cf6'
values:
- - 1634052360
- '5.016600450090265357'
- - 1634052480
- '12.015085955677299055'
- - 1634052600
- '8.014941163855322308'
- - 1634052720
- '32.016214285714285712'

0 comments on commit f29740a

Please sign in to comment.