> ## Documentation Index
> Fetch the complete documentation index at: https://docs.akua.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Dashboard Generation

> Use AI agents to generate and iterate on custom dashboards and snippets

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/akua-1dce587a/3H5lVc027NQakOso/images/heros/dashboard-generation-light.svg?fit=max&auto=format&n=3H5lVc027NQakOso&q=85&s=7d07050ace9887e71327e28e271c833f" alt="A natural-language prompt becomes a test-run snippet that generates a dashboard of heterogeneous live widgets — a stat, a table, logs, and a chart — which you refine through a conversational iterate loop" width="1536" height="864" data-path="images/heros/dashboard-generation-light.svg" />

  <img className="hidden dark:block" src="https://mintcdn.com/akua-1dce587a/3H5lVc027NQakOso/images/heros/dashboard-generation-dark.svg?fit=max&auto=format&n=3H5lVc027NQakOso&q=85&s=93b6d634316d1926c56f1d4d90f7c577" alt="A natural-language prompt becomes a test-run snippet that generates a dashboard of heterogeneous live widgets — a stat, a table, logs, and a chart — which you refine through a conversational iterate loop" width="1536" height="864" data-path="images/heros/dashboard-generation-dark.svg" />
</Frame>

[Custom dashboards](/dashboards/custom-dashboards) are powered by JavaScript snippets that query the Akua API (the same `platform.request()` sandbox used by [Code Mode](/ai/platform-mcp#why-code-mode)). This makes them a natural fit for AI-driven generation: your agent already knows how to write this code.

## Why use an agent

Snippet code is an **implementation detail, not something you hand-craft**. The JavaScript is simple, repetitive, and easy to regenerate; treat it as disposable. Instead of learning API endpoints and debugging code yourself, describe what you want and let your agent handle it:

| You say                                     | The agent does                                                                                                  |
| ------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| "Create a dashboard showing cluster health" | Writes snippets for cluster status, KaaS version, and error counts, then creates the dashboard with all widgets |
| "Add a stat widget for total installs"      | Creates a snippet that counts installs, adds it to the dashboard                                                |
| "Make the cluster table show regions too"   | Updates the snippet code to join cluster and region data                                                        |
| "The logs widget is too wide, make it half" | Adjusts the widget's column span from 4 to 2                                                                    |

The agent uses the same [Platform MCP](/ai/platform-mcp) that powers all Akua operations. It can create snippets, create dashboards, add widgets, and update layouts, all through the API.

## Workflow

<Steps>
  <Step title="Describe what you want">
    Tell your agent what data matters to you. Be specific about the use case, not the implementation:

    *"I want a dashboard that shows how many clusters I have, which ones are healthy, and the last 50 lines of logs from my production install."*
  </Step>

  <Step title="The agent writes and tests the snippets">
    The agent writes the JavaScript for each widget and can test it immediately. Since snippets use the same `platform.request()` sandbox as [Code Mode](/ai/platform-mcp#why-code-mode), the agent test-runs the code via `execute`, sees errors or unexpected results, fixes them, and only saves the working version as a snippet. You never see the debugging, just the finished widget.
  </Step>

  <Step title="Iterate conversationally">
    Review the result and refine. The agent can update snippet code, change display types, resize widgets, reorder the layout, or add new widgets, all from natural language.

    *"Split the cluster table into two widgets: one for KaaS clusters and one for imported."*
  </Step>

  <Step title="Save and share">
    The dashboard is saved to your workspace. Anyone on your team can open it, and widgets auto-run on load with no setup required.
  </Step>
</Steps>

## What agents can generate

Agents can create any snippet that the Akua API supports. Common patterns:

* **Resource tables**: list clusters, installs, products, or regions with selected columns
* **KPI stats**: count resources, calculate ratios, show status values
* **Health reports**: multi-step queries that check pod status, fetch logs, and summarize issues
* **Audit views**: cross-reference installs with clusters and products for compliance or inventory
* **Log viewers**: fetch and format container logs from running pods

Since snippets can make up to 50 API calls per execution, agents can build complex multi-step widgets. For example: fetch all installs, query pods for each one, then aggregate the results into a summary table.

## Beyond platform data: application-level dashboards

Here's where it gets powerful. Snippets can use the [exec endpoint](/ai/kubernetes-access#command-execution) to run commands *inside your running containers*. Dashboards aren't limited to Akua platform data; they can reach into your actual applications.

Ask your agent to build widgets like these:

| Widget idea                  | What the snippet does                                                                                     |
| ---------------------------- | --------------------------------------------------------------------------------------------------------- |
| **Postgres table sizes**     | Runs `psql` via exec to query `pg_stat_user_tables`; shows table names, row counts, and disk usage        |
| **Redis memory breakdown**   | Runs `redis-cli INFO memory` inside the Redis pod; displays used memory, peak memory, fragmentation ratio |
| **MongoDB collection stats** | Runs `mongosh --eval` to list collections with document counts and storage sizes                          |
| **Application health check** | Hits an internal `/healthz` or `/metrics` endpoint via `curl` inside the pod                              |
| **Queue depth**              | Queries RabbitMQ or Celery via CLI to show pending/processing/failed job counts                           |
| **Nginx access stats**       | Parses recent access logs with `awk` to show top endpoints, status code distribution, and request rates   |
| **SSL certificate expiry**   | Runs `openssl` to check certificate dates across services; flags anything expiring soon                   |
| **Disk usage per PVC**       | Runs `df -h` inside pods to show persistent volume usage before you run out of space                      |

These are **live widgets that auto-refresh** when you open the dashboard. A single dashboard can mix platform-level data (cluster health, install status) with application-level data (database sizes, queue depths), giving you a unified view that would normally require stitching together multiple monitoring tools.

<Tip>
  You don't need to know `psql` flags, `redis-cli` subcommands, or `mongosh` syntax. Your agent does. Just describe the data you want: *"Show me which Postgres tables are largest and whether any need vacuuming."*
</Tip>

## Tips

* **Let the agent debug for you**: if a widget shows an error, paste it into the conversation. The agent can test-run the snippet code via Code Mode, see exactly what failed, fix it, and update the snippet, all without you touching JavaScript.
* **Start broad, then refine**: ask for a general dashboard first, then tweak individual widgets.
* **Don't optimize the JavaScript**: if a snippet works, it's good enough. Regenerate rather than debug.
* **Use descriptive names**: tell the agent to name snippets clearly (e.g. "Cluster Health by Region" not "query1") so they're easy to reuse across dashboards.
* **Combine with Code Mode**: use [Code Mode](/ai/code-mode-in-action) for one-off investigations, then save the useful queries as snippets for ongoing monitoring.

## Related topics

<CardGroup cols={2}>
  <Card title="Custom dashboards" icon="gauge" href="/dashboards/custom-dashboards">
    Manual dashboard and snippet creation.
  </Card>

  <Card title="Code Mode in action" icon="code" href="/ai/code-mode-in-action">
    How the same sandbox powers AI agent operations.
  </Card>

  <Card title="Platform MCP" icon="plug" href="/ai/platform-mcp">
    Connect AI agents to Akua.
  </Card>
</CardGroup>
