Tower Stats API

The Stats API from Tower — 2 operation(s) for stats.

OpenAPI Specification

tower-stats-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  contact:
    email: hello@tower.dev
    name: Tower Computing GmbH
    url: https://tower.dev
  description: REST API to interact with Tower Services.
  termsOfService: https://tower.dev/terms
  title: Tower Accounts Stats API
  version: v0.11.16
servers:
- url: https://api.tower.dev/v1
tags:
- name: Stats
paths:
  /stats/apps:
    get:
      description: Generates current statistics about apps
      operationId: generate-app-statistics
      parameters:
      - description: The environment to filter the statistics by. If not provided, statistics for all environments will be returned.
        explode: false
        in: query
        name: environment
        schema:
          description: The environment to filter the statistics by. If not provided, statistics for all environments will be returned.
          type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateAppStatisticsResponse'
          description: OK
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorModel'
          description: Error
      security:
      - AccessTokenAuth:
        - apps:read
      - APIKeyAuth:
        - apps:read
      summary: Generate app statistics
      tags:
      - Stats
  /stats/runs:
    get:
      description: Generates statistics about runs over a specified time period.
      operationId: generate-run-statistics
      parameters:
      - description: Filter runs by status(es). Define multiple with a comma-separated list. Supplying none will return all statuses.
        explode: false
        in: query
        name: status
        schema:
          default:
          - pending
          - starting
          - running
          - crashed
          - errored
          - exited
          - cancelled
          - retrying
          description: Filter runs by status(es). Define multiple with a comma-separated list. Supplying none will return all statuses.
          items:
            enum:
            - pending
            - starting
            - running
            - crashed
            - errored
            - exited
            - cancelled
            - retrying
            type: string
          type: array
      - description: Start date and time for statistics (inclusive)
        explode: false
        in: query
        name: start_at
        required: true
        schema:
          description: Start date and time for statistics (inclusive)
          format: date-time
          type: string
      - description: End date and time for statistics (inclusive)
        explode: false
        in: query
        name: end_at
        required: true
        schema:
          description: End date and time for statistics (inclusive)
          format: date-time
          type: string
      - description: Timezone for the statistics (e.g., 'Europe/Berlin'). Defaults to UTC.
        explode: false
        in: query
        name: timezone
        schema:
          default: UTC
          description: Timezone for the statistics (e.g., 'Europe/Berlin'). Defaults to UTC.
          type: string
      - description: Filter runs by environment. If not provided, all environments will be included.
        explode: false
        in: query
        name: environment
        schema:
          description: Filter runs by environment. If not provided, all environments will be included.
          type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateRunStatisticsResponse'
          description: OK
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorModel'
          description: Error
      security:
      - AccessTokenAuth:
        - runs:read
      - APIKeyAuth:
        - runs:read
      summary: Generate run statistics
      x-shoulder-tap-events:
      - runs.*
      - statistics.updated
      tags:
      - Stats
components:
  schemas:
    RunTimeseriesPoint:
      additionalProperties: false
      properties:
        cancelled:
          format: int64
          type: integer
        crashed:
          format: int64
          type: integer
        errored:
          format: int64
          type: integer
        exited:
          format: int64
          type: integer
        pending:
          format: int64
          type: integer
        period:
          description: The period of the timeseries point, typically the start of the period.
          format: date-time
          type: string
        retrying:
          format: int64
          type: integer
        running:
          format: int64
          type: integer
        scheduled:
          format: int64
          type: integer
        starting:
          format: int64
          type: integer
      required:
      - period
      - scheduled
      - retrying
      - pending
      - starting
      - running
      - exited
      - errored
      - crashed
      - cancelled
      type: object
    StatisticsSettings:
      additionalProperties: false
      properties:
        end_at:
          description: The end time for the statistics period.
          format: date-time
          type: string
        environment:
          description: The environment to get statistics for.
          type: string
        interval:
          description: The interval for the statistics period.
          enum:
          - daily
          - hourly
          type: string
        start_at:
          description: The start time for the statistics period.
          format: date-time
          type: string
        timezone:
          description: The time zone for the statistics period.
          type: string
      required:
      - interval
      - timezone
      - start_at
      - end_at
      - environment
      type: object
    GenerateRunStatisticsResponse:
      additionalProperties: false
      properties:
        $schema:
          description: A URL to the JSON Schema for this object.
          examples:
          - https://api.tower.dev/v1/schemas/GenerateRunStatisticsResponse.json
          format: uri
          readOnly: true
          type: string
        series:
          items:
            $ref: '#/components/schemas/RunTimeseriesPoint'
          type: array
        settings:
          $ref: '#/components/schemas/StatisticsSettings'
        stats:
          $ref: '#/components/schemas/RunStatistics'
      required:
      - settings
      - stats
      - series
      type: object
    ErrorModel:
      additionalProperties: false
      properties:
        $schema:
          description: A URL to the JSON Schema for this object.
          examples:
          - https://api.tower.dev/v1/schemas/ErrorModel.json
          format: uri
          readOnly: true
          type: string
        detail:
          description: A human-readable explanation specific to this occurrence of the problem.
          examples:
          - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
        instance:
          description: A URI reference that identifies the specific occurrence of the problem.
          examples:
          - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
          - 400
          format: int64
          type: integer
        title:
          description: A short, human-readable summary of the problem type. This value should not change between occurrences of the error.
          examples:
          - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
          - https://example.com/errors/example
          format: uri
          type: string
      type: object
    GenerateAppStatisticsResponse:
      additionalProperties: false
      properties:
        $schema:
          description: A URL to the JSON Schema for this object.
          examples:
          - https://api.tower.dev/v1/schemas/GenerateAppStatisticsResponse.json
          format: uri
          readOnly: true
          type: string
        statistics:
          $ref: '#/components/schemas/AppStatistics'
      required:
      - statistics
      type: object
    RunStatistics:
      additionalProperties: false
      properties:
        cancelled_runs:
          format: int64
          type: integer
        crashed_runs:
          format: int64
          type: integer
        errored_runs:
          format: int64
          type: integer
        exited_runs:
          format: int64
          type: integer
        running_runs:
          format: int64
          type: integer
        total_runs:
          format: int64
          type: integer
      required:
      - running_runs
      - exited_runs
      - errored_runs
      - crashed_runs
      - cancelled_runs
      - total_runs
      type: object
    AppStatistics:
      additionalProperties: false
      properties:
        all_apps:
          format: int64
          type: integer
        disabled_apps:
          format: int64
          type: integer
        healthy_apps:
          format: int64
          type: integer
        running_apps:
          format: int64
          type: integer
      required:
      - all_apps
      - healthy_apps
      - running_apps
      - disabled_apps
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
  securitySchemes:
    APIKeyAuth:
      description: API key created by a Tower user or Tower service account to authenticate an API request.
      in: header
      name: X-API-Key
      type: apiKey
    AccessTokenAuth:
      description: Access token authentication scheme which uses an access token provided by the Tower API as part of a Tower session (see documentation about creating sessions).
      scheme: Bearer
      type: http