Database API
  • Database API
  • Endpoints
  • Authentication
  • Get the database ID
  • Data format
RESOURCES
  • Backups
  • Database Type Versions
  • Databases
  • Logs
  • Maintenance
  • Metrics
    • Get Database Metrics
    • Database Health
  • Instance Status
  • Users
LINKS
  • Addon Provider API
  • One-click Deployment API
  • API V1
  • scalingo.json Schema
  • Main site
  • Dashboard

Metrics

Get Database Metrics

GET https://$DB_API_URL/api/databases/[:database_id]/metrics

Database Metrics

field type description
cpu_usage Percentage (0-100) CPU usage of the database
real_disk_size Bytes Size of the database on disk
memory See Memory Metrics Memory usage of the database
database_stats See Database Stats Database specific metrics
instance_metrics map[instanceID]InstanceMetrics Instance specific metrics

Memory Metrics

field type description
memory_usage Bytes Total RAM bytes used
swap_usage Bytes Total SWAP bytes used
memory_limit Bytes Max memory allocated
swap_limit Bytes Max SWAP allocated
max_memory_usage Bytes highest memory usage recorded
max_swap_usage Bytes highest swap usage recorded

Instances Metrics

field type description
instance_id String ID of the current instance
instance_address String FQDN of the current instance
real_disk_size Bytes Size of the instance on disk
memory See Memory Metrics Memory usage of this instance

Database Stats

The database stats are database dependent

InfluxDB

field type description
data_size Byte Database size as reported by InfluxDB

MongoDB

field type description
collections Integer Collections count
Objects Integer Objects count
avg_obj_size Integer Average size of an object
data_size Bytes Total size of uncompressed data held in this database
storage_size Bytes Total amount of space allocated for document storage
num_extents Integer Number of extends in the database
indexes Integer Count of all the indexes created on every collections
index_size Integer Total size of all indexes created on this database
file_size Integer Total size of the data files that hold the database

MySQL

field type description
data_size Bytes Database size as reported by MySQL
current_connections Integer Count of current opened connections to the database
max_connections Integer maximum simultaneous connections accepted by the database

PostgreSQL

field type description
data_size Bytes Database size as reported by PostgreSQL
current_connections Integer Count of current opened connections to the database
max_connections Integer maximum simultaneous connections accepted by the database

Example request

curl -H "Accent: application/json" \
  -H "Authorization: Bearer $DB_BEARER_TOKEN" \
  -X GET https://$DB_API_URL/api/my-awesome-db-1234/metrics

Returns 200 OK

{
  "cpu_usage": 0,
  "memory": {
    "memory": 156426240,
    "memory_max": 222314496,
    "memory_limit": 536870912,
    "swap": 20480,
    "swap_max": 0,
    "swap_limit": 536870912
  },
  "database_stats": {
    "data_size": 11044896
  },
  "real_disk_size": 37825858,
  "instances_metrics": {
    "9f20c633-3507-4585-8cd0-f9ada91165c0": {
      "instance_id": "9f20c633-3507-4585-8cd0-f9ada91165c0",
      "instance_address": "9f20c633-3507-4585-8cd0-f9ada91165c0.my-awesome-db-1234.influxdb.dbs.scalingo.com:31376",
      "real_disk_size": 37825858,
      "cpu": {
        "usage_in_percents": 0
      },
      "memory": {
        "memory_usage": 156426240,
        "swap_usage": 20480,
        "memory_limit": 536870912,
        "swap_limit": 536870912,
        "max_memory_usage": 222314496,
        "max_swap_usage": 0
      }
    }
  }
}

Database Health

This endpoint is only available for Elasticsearch databases

GET https://$DB_API_URL/api/databases/[:db_id]/health

field type description
epoch Timestamp Timestamp of the reported health status
status String Elasticsearch status (green, yellow, red)
cluster string Name of the cluster
shards integer total shards count

Example request

curl -H "Accent: application/json" \
  -H "Authorization: Bearer $DB_BEARER_TOKEN" \
  -X GET https://$DB_API_URL/api/my-awesome-db-1234/health

Returns 200 OK

{
  "epoch": "1550839427",
  "status": "green",
  "cluster": "my-cluster",
  "shards": "141",
  "pending_tasks": "0"
}