Skip to content

Commit d293c11

Browse files
authored
added api-docs (#1878)
1 parent 057519a commit d293c11

2 files changed

Lines changed: 162 additions & 0 deletions

File tree

docs/configuration/exporting/exporting-data.rst

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,125 @@ If there is an error in processing the request, the API will return the followin
649649
}
650650
651651
- **Status Code**: Varies based on the error (e.g., `400 Bad Request`, `500 Internal Server Error`).
652+
653+
.. _namespaces-resources-api:
654+
655+
POST https://api.robusta.dev/api/namespaces/resources
656+
------------------------------------------------------
657+
658+
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.
659+
660+
You can specify exactly which resource kinds you want to query in the request.
661+
662+
This API relies on resource types configured in the Robusta UI sink.
663+
Make sure to configure them as described in :ref:`cb-robusta-ui-sink-namespace-config`.
664+
665+
Request Body Schema
666+
^^^^^^^^^^^^^^^^^^^
667+
668+
The request body must include the following fields:
669+
670+
.. list-table::
671+
:widths: 25 10 70 10
672+
:header-rows: 1
673+
674+
* - Field
675+
- Type
676+
- Description
677+
- Required
678+
* - ``namespace``
679+
- string
680+
- The name of the namespace you want to inspect.
681+
- Yes
682+
* - ``account_id``
683+
- string
684+
- The unique account identifier.
685+
- Yes
686+
* - ``cluster_name``
687+
- string
688+
- The name of the cluster where the namespace resides.
689+
- Yes
690+
* - ``resources``
691+
- list
692+
- A list of resource types to count, each including ``kind``, ``apiGroup``, and ``apiVersion``.
693+
- Yes
694+
695+
Each item in the ``resources`` list must include:
696+
697+
* ``kind`` (e.g., `Deployments`)
698+
* ``apiGroup`` (e.g., `apps`, or empty string for core group)
699+
* ``apiVersion`` (e.g., `v1`, `v2`)
700+
701+
Example Request
702+
^^^^^^^^^^^^^^^^^^^^
703+
704+
Here is an example of a ``POST`` request to query the resource count in a namespace:
705+
706+
.. code-block:: bash
707+
708+
curl --location 'https://api.robusta.dev/api/namespaces/resources' \
709+
--header 'Authorization: Bearer API-KEY-HERE' \
710+
--header 'Content-Type: application/json' \
711+
--data '{
712+
"namespace": "your-namespace",
713+
"account_id": "your-account-id",
714+
"cluster_name": "your-cluster-name",
715+
"resources": [
716+
{"kind": "Deployments", "apiGroup": "apps", "apiVersion": "v1"},
717+
{"kind": "Ingresses", "apiGroup": "networking.k8s.io", "apiVersion": "v1"},
718+
{"kind": "Services", "apiGroup": "", "apiVersion": "v1"},
719+
{"kind": "HorizontalPodAutoscalers", "apiGroup": "autoscaling", "apiVersion": "v2"},
720+
{"kind": "ReplicationControllers", "apiGroup": "", "apiVersion": "v1"}
721+
]
722+
}'
723+
724+
Replace:
725+
726+
- ``API-KEY-HERE`` with your API Key from **Settings → API Keys → New API Key**.
727+
Make sure the key has **Clusters → Read** permissions to access namespace resource data.
728+
- ``your-account-id`` with the ID found in ``generated_values.yaml``
729+
- ``your-cluster-name`` and ``your-namespace`` accordingly
730+
731+
Response Format
732+
^^^^^^^^^^^^^^^^^^^^
733+
734+
*Success Response*
735+
736+
If the request is successful, the API returns the following structure:
737+
738+
.. code-block:: json
739+
740+
{
741+
"cluster": "your-cluster-name",
742+
"namespace": "your-namespace",
743+
"resources": [
744+
{
745+
"apiGroup": "apps",
746+
"apiVersion": "v1",
747+
"count": 2,
748+
"kind": "Deployments"
749+
},
750+
{
751+
"apiGroup": "",
752+
"apiVersion": "v1",
753+
"count": 5,
754+
"kind": "Pods"
755+
},
756+
...
757+
]
758+
}
759+
760+
- **Status Code**: `200 OK`
761+
762+
*Error Response*
763+
764+
If an error occurs, you will receive a response in the following format:
765+
766+
.. code-block:: json
767+
768+
{
769+
"msg": "Error message here",
770+
"error_code": 456
771+
}
772+
773+
- **Status Code**: Varies depending on the error (e.g., `400`, `403`, `500`)

docs/configuration/sinks/RobustaUI.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,46 @@ To do so, configure a shorter retention period by setting the ``ttl_hours`` in t
6060
# automatically clean up old clusters in the UI if they are disconnected 12+ hours
6161
ttl_hours: 12
6262
63+
64+
.. _cb-robusta-ui-sink-namespace-config:
65+
66+
Monitoring Specific Resources in Namespaces
67+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68+
69+
By default, the Robusta UI sink discovers the standard resources in all namespaces using the standard discovery interval.
70+
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.
71+
72+
To configure this, use the ``namespace_discovery_seconds`` and ``namespaceMonitoredResources`` settings in the Robusta UI sink:
73+
74+
.. code-block:: bash
75+
:name: cb-robusta-ui-sink-namespace-config-code
76+
77+
sinksConfig:
78+
- robusta_sink:
79+
name: robusta_ui_sink
80+
token: <your-token>
81+
# how often to re-scan for new namespaces (in seconds)
82+
namespace_discovery_seconds: 3600
83+
# what resource types to actively count per namespace
84+
namespaceMonitoredResources:
85+
- apiGroup: ""
86+
apiVersion: "v1"
87+
kind: "Services"
88+
- apiGroup: "apps"
89+
apiVersion: "v1"
90+
kind: "Deployments"
91+
- apiGroup: "apps.openshift.io"
92+
apiVersion: "v1"
93+
kind: "DeploymentConfig"
94+
- apiGroup: "batch"
95+
apiVersion: "v1"
96+
kind: "CronJob"
97+
- apiGroup: "networking.k8s.io"
98+
apiVersion: "v1"
99+
kind: "Ingress"
100+
101+
102+
63103
More Information about the UI
64104
-------------------------------------
65105
For more information on UI features, view `robusta.dev <https://home.robusta.dev>`_.

0 commit comments

Comments
 (0)