Skip to content

Commit e024114

Browse files
arikalon1claude
andauthored
Add Prometheus Query API and Holmes Chat API documentation (#2006)
* Add Prometheus Query API and Holmes Chat API documentation Add documentation for two new API endpoints: - Prometheus Query API: Run PromQL queries against connected clusters - Holmes Chat API: Send questions to Holmes AI for root cause analysis https://claude.ai/code/session_01MLXAVw9RVcPfGyUhy1XeDQ * Improve API documentation with additional details - Fix ask parameter to be mandatory in Holmes Chat API - Add API key generation instructions to Prometheus Query API - Add Holmes Chat API reference to Robusta Pro Features - Add markdown response handling examples for Holmes Chat API https://claude.ai/code/session_01MLXAVw9RVcPfGyUhy1XeDQ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 80b18a6 commit e024114

File tree

4 files changed

+411
-0
lines changed

4 files changed

+411
-0
lines changed
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
Prometheus Query API
2+
====================
3+
4+
.. note::
5+
6+
This feature is available with the Robusta SaaS platform and self-hosted commercial plans.
7+
It is not available in the open-source version.
8+
9+
The Prometheus Query API allows you to run PromQL queries against the Prometheus instance
10+
in your connected clusters.
11+
12+
Endpoint
13+
--------
14+
15+
.. code-block::
16+
17+
POST https://api.robusta.dev/api/accounts/{account_id}/clusters/{cluster_name}/prometheus/query
18+
19+
Path Parameters
20+
---------------
21+
22+
.. list-table::
23+
:header-rows: 1
24+
:widths: 20 10 70
25+
26+
* - Parameter
27+
- Required
28+
- Description
29+
* - account_id
30+
- Yes
31+
- Your Robusta account ID (found in generated_values.yaml as ``globalConfig.account_id``)
32+
* - cluster_name
33+
- Yes
34+
- The name of the cluster to query (as shown in the Robusta UI)
35+
36+
Request Body
37+
------------
38+
39+
.. list-table::
40+
:header-rows: 1
41+
:widths: 20 10 15 55
42+
43+
* - Field
44+
- Required
45+
- Default
46+
- Description
47+
* - promql_query
48+
- Yes
49+
-
50+
- The PromQL query to execute
51+
* - duration_minutes
52+
- No
53+
- 60
54+
- Time range in minutes (looking back from now)
55+
* - starts_at
56+
- No
57+
-
58+
- Start time for date range queries (format: ``YYYY-MM-DD HH:MM:SS UTC``)
59+
* - ends_at
60+
- No
61+
-
62+
- End time for date range queries (format: ``YYYY-MM-DD HH:MM:SS UTC``)
63+
* - step
64+
- No
65+
- 1m
66+
- Query resolution step (e.g., ``30s``, ``1m``, ``5m``)
67+
68+
.. note::
69+
70+
You can specify either ``duration_minutes`` OR both ``starts_at`` and ``ends_at``, but not both.
71+
If neither is specified, ``duration_minutes`` defaults to 60.
72+
73+
Authentication
74+
--------------
75+
76+
Include an API key in the Authorization header:
77+
78+
.. code-block::
79+
80+
Authorization: Bearer <API_KEY>
81+
82+
The API key must have **Read Metrics** permission. You can generate this token in the platform by navigating to **Settings** -> **API Keys** -> **New API Key**, and creating a key with the "Read Metrics" permission.
83+
84+
Example Request
85+
---------------
86+
87+
Using duration (last 5 minutes):
88+
89+
.. code-block:: bash
90+
91+
curl -X POST "https://api.robusta.dev/api/accounts/ACCOUNT_ID/clusters/CLUSTER_NAME/prometheus/query" \
92+
-H "Authorization: Bearer YOUR_API_KEY" \
93+
-H "Content-Type: application/json" \
94+
-d '{
95+
"promql_query": "up",
96+
"duration_minutes": 5,
97+
"step": "1m"
98+
}'
99+
100+
Using date range:
101+
102+
.. code-block:: bash
103+
104+
curl -X POST "https://api.robusta.dev/api/accounts/ACCOUNT_ID/clusters/CLUSTER_NAME/prometheus/query" \
105+
-H "Authorization: Bearer YOUR_API_KEY" \
106+
-H "Content-Type: application/json" \
107+
-d '{
108+
"promql_query": "kube_resourcequota{type=\"hard\"}",
109+
"starts_at": "2024-01-27 10:00:00 UTC",
110+
"ends_at": "2024-01-27 11:00:00 UTC",
111+
"step": "1m"
112+
}'
113+
114+
Replace ``ACCOUNT_ID``, ``CLUSTER_NAME``, and ``YOUR_API_KEY`` with your actual values.
115+
116+
Response Format
117+
---------------
118+
119+
Success response:
120+
121+
.. code-block:: json
122+
123+
{
124+
"status": "success",
125+
"query": "up",
126+
"data": [
127+
{
128+
"metric": {
129+
"__name__": "up",
130+
"job": "kubelet",
131+
"namespace": "kube-system",
132+
"node": "worker-node-1"
133+
},
134+
"timestamps": [1706356800.0, 1706356860.0, 1706356920.0],
135+
"values": ["1", "1", "1"]
136+
},
137+
{
138+
"metric": {
139+
"__name__": "up",
140+
"job": "coredns",
141+
"namespace": "kube-system",
142+
"pod": "coredns-7c68b4b998-abc12"
143+
},
144+
"timestamps": [1706356800.0, 1706356860.0, 1706356920.0],
145+
"values": ["1", "1", "1"]
146+
}
147+
]
148+
}
149+
150+
Response Fields
151+
---------------
152+
153+
.. list-table::
154+
:header-rows: 1
155+
:widths: 20 80
156+
157+
* - Field
158+
- Description
159+
* - status
160+
- ``success`` or ``error``
161+
* - query
162+
- The PromQL query that was executed
163+
* - data
164+
- Array of time series results
165+
* - data[].metric
166+
- Labels identifying the time series
167+
* - data[].timestamps
168+
- Array of Unix timestamps for each data point
169+
* - data[].values
170+
- Array of values corresponding to each timestamp
171+
172+
Error Response
173+
--------------
174+
175+
.. code-block:: json
176+
177+
{
178+
"status": "error",
179+
"query": "invalid_query",
180+
"error": "Error message describing what went wrong"
181+
}
182+
183+
Common Queries
184+
--------------
185+
186+
Resource quotas (OpenShift/Kubernetes):
187+
188+
.. code-block:: json
189+
190+
{"promql_query": "kube_resourcequota{type=\"hard\"}"}
191+
{"promql_query": "kube_resourcequota{type=\"used\"}"}
192+
193+
CPU and memory:
194+
195+
.. code-block:: json
196+
197+
{"promql_query": "sum(rate(container_cpu_usage_seconds_total[5m])) by (pod, namespace)"}
198+
{"promql_query": "container_memory_usage_bytes{namespace=\"default\"}"}
199+
200+
Pod status:
201+
202+
.. code-block:: json
203+
204+
{"promql_query": "kube_pod_status_phase{phase=\"Running\"}"}
205+
{"promql_query": "kube_pod_container_status_restarts_total"}

docs/configuration/exporting/robusta-pro-features.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Automatically investigate and resolve issues with AI-powered analysis.
1414
:doc:`AI Analysis (HolmesGPT) <../holmesgpt/main-features>`
1515
Automatically analyze Kubernetes alerts, logs, and metrics. Get potential root causes and remediation suggestions.
1616

17+
:doc:`Holmes Chat API <../holmesgpt/holmes-chat-api>`
18+
Programmatically send questions to Holmes AI for root cause analysis via REST API.
19+
1720
Custom Alert Ingestion
1821
-----------------------
1922

@@ -49,6 +52,7 @@ Features include:
4952
* :doc:`Send Alerts API <send-alerts-api>`: Send alerts programmatically from external systems or via integrations
5053
* :doc:`Configuration Changes API <configuration-changes-api>`: Track configuration changes in your environment
5154
* :doc:`RBAC Configuration API <rbac-api>`: Programmatically manage role-based access control configurations
55+
* :doc:`Prometheus Query API <prometheus-query-api>`: Run PromQL queries against Prometheus in your connected clusters
5256

5357
Additional Pro Features
5458
-----------------------

0 commit comments

Comments
 (0)