This API allows users to execute SELECT queries on a PostgreSQL database and returns the results in JSON format. It accepts input in JSON format and returns a JSON response with the query results.
GET /swaggerThis endpoint serves the Swagger UI documentation for the API. It provides an interactive interface for users to explore and test the available API endpoints, including the ability to execute queries, view results, and understand the structure of requests and responses.
POST /db/custom-queryThis endpoint accepts a POST request to execute a SELECT query on the PostgreSQL database.
The request body must be a JSON object containing the following fields:
dsn (string, required): The Data Source Name (DSN) for connecting to the PostgreSQL database. Example: "postgres://[user]:[password]@[host]/[database]".query (string, required): The SELECT query to execute on the database.{
"dsn": "postgres://user:password@localhost:5432/dbname",
"query": "SELECT id, name FROM users;"
}
curl -X POST http://localhost:8080/db/custom-query \
-H "Content-Type: application/json" \
-d '{
"dsn": "postgres://user:password@localhost:5432/dbname",
"query": "SELECT id, name FROM users;"
}'
POST /db/long-running-queriesThis endpoint executes a SELECT query on a pg_stat_activity to retrieve information about long-running queries. It allows you to dynamically specify parameters such as query duration, database, and state of the queries you want to monitor.
The request body must be a JSON object containing the following fields:
dsn (string, required): The Data Source Name (DSN) for connecting to the PostgreSQL database. Example: "postgres://[user]:[password]@[host]/[database]".query_duration (string, required): The duration for filtering long-running queries. Only queries that have been running longer than this duration will be considered.pg_database (string, required): The name of the database.query_state (string, required): The state of the query (e.g., "active", "idle", "idle in transaction"). You can use "*" to include all states.{
"dsn": "postgres://user:password@localhost:5432/dbname",
"query_duration": "5 second",
"pg_database": "dbname",
"query_state": "*"
}
curl -X POST http://localhost:8080/db/long-running-queries \
-H "Content-Type: application/json" \
-d '{
"dsn": "postgres://user:password@localhost:5432/dbname",
"query_duration": "5 second",
"pg_database": "dbname",
"query_state": "*"
}'
POST /db/largest-tablesThis endpoint executes a SELECT query on a pg_statio_user_tables to retrieve information about the largest tables.
The request body must be a JSON object containing the following fields:
dsn (string, required): The Data Source Name (DSN) for connecting to the PostgreSQL database. Example: "postgres://[user]:[password]@[host]/[database]".query_limit (integer, required): The maximum number of results to return. Must be between 1 and 100.{
"dsn": "postgres://user:password@localhost:5432/dbname",
"query_limit": 10
}
curl -X POST http://localhost:8080/db/largest-tables \
-H "Content-Type: application/json" \
-d '{
"dsn": "postgres://user:password@localhost:5432/dbname",
"query_limit": 10
}'
Content type
Image
Digest
sha256:b9e683082…
Size
27.7 MB
Last updated
almost 2 years ago
docker pull id69tver/go-pg-mon