SweetConnect LogoSweetConnect
ApiDatabus metrics

Stream machine metrics (states, logs, aggregated) over a time window

Streams real-time or historical metrics for a machine over time window using Server-Sent Events.

Metrics may include: states, logs and aggregated metrics.

Events are emitted with event databus.metrics.{type}, where type can be state, log or aggregated

Access restricted to roles:

  • admin
  • manufacturer-admin
  • manufacturer-user
  • producer-admin
  • producer-user
GET
/v1/metrics/stream
AuthorizationBearer <token>

In: header

Query Parameters

machineId*string

UUID of the machine to query states for

Formatuuid
metric?string

Metric name to stream (optional)

aggregation?string

Aggregation type to apply to state values.

Value in"none" | "min" | "max" | "mean"
startDate?unknown

Start of time window in UTC timezone. Accepted formats:

  - ISO 8601 (e.g. "2025-06-10T10:07:13Z
  - Duration (e.g. "-3d", "1h). Accepted units are: m (minutes), h (hours), d (days), w (weeks)
  - Unix timestamp in milliseconds (e.g. 1752503444666)
  - Special: "now"
  
  Defaults to "-15m" if not provided.
endDate?unknown

End of time window in UTC timezone. Accepted formats:

  - ISO 8601 (e.g. "2025-06-14T23:59:59Z")
  - Duration (e.g. "-1h", "3d")
  - Unix timestamp in milliseconds (e.g. 1721068799000)
  - Special: "now"
  
  Defaults to "now" if not provided.

Response Body

text/event-stream

text/event-stream

text/event-stream

text/event-stream

text/event-stream

curl -X GET "https://test.sweetconnect.io/api/databus/v1/metrics/stream?machineId=9488c561-749f-4b3d-8c2f-30e867ba66db"
"event: databus.metrics.state\nid: 1e28a798-3f1b-4f6d-bc88-d5a2a7b4c3e1\nretry: 15000\ndata: {\"type\":\"state\",\"time\":\"2025-06-14T09:15:10.685Z\",\"value\":\"Aborted\",...}\n"
{
  "errors": [
    {
      "errorCode": "RequestValidationError",
      "message": "The 'username' field is required.",
      "extension": {
        "type": "body",
        "key": "username"
      }
    }
  ]
}
{
  "errors": [
    {
      "errorCode": "Unauthorized",
      "message": "Authentication is required to access this resource.",
      "extension": {}
    }
  ]
}
{
  "errors": [
    {
      "errorCode": "NoPermission",
      "message": "You do not have permission to access this resource.",
      "extension": {}
    }
  ]
}
{
  "errors": [
    {
      "errorCode": "NotFound",
      "message": "The requested resource was not found.",
      "extension": {}
    }
  ]
}