openapi: 3.1.0
info:
  version: "1.0.2"
  title: Time Series API
  description: API covers all operations related to time series.
paths:
  /assets/{assetId}/prometheus/api/v1/query:
    get:
      tags:
        - "Advanced Querying"
      summary: Instant Query
      description: |-
        The instant query endpoint allows you to evaluate an instant query for a specific asset and a given point in time. You provide a PromQL query string that defines the metric or calculation you want to perform. The result of the query will be a single value or a set of values for the specified timestamp.
        
        The response from the instant query endpoint includes the result of the query, which can be of different types such as matrix, vector, scalar, or string. The format of the result depends on the type and may include additional metadata such as labels or timestamps.

        Result types:
        - Matrix: A two-dimensional data structure representing multiple entries per time series data. Enables working with multiple data series simultaneously.
        - Vector: A one-dimensional data structure representing a single entry per time series.
        - Scalar: A single value, typically a number or boolean. Used when the query produces a single aggregated value or a specific metric attribute.
        - String: Text-based information. Used for retrieving metadata, labels, or descriptive information related to a metric.
        
        These result types allow for flexibility in representing and working with different types of data in an instant query. Choose the appropriate result type based on your specific use case to extract the desired information or perform calculations on the returned data.
      operationId: GetQuery
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
        - name: query
          in: query
          description: |-
            [Prometheus expression query string](https://prometheus.io/docs/prometheus/latest/querying/basics/). Example shows machine_insight_cumulative_operating_hours within the past 5 min
          example: "machine_insight_cumulative_operating_hours"
          required: true
          schema:
            type: string
        - name: time
          in: query
          schema:
            $ref: '#/components/schemas/Time'
        - name: timeout
          in: query
          schema:
            $ref: '#/components/schemas/QueryTimeout'
      responses:
        200:
          description: "Success"
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/QueryResponse'
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        422:
          $ref: "#/components/responses/UnprocessableEntityError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"
    post:
      tags:
        - "Advanced Querying"
      summary: Instant Query
      description: |-
        The instant query endpoint allows you to evaluate an instant query for a specific asset and a given point in time. You provide a PromQL query string that defines the metric or calculation you want to perform. The result of the query will be a single value or a set of values for the specified timestamp.
        
        The response from the instant query endpoint includes the result of the query, which can be of different types such as matrix, vector, scalar, or string. The format of the result depends on the type and may include additional metadata such as labels or timestamps.
        
        Result types:
        - Matrix: A two-dimensional data structure representing multiple entries per time series data. Enables working with multiple data series simultaneously.
        - Vector: A one-dimensional data structure representing a single entry per time series.
        - Scalar: A single value, typically a number or boolean. Used when the query produces a single aggregated value or a specific metric attribute.
        - String: Text-based information. Used for retrieving metadata, labels, or descriptive information related to a metric.
        
        These result types allow for flexibility in representing and working with different types of data in an instant query. Choose the appropriate result type based on your specific use case to extract the desired information or perform calculations on the returned data.
      operationId: GetQueryUsingPost
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - query
              properties:
                query:
                  type: string
                  example: "machine_insight_cumulative_operating_hours"
                  description: |-
                    [Prometheus expression query string](https://prometheus.io/docs/prometheus/latest/querying/basics/). Example shows machine_insight_cumulative_operating_hours within the past 5 min
                time:
                  $ref: '#/components/schemas/Time'
                timeout:
                  $ref: '#/components/schemas/QueryTimeout'
      responses:
        200:
          description: "Success"
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/QueryResponse'
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        422:
          $ref: "#/components/responses/UnprocessableEntityError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"

  /assets/{assetId}/prometheus/api/v1/query_range:
    get:
      tags:
        - "Advanced Querying"
      summary: Range Query
      description: |-
        The range query endpoint allows you to perform time series analysis of data within a specified time range.

        Here's a breakdown of how a range query works:

        1. Query Expression: You provide a PromQL (Prometheus Query Language) expression that specifies the metrics, aggregations, or transformations you want to apply to the time series data. This query expression can include metric names, labels, operators, and functions.
        2. Step: The step parameter determines the resolution or interval at which data points are returned within the specified time range. It represents the time duration between consecutive data points in the query result.
        3. Time Range: The range query selects all the data points or time series that fall within the specified time range. The start time and end time of the range are determined based on the time range for which the data is available in the Prometheus time series database.
        4. Data Retrieval: Time Series API retrieves the data points or time series within the defined range from its time series database, considering the specified step interval.
        5. Result Format: The result of the range query is returned in a matrix format. Each data point consists of a timestamp and its corresponding value. The matrix format allows for efficient representation of multiple time series data points over the specified time range.
        
        By adjusting the step parameter, you can control the granularity or level of detail in the returned data. Smaller step values result in more fine-grained data points.
      operationId: GetQueryRange
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
        - name: query
          in: query
          description: "[Prometheus expression query string](https://prometheus.io/docs/prometheus/latest/querying/basics/). Example detects periods of unsafe usage on an asset where payload is above 55% and height is extended above 20%."
          example: "(machine_insights_payload_percentage > bool 55) + (machine_insights_platform_height_percent > bool 20) > bool 1"
          required: true
          schema:
            type: string
        - name: start
          required: true
          in: query
          description: Start timestamp
          example: "2015-06-01T20:10:30.781Z"
          schema:
            type: string
            format: date-time
        - name: end
          required: true
          in: query
          description: End timestamp
          example: "2015-07-01T20:11:00.781Z"
          schema:
            type: string
            format: date-time
        - name: step
          in: query
          description: |-
            Query resolution step width in [```duration``` format](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-durations) or float number of seconds.
          example: "15s"
          schema:
            type: [ "null", "string" ]
            format: duration | float
        - name: timeout
          in: query
          schema:
            $ref: '#/components/schemas/QueryTimeout'
      responses:
        200:
          description: "Success"
          content:
            application/json; charset=utf-8:
              schema:
                $ref: "#/components/schemas/QueryResponse"
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        422:
          $ref: "#/components/responses/UnprocessableEntityError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"
    post:
      tags:
        - "Advanced Querying"
      summary: Range Query
      description: |-
        The range query endpoint allows you to perform time series analysis of data within a specified time range.
        
        Here's a breakdown of how a range query works:
        
        1. Query Expression: You provide a PromQL (Prometheus Query Language) expression that specifies the metrics, aggregations, or transformations you want to apply to the time series data. This query expression can include metric names, labels, operators, and functions.
        2. Step: The step parameter determines the resolution or interval at which data points are returned within the specified time range. It represents the time duration between consecutive data points in the query result.
        3. Time Range: The range query selects all the data points or time series that fall within the specified time range. The start time and end time of the range are determined based on the time range for which the data is available in the Prometheus time series database.
        4. Data Retrieval: Time Series API retrieves the data points or time series within the defined range from its time series database, considering the specified step interval.
        5. Result Format: The result of the range query is returned in a matrix format. Each data point consists of a timestamp and its corresponding value. The matrix format allows for efficient representation of multiple time series data points over the specified time range.
        
        By adjusting the step parameter, you can control the granularity or level of detail in the returned data. Smaller step values result in more fine-grained data points.
      operationId: GetQueryRangeUsingPost
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - query
                - start
                - end
              properties:
                query:
                  type: string
                  description: "[Prometheus expression query string](https://prometheus.io/docs/prometheus/latest/querying/basics/). Example detects periods of unsafe usage on an asset where payload is above 55% and height is extended above 20%."
                  example: "(machine_insights_payload_percentage > bool 55) + (machine_insights_platform_height_percent > bool 20) > bool 1"
                start:
                  type: string
                  format: date-time
                  description: Start timestamp
                  example: "2015-07-01T20:10:51.781Z"
                end:
                  type: string
                  format: date-time
                  description: End timestamp
                  example: "2015-07-01T20:11:00.781Z"
                step:
                  type: [ "null", "string" ]
                  format: duration | float
                  description: |-
                    Query resolution step width in [```duration``` format](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-durations) or float number of seconds.
                  example: "15s"
                timeout:
                  $ref: '#/components/schemas/QueryTimeout'
      responses:
        200:
          description: "Success"
          content:
            application/json; charset=utf-8:
              schema:
                $ref: "#/components/schemas/QueryResponse"
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        422:
          $ref: "#/components/responses/UnprocessableEntityError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"

  /assets/{assetId}/prometheus/api/v1/labels:
    get:
      tags:
        - "Advanced Querying"
      summary: List label names
      operationId: GetListOfLabelNames
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
        - name: match%5B%5D
          in: query
          example: "machine_insight_speed"
          description: >-
            Time-series selector. [See prometheus documentation for more details.](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-series-selectors)
            Metric names containing hyphen (`-`) need to be escaped with `\`, eg. `advanced_sensor_elevated_work_utilization_-_powered` `should be advanced_sensor_elevated_work_utilization_\-_powered.`
          schema:
            type: [ "null", "string" ]
        - name: start
          in: query
          description: Start timestamp
          example: "2015-06-01T20:10:30.781Z"
          schema:
            type: [ "null", "string" ]
            format: date-time
        - name: end
          in: query
          description: End timestamp
          example: "2015-07-01T20:11:00.781Z"
          schema:
            type: [ "null", "string" ]
            format: date-time
      responses:
        200:
          description: "Success"
          content:
            application/json; charset=utf-8:
              schema:
                $ref: "#/components/schemas/LabelsResponse"
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        422:
          $ref: "#/components/responses/UnprocessableEntityError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"
    post:
      tags:
        - "Advanced Querying"
      summary: List label names
      operationId: GetListOfLabelNamesUsingPOST
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                match%5B%5D:
                  type: [ "null", "string" ]
                  description: >-
                    Time-series selector. [See prometheus documentation for more details.](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-series-selectors)
                    Metric names containing hyphen (`-`) need to be escaped with `\`, eg. `advanced_sensor_elevated_work_utilization_-_powered` `should be advanced_sensor_elevated_work_utilization_\-_powered.`
                  example: "machine_insight_speed"
                start:
                  type: [ "null", "string" ]
                  format: date-time
                  description: Start timestamp
                  example: "2015-07-01T20:10:51.781Z"
                end:
                  type: [ "null", "string" ]
                  format: date-time
                  description: End timestamp
                  example: "2015-07-01T20:11:00.781Z"
      responses:
        200:
          description: "Success"
          content:
            application/json; charset=utf-8:
              schema:
                $ref: "#/components/schemas/LabelsResponse"
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        422:
          $ref: "#/components/responses/UnprocessableEntityError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"

  /assets/{assetId}/prometheus/api/v1/series:
    get:
      tags:
        - "Advanced Querying"
      summary: List times series
      operationId: GetListOfTimeSeries
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
        - name: match%5B%5D
          required: true
          in: query
          example: "machine_insight_speed"
          description: >-
            Time-series selector. [See prometheus documentation for more details.](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-series-selectors)
            Metric names containing hyphen (`-`) need to be escaped with `\`, eg. `advanced_sensor_elevated_work_utilization_-_powered` `should be advanced_sensor_elevated_work_utilization_\-_powered.`
          schema:
            type: string
        - name: start
          in: query
          description: Start timestamp
          example: "2015-06-01T20:10:30.781Z"
          schema:
            type: [ "null", "string" ]
            format: date-time
        - name: end
          in: query
          description: End timestamp
          example: "2015-07-01T20:11:00.781Z"
          schema:
            type: [ "null", "string" ]
            format: date-time
      responses:
        200:
          description: "Success"
          content:
            application/json; charset=utf-8:
              schema:
                $ref: "#/components/schemas/TimeSeriesResponse"
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        422:
          $ref: "#/components/responses/UnprocessableEntityError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"
    post:
      tags:
        - "Advanced Querying"
      summary: List times series
      operationId: GetListOfTimeSeriesUsingPOST
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - match%5B%5D
              properties:
                match%5B%5D:
                  type: string
                  description: >-
                    Time-series selector. [See prometheus documentation for more details.](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-series-selectors)
                    Metric names containing hyphen (`-`) need to be escaped with `\`, eg. `advanced_sensor_elevated_work_utilization_-_powered` `should be advanced_sensor_elevated_work_utilization_\-_powered.`
                  example: "machine_insight_speed"
                start:
                  type: [ "null", "string" ]
                  format: date-time
                  description: Start timestamp
                  example: "2015-07-01T20:10:51.781Z"
                end:
                  type: [ "null", "string" ]
                  format: date-time
                  description: End timestamp
                  example: "2015-07-01T20:11:00.781Z"
      responses:
        200:
          description: "Success"
          content:
            application/json; charset=utf-8:
              schema:
                $ref: "#/components/schemas/TimeSeriesResponse"
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        422:
          $ref: "#/components/responses/UnprocessableEntityError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"

  /assets/{assetId}/prometheus/api/v1/label/{labelName}/values:
    get:
      tags:
        - "Advanced Querying"
      summary: List label values
      operationId: GetListOfLabelValues
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
        - name: labelName
          required: true
          in: path
          schema:
            type: string
            example: "sensor_id"
        - name: start
          in: query
          description: Start timestamp
          example: "2015-06-01T20:10:30.781Z"
          schema:
            type: [ "null", "string" ]
            format: date-time
        - name: end
          in: query
          description: End timestamp
          example: "2015-07-01T20:11:00.781Z"
          schema:
            type: [ "null", "string" ]
            format: date-time
        - name: match%5B%5D
          in: query
          example: "machine_insight_speed"
          description: >-
            Time-series selector. [See prometheus documentation for more details.](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-series-selectors)
            Metric names containing hyphen (`-`) need to be escaped with `\`, eg. `advanced_sensor_elevated_work_utilization_-_powered` `should be advanced_sensor_elevated_work_utilization_\-_powered.`
          schema:
            type: [ "null", "string" ]
      responses:
        200:
          description: "Success"
          content:
            application/json; charset=utf-8:
              schema:
                $ref: "#/components/schemas/LabelValuesResponse"
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        422:
          $ref: "#/components/responses/UnprocessableEntityError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"

  /assets/{assetId}/metrics:
    get:
      summary: Get metrics
      tags:
        - "Metrics"
      description: |-
        The metrics endpoint allows you to retrieve metrics as they were ingested. It provides a way to access historical metric data for analysis, debugging, or offline processing.

        To use the metrics endpoint, you construct a request URL with parameters such as the time range and metric filters. The system retrieves the relevant metrics from its database and returns them in JSON format.

        Additionally, if the `Accept-Encoding` header in your request is set to `gzip`, the response will be compressed using gzip encoding. This allows you to reduce the response time and size for efficient data transfer.
      operationId: GetMetrics
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
        - name: start
          required: true
          in: query
          description: Start timestamp
          example: "2015-06-01T20:10:30.781Z"
          schema:
            type: string
            format: date-time
        - name: end
          required: true
          in: query
          description: End timestamp
          example: "2015-07-01T20:11:00.781Z"
          schema:
            type: string
            format: date-time
        - name: match%5B%5D
          required: true
          in: query
          example: "machine_insight_speed"
          description: >-
            Time-series selector. [See prometheus documentation for more details.](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-series-selectors)
            Metric names containing hyphen (`-`) need to be escaped with `\`, eg. `advanced_sensor_elevated_work_utilization_-_powered` `should be advanced_sensor_elevated_work_utilization_\-_powered.`
          schema:
            type: string
      responses:
        200:
          description: "Success. Media type: [application/jsonl](https://jsonlines.org)"
          content:
            application/jsonl; charset=utf-8:
              schema:
                $ref: "#/components/schemas/ExportTimeSeries"
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"

  /assets/{assetId}/metrics/offsets:
    get:
      summary: Get metric offsets
      tags:
        - "Metrics"
      description: |-
        The metric offsets endpoint allows you to retrieve offsets for metrics that have not been incorporated into the metric data. This endpoint will be removed once the offsets have been incorporated directly into the metrics data.
      deprecated: true
      operationId: GetMetricOffsets
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            $ref: "#/components/schemas/AssetId"
      responses:
        200:
          description: "Success"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetMetricOffsetsResponse"
        400:
          $ref: "#/components/responses/BadRequestError"
        401:
          $ref: "#/components/responses/UnauthorizedError"
        403:
          $ref: "#/components/responses/ForbiddenError"
        429:
          $ref: "#/components/responses/RateLimitError"
        500:
          $ref: "#/components/responses/UnexpectedError"
        504:
          $ref: "#/components/responses/UpstreamTimeoutError"

components:
  responses:
    UnexpectedError:
      description: "A server error has occurred"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
    BadRequestError:
      description: "Error when parameters are missing or incorrect"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ExpectedError"
    UnprocessableEntityError:
      description: "Error when processing an expression"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ExpectedError"
    UnauthorizedError:
      description: "Access token is missing or invalid"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ExpectedError"
    ForbiddenError:
      description: "User is not allowed to make this request"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ExpectedError"
    UpstreamTimeoutError:
      description: "Upstream request timeout"
    RateLimitError:
      description: "Rate limit exceeded"

  schemas:
    Error:
      type: object
      properties:
        status:
          type: integer
          format: int32
          description: "HTTP status code"
          example: "400"
        message:
          type: string
          description: "Technical error description (not for end user)"
          example: "Something went wrong"

    ExpectedError:
      type: object
      allOf:
        - $ref: "#/components/schemas/Error"
      properties:
        code:
          type: string
          description: "Code identifying the error"
          example: "error_code"

    VectorData:
      type: object
      properties:
        resultType:
          type: string
        result:
          $ref: '#/components/schemas/VectorResult'
      description: |-
        Vector: A one-dimensional data structure representing a single entry per time series.

    MatrixData:
      type: object
      properties:
        resultType:
          type: string
        result:
          $ref: '#/components/schemas/MatrixResult'
      description: |-
        Matrix: A two-dimensional data structure representing multiple entries per time series data. Enables working with multiple data series simultaneously.

    ScalarData:
      type: object
      properties:
        resultType:
          type: string
        result:
          $ref: '#/components/schemas/ScalarResult'
      description: |-
        Scalar: A single value, typically a number or boolean. Used when the query produces a single aggregated value or a specific metric attribute.

    StringData:
      type: object
      properties:
        resultType:
          type: string
        result:
          $ref: '#/components/schemas/StringResult'
      description: |-
        String: Text-based information. Used for retrieving metadata, labels, or descriptive information related to a metric.

    QueryResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
          description: Prometheus-style status. Errors are mapped into the Trackunit error format therefore status will always be success.
        data:
          oneOf:
            - $ref: '#/components/schemas/MatrixData'
            - $ref: '#/components/schemas/VectorData'
            - $ref: '#/components/schemas/ScalarData'
            - $ref: '#/components/schemas/StringData'
          discriminator:
            propertyName: resultType
            mapping:
              matrix: '#/components/schemas/MatrixData'
              vector: '#/components/schemas/VectorData'
              scalar: '#/components/schemas/ScalarData'
              string: '#/components/schemas/StringData'
        warnings:
          type: array
          items:
            type: string
          description: Warnings, which occurred while executing the request. There will still be data in the data field.

    LabelsResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
          description: Prometheus-style status. Errors are mapped into the Trackunit error format therefore status will always be success.
        data:
          type: array
          items:
            type: string
          description: List of labels
          example:
            [ "__name__", "version", "asset_id" ]
        warnings:
          type: array
          items:
            type: string
          description: Warnings, which occurred while executing the request. There will still be data in the data field.

    LabelValuesResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
          description: Prometheus-style status. Errors are mapped into the Trackunit error format therefore status will always be success.
        data:
          type: array
          items:
            type: string
          description: List of labels
          example:
            [ "variable_13032" ]
        warnings:
          type: array
          items:
            type: string
          description: Warnings, which occurred while executing the request. There will still be data in the data field.

    TimeSeriesResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
          description: Prometheus-style status. Errors are mapped into the Trackunit error format therefore status will always be success.
        data:
          type: array
          items:
            $ref: "#/components/schemas/Labels"
        warnings:
          type: array
          items:
            type: string
          description: Warnings, which occurred while executing the request. There will still be data in the data field.

    ExportTimeSeries:
      type: object
      properties:
        metric:
          $ref: "#/components/schemas/Labels"
        values:
          type: array
          items:
            type: number
          example:
            [
              1,
              1,
              0,
              0
            ]
        timestamps:
          type: array
          items:
            type: integer
            format: "int64"
          example:
            [
              1647784185753,
              1647939385272,
              1648022507307,
              1648359388835
            ]

    Labels:
      type: object
      additionalProperties:
        type: string
      example:
        __name__: "machine_insight_cumulative_operating_hours"
        asset_id: "eeba6427-3c44-4691-8e74-446403db8867"
        version: "1"
    AssetId:
      type: string
      format: uuid
      description: "Identifier for an asset"
      example: "eeba6427-3c44-4691-8e74-446403db8867"

    MatrixResult:
      type: array
      items:
        $ref: '#/components/schemas/MatrixEntry'
    MatrixEntry:
      type: object
      properties:
        metric:
          $ref: '#/components/schemas/Labels'
        values:
          type: array
          items:
            $ref: '#/components/schemas/Value'
          example:
            [
              [ 1682415206, "0.21" ],
              [ 1682417206,"0.23" ]
            ]
    VectorResult:
      type: array
      items:
        $ref: '#/components/schemas/VectorEntry'
    VectorEntry:
      type: object
      properties:
        metric:
          $ref: '#/components/schemas/Labels'
        value:
          $ref: '#/components/schemas/Value'
          example: [ 1435781451.781, "1" ]

    Value:
      type: array
      prefixItems:
        - type: integer
          description: timestamp
        - type: string
          description: value
      minItems: 2
      maxItems: 2

    ScalarResult:
      $ref: '#/components/schemas/Value'
      example:
        [
          1682415206,
          "0.21"
        ]

    StringResult:
      $ref: '#/components/schemas/Value'
      example:
        [
          1682415206,
          "string_value"
        ]
    QueryTimeout:
      type: [ "null", "string" ]
      format: duration
      description: Query evaluation timeout defined by [```duration``` format](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-durations). Defaults to and is capped by 10 seconds. Requests can be queued up to 10 seconds prior to evaluation, which does not affect query evaluation timeout period.
      example: "5s"

    Time:
      type: [ "null", "string" ]
      format: date-time
      description: |-
        Evaluation timestamp. Optional.

        The current server time is used if the ```time``` parameter is omitted.
      example: "2015-07-01T20:10:51.781Z"

    GetMetricOffsetsResponse:
      type: object
      properties:
        offsets:
          type: array
          items:
            $ref: "#/components/schemas/MetricOffset"

    MetricOffset:
      type: object
      properties:
        metricName:
          type: string
          example: "machine_insight_cumulative_operating_hours"
        offset:
          type: number
          example: 652.3
  securitySchemes:
    authorizationBearer:
      type: "http"
      scheme: "bearer"
      bearerFormat: "JWT"
security:
  - authorizationBearer: [ ]
servers:
  - description: Endpoint for API users
    url: https://iris.trackunit.com/api/time-series/v1