You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(k8s): support promql historical data queries (#82)
Enable users the ability to query historical data (if provided a
timeline) from metric tools that use Sysdig Monitor with no data
restrictions.
- Adds optional ``start/end`` historical query parameters to all Sysdig
Monitor ``k8s_list_* tools``, enabling LLMs to query Kubernetes metrics
over a past time window instead of only the current snapshot.
- When provided, the underlying PromQL is wrapped in the appropriate
aggregation for each tool:
- CPU/memory/pod count → ``avg_over_time``
- Restarted pods → ``increase``
- Unavailable pods → ``min_over_time >= 1``
- HTTP/network errors → ``sum_over_time / N (rate per second)``
- Inventory tools (clusters, nodes, workloads, etc.) → ``max_over_time >
0``
- When omitted, tools behave as before (instant snapshot)
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -131,6 +131,8 @@ The server dynamically filters the available tools based on the permissions asso
131
131
-**Required Permission**: `metrics-data.read`
132
132
-**Sample Prompt**: "Show the top 10 underutilized pods by memory quota in cluster 'production'"
133
133
134
+
> **Note:** When a time window is provided, the underlying PromQL is wrapped in the aggregation appropriate for each tool (`avg_over_time`, `max_over_time`, `min_over_time`, `increase`, etc.) and evaluated at `end`. See [`internal/infra/mcp/tools/README.md`](./internal/infra/mcp/tools/README.md) for the per-tool aggregation table.
Copy file name to clipboardExpand all lines: internal/infra/mcp/tools/README.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,35 @@ The handler filters tools dynamically based on the Sysdig user's permissions. Ea
38
38
|---|---|---|---|---|
39
39
|`generate_sysql`|`tool_generate_sysql.go`| Convert natural language to SysQL via Sysdig Sage. |`sage.exec` (does not work with Service Accounts) | "Create a SysQL to list S3 buckets." |
40
40
41
+
## Historical range (start / end)
42
+
43
+
All Sysdig Monitor `k8s_list_*` tools accept two optional parameters:
44
+
45
+
-`start` — RFC3339 timestamp, e.g. `2026-04-16T00:00:00Z`
46
+
-`end` — RFC3339 timestamp, e.g. `2026-04-16T01:00:00Z`
47
+
48
+
When omitted, tools return an instant snapshot (current behaviour). When provided,
49
+
the underlying PromQL is wrapped in the aggregation appropriate for each tool and
50
+
evaluated at `end`:
51
+
52
+
| Tool group | Wrapping applied when windowed |
53
+
|---|---|
54
+
| CPU / memory usage, underutilized quota, pod count |`avg_over_time(metric[Ns])`|
55
+
| Top restarted pods |`increase(kube_pod_container_status_restarts_total[Ns])`|
56
+
| Top unavailable pods |`min_over_time(kube_workload_status_unavailable[Ns]) >= 1` (Sysdig-canonical pattern — requires continuous unavailability for the entire window) |
mcp.WithDescription("Lists the cluster information for all clusters or just the cluster specified."),
29
+
mcp.WithDescription("Lists the cluster information for all clusters or just the cluster specified. Optionally pass start/end (RFC3339) to list clusters that existed at any point in the window."),
27
30
mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")),
28
31
mcp.WithNumber("limit",
29
32
mcp.Description("Maximum number of clusters to return."),
mcp.WithDescription("List the count of running Kubernetes Pods grouped by cluster and namespace."),
30
+
mcp.WithDescription("List the count of running Kubernetes Pods grouped by cluster and namespace. Optionally pass start/end (RFC3339) to count pods averaged over a historical window instead of the current instant snapshot."),
28
31
mcp.WithString("cluster_name", mcp.Description("The name of the cluster to filter by.")),
29
32
mcp.WithString("namespace_name", mcp.Description("The name of the namespace to filter by.")),
30
33
mcp.WithNumber("limit",
31
34
mcp.Description("Maximum number of results to return."),
0 commit comments