addServer - Add a server to pganalyze Enterprise Server

Use case

This API is only supported for pganalyze Enterprise Server when utilizing the collector inside the central installation, and is used to configure the connections 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).

This API requires a read-write API key.

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)
  • dbUseIamAuth (String)
    For Amazon RDS: Whether to use AWS IAM authentication (optional)
  • awsRegion (String)
    For Amazon RDS: Region the database runs in (optional)
  • awsDbInstanceId (String)
    For Amazon RDS: Instance ID of the database instance (optional)
  • awsDbClusterId (String)
    For Amazon RDS: Cluster ID of the Aurora Cluster (optional)
  • awsAssumeRole (String)
    For Amazon RDS: IAM role to be assumed for AWS API access (optional)
  • enableLogs (Boolean)
    Determines whether log collection is enabled (optional, defaults to false, works with Amazon RDS and self-managed servers)
  • 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

GraphQL mutation:

mutation {
  addServer(dbHost: "my-database.internal", dbUsername: "postgres", dbName: "postgres", enableActivity: true) {
    errors
    server {
      humanId
    }
  }
}

Using curl, replace pganalyze.internal with the hostname or IP of your pganalyze installation:

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://pganalyze.internal' # 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://pganalyze.internal/servers/bdp4m73ysjgefke7i2dgkenzi4

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