Observability settings API reference
HTTP routes that read and write the observability settings of a CosmicAC deployment, with request bodies, responses, and status codes.
These routes read and write the observability settings of a CosmicAC deployment. The settings hold the base URLs of the Prometheus and Loki that CosmicAC queries. Each route lists its request, response, and errors.
In every path, <cosmicac-url> is the base URL of your deployment. Caddy serves these routes under /api and proxies them to cosmicac-app-node.
To set the same values from the web interface, see Connect CosmicAC to your Prometheus and Loki.
Endpoints
| Method | Path | Route |
|---|---|---|
GET | /api/v1/observability-settings | Get observability settings |
PUT | /api/v1/observability-settings | Update observability settings |
DELETE | /api/v1/observability-settings | Clear observability settings |
Authentication
Every route requires an administrator account. CosmicAC reads the session token from the ttr-token header.
ttr-token: <session-token>CosmicAC binds a token to the IP address that requested it, and rejects that token from any other host.
A default deployment runs without authentication
The --noauth true argument in .env.example turns off authentication for cosmicac-app-node. Every request to these routes gets administrator access. See Deployment configuration.
Get observability settings
Returns the Prometheus and Loki URLs the deployment stores.
HTTP request
GET <cosmicac-url>/api/v1/observability-settingsResponse
{
"prometheus_url": "http://prometheus:9090",
"loki_url": "http://loki:3100"
}| Field | Type | Description |
|---|---|---|
prometheus_url | string | Base URL of your Prometheus, or null when the deployment has none. |
loki_url | string | Base URL of your Loki, or null when the deployment has none. |
A field that you clear with an empty string returns "" rather than null.
Errors
Failed requests return the status text and a message.
{
"statusCode": 403,
"error": "Forbidden",
"message": "ERR_PERMISSION_REQUIRED"
}| Field | Type | Description |
|---|---|---|
statusCode | integer | Repeats the HTTP status code. |
error | string | Names the status text for that code. |
message | string | Identifies the error, such as ERR_AUTH_FAIL. |
The route returns these status codes.
| Status | Meaning |
|---|---|
401 | The request omits the ttr-token header, or the token doesn't resolve. The message is ERR_AUTH_FAIL. |
403 | The account isn't an administrator. The message is ERR_PERMISSION_REQUIRED. |
500 | CosmicAC couldn't read the stored settings. The message is Failed to read observability settings. |
Update observability settings
Sets the Prometheus URL, the Loki URL, or both. CosmicAC stores the values, then pushes both settings to cosmicac-wrk-monitor.
HTTP request
PUT <cosmicac-url>/api/v1/observability-settingsRequest body
{
"prometheus_url": "http://prometheus:9090",
"loki_url": "http://loki:3100"
}| Field | Type | Required | Description |
|---|---|---|---|
prometheus_url | string | No | Base URL of your Prometheus. |
loki_url | string | No | Base URL of your Loki. |
The body must contain at least one of the two fields, and each value must be a valid URI. CosmicAC writes only the fields in the request, so an omitted field keeps its stored value. An empty string clears the field that carries it, and a null fails validation.
Response
Returns the full settings after the write.
{
"prometheus_url": "http://prometheus:9090",
"loki_url": "http://loki:3100"
}| Field | Type | Description |
|---|---|---|
prometheus_url | string | Base URL of your Prometheus, or null when the deployment has none. |
loki_url | string | Base URL of your Loki, or null when the deployment has none. |
A 200 confirms only that CosmicAC stored the values, not that cosmicac-wrk-monitor received them. The push to the monitor runs separately and never changes the response, so it can fail without an error. CosmicAC skips the push when the deployment omits monitorService.rpcPublicKey.
Errors
A request that fails validation returns the field that CosmicAC rejected.
{
"error": "Validation failed",
"details": [
{
"field": "prometheus_url",
"message": "\"prometheus_url\" must be a valid uri"
}
]
}| Field | Type | Description |
|---|---|---|
error | string | Always Validation failed. |
details | array | Holds one entry per rejected field. |
details[].field | string | Names the rejected field. |
details[].message | string | Explains why the value failed. |
Every other failure returns the status text and a message.
{
"statusCode": 403,
"error": "Forbidden",
"message": "ERR_PERMISSION_REQUIRED"
}| Field | Type | Description |
|---|---|---|
statusCode | integer | Repeats the HTTP status code. |
error | string | Names the status text for that code. |
message | string | Identifies the error, such as ERR_AUTH_FAIL. |
The route returns these status codes.
| Status | Meaning |
|---|---|
400 | The body contains no recognized field, carries an unknown field, or holds a value that isn't a valid URI or that exceeds 2048 characters. |
401 | The request omits the ttr-token header, or the token doesn't resolve. The message is ERR_AUTH_FAIL. |
403 | The account isn't an administrator. The message is ERR_PERMISSION_REQUIRED. |
500 | CosmicAC couldn't write the settings, or couldn't read them back after the write. The message is Failed to persist observability settings or Failed to read observability settings. A failure on the second write leaves the first one applied. |
Clear observability settings
Clears both URLs. CosmicAC stores the change, then pushes both settings to cosmicac-wrk-monitor.
HTTP request
DELETE <cosmicac-url>/api/v1/observability-settingsResponse
{
"prometheus_url": null,
"loki_url": null
}| Field | Type | Description |
|---|---|---|
prometheus_url | string | Base URL of your Prometheus, or null when the deployment has none. |
loki_url | string | Base URL of your Loki, or null when the deployment has none. |
The route is idempotent. Clearing settings that CosmicAC never stored returns 200 with both fields null.
Clearing loki_url stops CosmicAC from pushing log lines to Loki. Clearing prometheus_url stops CosmicAC from querying Prometheus for job metrics. Neither change stops your Prometheus from scraping CosmicAC, because you configure that scrape in Prometheus.
Errors
Failed requests return the status text and a message.
{
"statusCode": 403,
"error": "Forbidden",
"message": "ERR_PERMISSION_REQUIRED"
}| Field | Type | Description |
|---|---|---|
statusCode | integer | Repeats the HTTP status code. |
error | string | Names the status text for that code. |
message | string | Identifies the error, such as ERR_AUTH_FAIL. |
The route returns these status codes.
| Status | Meaning |
|---|---|
401 | The request omits the ttr-token header, or the token doesn't resolve. The message is ERR_AUTH_FAIL. |
403 | The account isn't an administrator. The message is ERR_PERMISSION_REQUIRED. |
500 | CosmicAC couldn't clear the settings, or couldn't read them back after the delete. The message is Failed to clear observability settings or Failed to read observability settings. |