Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions docs/configuration/exporting/exporting-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,125 @@ If there is an error in processing the request, the API will return the followin
}

- **Status Code**: Varies based on the error (e.g., `400 Bad Request`, `500 Internal Server Error`).

.. _namespaces-resources-api:

POST https://api.robusta.dev/api/namespaces/resources
------------------------------------------------------

Use this endpoint to retrieve an **active count of specific Kubernetes resources** within a namespace. This is the same data displayed in the **Namespaces** tab of the Robusta UI.

You can specify exactly which resource kinds you want to query in the request.

This API relies on resource types configured in the Robusta UI sink.
Make sure to configure them as described in :ref:`cb-robusta-ui-sink-namespace-config`.

Request Body Schema
^^^^^^^^^^^^^^^^^^^

The request body must include the following fields:

.. list-table::
:widths: 25 10 70 10
:header-rows: 1

* - Field
- Type
- Description
- Required
* - ``namespace``
- string
- The name of the namespace you want to inspect.
- Yes
* - ``account_id``
- string
- The unique account identifier.
- Yes
* - ``cluster_name``
- string
- The name of the cluster where the namespace resides.
- Yes
* - ``resources``
- list
- A list of resource types to count, each including ``kind``, ``apiGroup``, and ``apiVersion``.
- Yes

Each item in the ``resources`` list must include:

* ``kind`` (e.g., `Deployments`)
* ``apiGroup`` (e.g., `apps`, or empty string for core group)
* ``apiVersion`` (e.g., `v1`, `v2`)

Example Request
^^^^^^^^^^^^^^^^^^^^

Here is an example of a ``POST`` request to query the resource count in a namespace:

.. code-block:: bash

curl --location 'https://api.robusta.dev/api/namespaces/resources' \
--header 'Authorization: Bearer API-KEY-HERE' \
--header 'Content-Type: application/json' \
--data '{
"namespace": "your-namespace",
"account_id": "your-account-id",
"cluster_name": "your-cluster-name",
"resources": [
{"kind": "Deployments", "apiGroup": "apps", "apiVersion": "v1"},
{"kind": "Ingresses", "apiGroup": "networking.k8s.io", "apiVersion": "v1"},
{"kind": "Services", "apiGroup": "", "apiVersion": "v1"},
{"kind": "HorizontalPodAutoscalers", "apiGroup": "autoscaling", "apiVersion": "v2"},
{"kind": "ReplicationControllers", "apiGroup": "", "apiVersion": "v1"}
]
}'

Replace:

- ``API-KEY-HERE`` with your API Key from **Settings → API Keys → New API Key**.
Make sure the key has **Clusters → Read** permissions to access namespace resource data.
- ``your-account-id`` with the ID found in ``generated_values.yaml``
- ``your-cluster-name`` and ``your-namespace`` accordingly

Response Format
^^^^^^^^^^^^^^^^^^^^

*Success Response*

If the request is successful, the API returns the following structure:

.. code-block:: json

{
"cluster": "your-cluster-name",
"namespace": "your-namespace",
"resources": [
{
"apiGroup": "apps",
"apiVersion": "v1",
"count": 2,
"kind": "Deployments"
},
{
"apiGroup": "",
"apiVersion": "v1",
"count": 5,
"kind": "Pods"
},
...
]
}

- **Status Code**: `200 OK`

*Error Response*

If an error occurs, you will receive a response in the following format:

.. code-block:: json

{
"msg": "Error message here",
"error_code": 456
}

- **Status Code**: Varies depending on the error (e.g., `400`, `403`, `500`)
40 changes: 40 additions & 0 deletions docs/configuration/sinks/RobustaUI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,46 @@ To do so, configure a shorter retention period by setting the ``ttl_hours`` in t
# automatically clean up old clusters in the UI if they are disconnected 12+ hours
ttl_hours: 12


.. _cb-robusta-ui-sink-namespace-config:

Monitoring Specific Resources in Namespaces
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

By default, the Robusta UI sink discovers the standard resources in all namespaces using the standard discovery interval.
However, we have a configuration to monitor custom namespaced resources, and an API is exposed via the the Robusta Backend to see how many of each resource you have in a namespace.

To configure this, use the ``namespace_discovery_seconds`` and ``namespaceMonitoredResources`` settings in the Robusta UI sink:

.. code-block:: bash
:name: cb-robusta-ui-sink-namespace-config-code

sinksConfig:
- robusta_sink:
name: robusta_ui_sink
token: <your-token>
# how often to re-scan for new namespaces (in seconds)
namespace_discovery_seconds: 3600
# what resource types to actively count per namespace
namespaceMonitoredResources:
- apiGroup: ""
apiVersion: "v1"
kind: "Services"
- apiGroup: "apps"
apiVersion: "v1"
kind: "Deployments"
- apiGroup: "apps.openshift.io"
apiVersion: "v1"
kind: "DeploymentConfig"
- apiGroup: "batch"
apiVersion: "v1"
kind: "CronJob"
- apiGroup: "networking.k8s.io"
apiVersion: "v1"
kind: "Ingress"



More Information about the UI
-------------------------------------
For more information on UI features, view `robusta.dev <https://home.robusta.dev>`_.
Loading