Admin API (v1)

http://localhost:8081

Table of contents

/admin

POST /admin/importSQL

Uploads a file and saves it to a directory configured on the server

POST /admin/importSQL
Body

Media type: application/octet-stream

Type: any

Response 200

Saved

Headers
  • Location: required (string)

    URI to the created <> item

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

"unable to add <<resourcePathName|!singularize>>"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

PUT /admin/loglevel

Set logging level for all loggers in the JVM or just for a specific package / class

PUT /admin/loglevel
Query Parameters
  • level: required (one of SEVERE, WARNING, INFO, FINE, FINER, FINEST - default: INFO)

    The log level to set the module's log to

  • java_package: (string - default: *)

    The package / class to set the logging level to, defaults to all packages

Response 200

Returns packages with log level of the updated packages

Body

Media type: application/json

Type: any

Example:

{"package" : "log level" , "package2" : "log level"}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/loglevel

Get the logging level for all loggers in the JVM

GET /admin/loglevel

Response 200

Returns packages with log level

Body

Media type: application/json

Type: any

Example:

{"package" : "log level" , "package2" : "log level"}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

PUT /admin/jstack

dumps jstacks every N seconds to a jstack file to find potential bottlenecks. Looking at this | file you can see if there are functions blocking for too long

PUT /admin/jstack

Response 204

Jstack request successful

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/jstack

Get stack trace

GET /admin/jstack

Response 200

Returns the stack trace of all threads in the JVM

Body

Media type: text/html

Type: any

Example:

Text.....

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/memory

Get JVM memory info

GET /admin/memory
Query Parameters
  • history: (boolean - default: false)

    Whether to save returned values into a least recently inserted cache. | Every call to the API after calling with history=true will return results from up | to the previous 100 calls to this API

Response 200

Returns JVM memory info

Body

Media type: text/html

Type: any

Example:

Text.....

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

POST /admin/postgres_maintenance

run one of the following maintenance jobs on the Postgres DB. | analyze, vacuum, vacuum analyze, vacuum verbose

POST /admin/postgres_maintenance
Query Parameters
  • table: required (string)

    Table name to run command on

  • command: (one of ANALYZE, VACUUM, VACUUM_ANALYZE, VACUUM_VERBOSE - default: ANALYZE)

    The command to run

Response 201

Command requested successful

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/postgres_active_sessions

Get active PostgreSQL sessions

GET /admin/postgres_active_sessions
Query Parameters
  • dbname: required (string - default: postgres)

    Database name to retrieve info for

Response 200

Returns active sessions with the following information. | process ID of the currently connected user to the database. | name of the database to which the user is currently connected. | the full text of the SQL query that is being executed by the client. | etc...

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/postgres_load

Get load information on PostgreSQL

GET /admin/postgres_load
Query Parameters
  • dbname: required (string - default: postgres)

    Database name to retrieve info for

Response 200

Returns load with the following information. | Number of active connections. | Number of rollbacks and commits issued. | Number of blocks read ( block = an 8kb segment information the file storing the table. ). | Number of buffer hits (cache) | Note that the function calls SELECT pg_stat_reset(); to clear stats, waits 10 seconds, and | then returns with the info collected during those 10 seconds

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/postgres_table_access_stats

Get access stats on the PostgreSQL tables

GET /admin/postgres_table_access_stats

Response 200

Returns info about how the tables are being accessed either sequential or index scans

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/postgres_table_size

amount of disk usage for a specific database and its associated tables and indexes.

GET /admin/postgres_table_size
Query Parameters
  • dbname: required (string - default: postgres)

    Database name to retrieve info for

Response 200

Returns info for every table in format - table | table size | index size

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/table_index_usage

table index usage rates per table

GET /admin/table_index_usage

Response 200

Returns index usage info for every table

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/cache_hit_rates

cache hit rates

GET /admin/cache_hit_rates

Response 200

cache hit rates

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/slow_queries

Check for currently running queries that have been executing longer than X seconds

GET /admin/slow_queries
Query Parameters
  • querytimerunning: required (integer)

    time a query should be running for it to be considered slow

Response 200

List of slow queries

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/total_db_size

Returns the size of the entire database for example, db_size = 711 MB

GET /admin/total_db_size
Query Parameters
  • dbname: required (string - default: postgres)

    Database name to retrieve info for

Response 200

Returns the size of the entire database

Body

Media type: application/json

Type: any

Example:

{"db_size" : "711 MB"}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/db_cache_summary

Returns a list of the tables / indexes in the shared_buffers (cache) and their size. This is | an expensive API from a DB resource perspective and should not run frequently (every few hours should suffice)

GET /admin/db_cache_summary

Response 200

Returns a list of the tables / indexes in the shared_buffers

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/list_locking_queries

Returns a list of queries in transactions that are blocking other queries. The result includes the blocking query, the query being blocked, and their pids

GET /admin/list_locking_queries
Query Parameters
  • dbname: required (string - default: postgres)

    Database name to retrieve info for

Response 200

Body

Media type: application/json

Type: any

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

DELETE /admin/kill_query

Stops a query from running based on its PID using the pg_terminate_backend command

DELETE /admin/kill_query
Query Parameters
  • pid: required (string)

    PID of a query

Response 204

Query terminated successfully

Response 404

PID not found

Body

Media type: text/plain

Type: any

Example:

"<<resourcePathName|!singularize>> not found"

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

PUT /admin/postgres_drop_indexes

Drop indexes, useful before a large batch load, tenantid will be used to select the correct schema to use

PUT /admin/postgres_drop_indexes

Response 204

Indexes dropped

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

"No indexes to delete"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

PUT /admin/postgres_create_indexes

Create indexes, useful if prior to a large batch load the indexes were dropped, tenantid will be used to select the correct schema to use

PUT /admin/postgres_create_indexes

Response 204

Indexes created

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

"example message"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

POST /admin/set_AES_key

Sets the AES secret key that the postgres config file password was encrypted with. The key will only be checked | when the configuration file is read in and the DB connection is created

POST /admin/set_AES_key
Query Parameters
  • key: required (string)

    Secret key to use to decrypt the password of the postgres-configuration file

Response 204

Secret key set

POST /admin/get_password

The API takes the secret key passed in and the x-okapi-tenant header and returns the DB password generated for | that tenant's schema

POST /admin/get_password
Query Parameters
  • key: required (string)

    Secret key to use to decrypt the password of the postgres-configuration file

Response 200

returned password

Body

Media type: text/plain

Type: any

Example:

as35235+df+df/ggr

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

"unable to add <<resourcePathName|!singularize>>"

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/health

The API returns 200 if service is up and responding. Should be overridden | by individual services that want to actually run some business logic to determine health.

GET /admin/health

Response 200

Body

Media type: any/any

Type: any

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

""

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /admin/module_stats

The API returns service specific statistics. Should be overridden | by individual services that run a set of business logic functions / gather stats and return.

GET /admin/module_stats

Response 200

returned status

Body

Media type: text/plain

Type: any

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

""

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator