> ## Documentation Index
> Fetch the complete documentation index at: https://ubicloud.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get PostgreSQL database logs



## OpenAPI

````yaml /api-reference/openapi.yml get /project/{project_id}/location/{location}/postgres/{postgres_database_reference}/logs
openapi: 3.0.3
info:
  description: API for managing resources on Ubicloud
  title: Clover API
  version: 0.1.0
  contact:
    url: https://www.ubicloud.com/
    email: support@ubicloud.com
  license:
    name: GNU Affero General Public License v3.0 (AGPL-3.0)
    url: https://www.gnu.org/licenses/agpl-3.0.en.html
servers:
  - url: https://api.ubicloud.com
security:
  - BearerAuth: []
tags:
  - description: Firewall Operations
    name: Firewall
  - description: Firewall Rule Operations
    name: Firewall Rule
  - description: Inference API Key Operations
    name: Inference Api Key
  - description: Inference Endpoint Operations
    name: Inference Endpoint
  - description: Load Balancer Operations
    name: Load Balancer
  - description: Login Operations
    name: Login
  - description: Machine Image Operations
    name: Machine Image
  - description: Postgres Database Operations
    name: Postgres Database
  - description: Postgres Firewall Rule Operations
    name: Postgres Firewall Rule
  - description: Postgres Metric Destination
    name: Postgres Metric Destination
  - description: Postgres Log Destination
    name: Postgres Log Destination
  - description: Private Subnet Operations
    name: Private Subnet
  - description: Project Operations
    name: Project
  - description: Virtual Machine Operations
    name: Virtual Machine
  - description: Private Location Operations
    name: Private Location
  - description: Kubernetes Cluster Operations
    name: Kubernetes Cluster
  - description: SSH Public Key Operations
    name: SSH Public Key
  - description: GitHub Operations
    name: GitHub
  - description: Audit Log Operations
    name: Audit Log
paths:
  /project/{project_id}/location/{location}/postgres/{postgres_database_reference}/logs:
    parameters:
      - $ref: '#/components/parameters/location'
      - $ref: '#/components/parameters/postgres_database_reference'
      - $ref: '#/components/parameters/project_id'
    get:
      tags:
        - Postgres Database
      summary: Get PostgreSQL database logs
      operationId: getPostgresDatabaseLogs
      parameters:
        - name: start
          in: query
          description: Start time for log query (rfc3339 format, default 30 minutes ago)
          required: false
          schema:
            type: string
            example: '2025-05-12T11:27:24.000Z'
        - name: end
          in: query
          description: End time for log query (rfc3339 format, default now)
          required: false
          schema:
            type: string
            example: '2025-05-12T11:57:24.000Z'
        - name: stream_name
          in: query
          description: Filter by log stream (postgres, pgbouncer, or upgrade)
          required: false
          schema:
            type: string
            example: postgres
            enum:
              - postgres
              - pgbouncer
              - upgrade
        - name: severity_level
          in: query
          description: Filter by log severity level
          required: false
          schema:
            type: string
            example: INFO
            enum:
              - DEBUG
              - INFO
              - WARN
              - ERROR
              - FATAL
        - name: server_role
          in: query
          description: Filter by server role (primary or standby)
          required: false
          schema:
            type: string
            example: primary
            enum:
              - primary
              - standby
        - name: query_pattern
          in: query
          description: Pattern for substring match against log message body
          required: false
          schema:
            type: string
        - name: max_log_lines
          in: query
          description: Number of log lines to return (default 50, max 500)
          required: false
          schema:
            type: integer
            default: 50
        - name: pagination_key
          in: query
          description: Pagination key returned from a previous response
          required: false
          schema:
            type: string
            pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
      responses:
        '200':
          $ref: '#/components/responses/PostgresDatabaseLogs'
        default:
          $ref: '#/components/responses/Error'
components:
  parameters:
    location:
      description: The Ubicloud location/region
      in: path
      name: location
      required: true
      schema:
        type: string
        example: eu-central-h1
    postgres_database_reference:
      description: Postgres database ID or name
      examples:
        id:
          value: pgn30gjk1d1e2jj34v9x0dq4rp
        name:
          value: postgres-database-name
      in: path
      name: postgres_database_reference
      required: true
      schema:
        $ref: '#/components/schemas/Reference'
    project_id:
      description: ID of the project
      in: path
      name: project_id
      required: true
      schema:
        type: string
        example: pjkkmx0f2vke4h36nk9cm8v8q0
        pattern: ^pj[0-9a-hj-km-np-tv-z]{24}$
  responses:
    PostgresDatabaseLogs:
      description: Log entries for a Postgres Database
      content:
        application/json:
          schema:
            type: object
            properties:
              logs:
                type: array
                items:
                  $ref: '#/components/schemas/PostgresDatabaseLogEntry'
              pagination_key:
                description: Pass as pagination_key to retrieve the next page of results
                type: string
                pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
            additionalProperties: false
            required:
              - logs
    Error:
      description: An error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Reference:
      description: Resource ID or name
      type: string
      pattern: ^[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?$
    PostgresDatabaseLogEntry:
      type: object
      properties:
        timestamp:
          description: Log entry timestamp in RFC 3339 format
          type: string
          format: date-time
        stream_name:
          type: string
          enum:
            - postgres
            - pgbouncer
            - upgrade
        severity_level:
          description: Log severity level
          type: string
          enum:
            - DEBUG
            - INFO
            - WARN
            - ERROR
            - FATAL
        message:
          description: Log message body
          type: string
        server_ubid:
          description: UBID of the server that produced this log entry
          type: string
          pattern: ^pv[0-9a-hj-km-np-tv-z]{24}$
        server_role:
          type: string
          enum:
            - primary
            - standby
        context:
          description: >-
            Additional context fields parsed from the log entry (e.g.
            remote_host_port, dbname, pid, user)
          type: object
          additionalProperties:
            type: string
      additionalProperties: false
      required:
        - timestamp
        - stream_name
        - severity_level
        - message
        - server_ubid
        - server_role
    Error:
      type: object
      properties:
        error:
          type: object
          additionalProperties: false
          properties:
            code:
              type: integer
              example: 401
            message:
              type: string
              example: There was an error logging in
            type:
              type: string
              example: InvalidCredentials
            details:
              type: object
              nullable: true
          required:
            - code
            - message
            - type
      additionalProperties: false
      required:
        - error
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````