Zum Hauptinhalt springen

Get a usage-metrics breakdown for a project

GET/v2/projects/{projectId}/usage-metrics/breakdown
API-Version
v2
Request-Methode
GET
Operation-ID
project-get-usage-metrics-breakdown

Request​

  • projectIdstring (uuid)required

    ID of the project whose usage-metrics breakdown is retrieved.

Responses​

Format
application/json
Beschreibung

Usage-metrics breakdown for the project

  • appsArray von objectrequired

    Usage of all apps relative to the applicable limit.

    • Array[
      • *object
        • labelsobjectrequired

          Prometheus labels identifying the series, e.g. project, stack, container, database_type or database_version; empty for an aggregated series.

          • *string
        • samplesArray von objectrequired
          • Array[
            • *object
              • timestring (date-time)required
              • valuenumberrequired
            ]
      ]
  • containersArray von objectrequired

    Usage per container relative to the applicable limit, labelled with stack and container.

    • Array[
      • *object
        • labelsobjectrequired

          Prometheus labels identifying the series, e.g. project, stack, container, database_type or database_version; empty for an aggregated series.

          • *string
        • samplesArray von objectrequired
          • Array[
            • *object
              • timestring (date-time)required
              • valuenumberrequired
            ]
      ]
  • databasesArray von objectrequired

    Usage of all databases relative to the applicable limit; empty for projects on a dedicated server or proSpace lite.

    • Array[
      • *object
        • labelsobjectrequired

          Prometheus labels identifying the series, e.g. project, stack, container, database_type or database_version; empty for an aggregated series.

          • *string
        • samplesArray von objectrequired
          • Array[
            • *object
              • timestring (date-time)required
              • valuenumberrequired
            ]
      ]
Content-Type: application/json

{
"apps": [
{
"labels": {
"project": "p-XXXXXX"
},
"samples": [
{
"time": "2026-11-10T12:00:00.000Z",
"value": 0.42
}
]
}
],
"containers": [
{
"labels": {
"project": "p-XXXXXX"
},
"samples": [
{
"time": "2026-11-10T12:00:00.000Z",
"value": 0.42
}
]
}
],
"databases": [
{
"labels": {
"project": "p-XXXXXX"
},
"samples": [
{
"time": "2026-11-10T12:00:00.000Z",
"value": 0.42
}
]
}
]
}
{
"properties": {
"apps": {
"description": "Usage of all apps relative to the applicable limit.",
"items": {
"properties": {
"labels": {
"additionalProperties": {
"type": "string"
},
"description": "Prometheus labels identifying the series, e.g. `project`, `stack`, `container`, `database_type` or `database_version`; empty for an aggregated series.",
"example": {
"project": "p-XXXXXX"
},
"type": "object"
},
"samples": {
"items": {
"properties": {
"time": {
"example": "2026-11-10T12:00:00.000Z",
"format": "date-time",
"type": "string"
},
"value": {
"example": 0.42,
"type": "number"
}
},
"required": [
"time",
"value"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"labels",
"samples"
],
"type": "object"
},
"type": "array"
},
"containers": {
"description": "Usage per container relative to the applicable limit, labelled with `stack` and `container`.",
"items": {
"properties": {
"labels": {
"additionalProperties": {
"type": "string"
},
"description": "Prometheus labels identifying the series, e.g. `project`, `stack`, `container`, `database_type` or `database_version`; empty for an aggregated series.",
"example": {
"project": "p-XXXXXX"
},
"type": "object"
},
"samples": {
"items": {
"properties": {
"time": {
"example": "2026-11-10T12:00:00.000Z",
"format": "date-time",
"type": "string"
},
"value": {
"example": 0.42,
"type": "number"
}
},
"required": [
"time",
"value"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"labels",
"samples"
],
"type": "object"
},
"type": "array"
},
"databases": {
"description": "Usage of all databases relative to the applicable limit; empty for projects on a dedicated server or proSpace lite.",
"items": {
"properties": {
"labels": {
"additionalProperties": {
"type": "string"
},
"description": "Prometheus labels identifying the series, e.g. `project`, `stack`, `container`, `database_type` or `database_version`; empty for an aggregated series.",
"example": {
"project": "p-XXXXXX"
},
"type": "object"
},
"samples": {
"items": {
"properties": {
"time": {
"example": "2026-11-10T12:00:00.000Z",
"format": "date-time",
"type": "string"
},
"value": {
"example": 0.42,
"type": "number"
}
},
"required": [
"time",
"value"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"labels",
"samples"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"containers",
"apps",
"databases"
],
"type": "object"
}

Nutzungsbeispiele​

$ curl \
--fail \
--location \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
https://api.mittwald.de/v2/projects/f0f86186-0a5a-45b2-aa33-502777496347/usage-metrics/breakdown?metric=cpu&from=1985-10-26T01%3A21%3A00.000Z&to=1985-10-26T01%3A21%3A00.000Z
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";

const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.project.getUsageMetricsBreakdown({
"projectId": "f0f86186-0a5a-45b2-aa33-502777496347",
"queryParameters": {
"metric": "cpu",
"from": "1985-10-26T01:21:00.000Z",
"to": "1985-10-26T01:21:00.000Z"
}
});

assertStatus(response, 200);

use \Mittwald\ApiClient\Generated\V2\Clients\Project\GetUsageMetricsBreakdown\GetUsageMetricsBreakdownRequest;

$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));

$request = (new GetUsageMetricsBreakdownRequest(
projectId: "f0f86186-0a5a-45b2-aa33-502777496347"
))
->withMetric("cpu")
->withFrom("1985-10-26T01:21:00.000Z")
->withTo("1985-10-26T01:21:00.000Z");
$response = $client->project()->getUsageMetricsBreakdown($request);

var_dump($response->getBody();

Auf dieser Seite