Check out our free eBook: "Best Practices for Optimizing Postgres Query Performance"Download Now

addServer - Add a server to pganalyze Enterprise Edition

Use case

This API is only supported for pganalyze Enterprise Edition running on-premise, and is used to configure the pganalyze container for connecting to your database servers.

For registering new servers to the hosted service you can simply use an organization-wide collector key and follow the regular installation steps (no API call necessary).

API

Arguments for addServer:

  • name (String)
    Display name for the server in pganalyze (optional)
  • dbHost (String)
    Hostname of the database server
  • dbPort (Integer)
    Port of the database server (optional, defaults to 5432)
  • dbUsername (String)
    Username for the database server
  • dbPassword (String)
    Password for the database server (optional)
  • dbName (String)
    Database name to connect to
  • dbSslmode (String)
    Postgres SSL mode to be used when connecting (optional, defaults to prefer)
  • awsRegion (String)
    For Amazon RDS: Region the database runs in (optional)
  • awsDbInstanceId (String)
    For Amazon RDS: Instance ID of the database server (optional)
  • enableLogs (Boolean)
    For Amazon RDS: Determines whether log collection is enabled (optional, defaults to false)
  • enableActivity (Boolean)
    Determines whether activity snapshots for Connection Tracing and Vacuum Monitoring are enabled (optional, defaults to false)
  • collectAllDatabases (Boolean)
    Determines whether statistics are collected for all databases on the server (optional, defaults to false)

Fields returned:

  • server (ServerType)
    Server that was just created using this endpoint (null if an error occurred)

    • humanId (String)
      Public "human" ID that can be used to refer to this server in URLs and API calls
  • errors (Array of String)
    Errors that occurred during creation of the server (if any)

Example

mutation {
  addServer(dbHost: "my-database.internal", dbUsername: "postgres", dbName: "postgres", enableActivity: true) {
    errors
    server {
      humanId
    }
  }
}
curl -XPOST -H 'Authorization: Token XXXXXXX' -F 'query=mutation { addServer(dbHost: "my-database.internal", dbUsername: "postgres", dbName: "postgres", enableActivity: true) { server { humanId }, errors } }' https://pganalyze.internal/graphql
{
  "data": {
    "addServer": {
      "server": {
        "humanId": "bdp4m73ysjgefke7i2dgkenzi4"
      },
      "errors": []
    }
  }
}

You can view the new server by constructing the URL like this:

pganalyze_base_url = 'https://demo.pganalyze.com' # Use your internal hostname for pganalyze
server_human_id = 'bdp4m73ysjgefke7i2dgkenzi4' # Take this from the API response `humanId` field
url = pganalyze_base_url + '/servers/' + server_human_id
# => https://demo.pganalyze.com/servers/bdp4m73ysjgefke7i2dgkenzi4

Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →