Skip to content
Draft
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
43 changes: 22 additions & 21 deletions mission-control/docs/guide/views/concepts/templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,37 @@ templating:

### Required Properties

| Property | Type | Description |
| -------- | ------ | ----------------------------------------------------------------- |
| `key` | string | Unique identifier for the variable (used in template expressions) |
| `label` | string | Display name shown to users |
| `values` | array | Static list of options for the dropdown |
| `valueFrom` | object | Dynamic options from config items (alternative to `values`) |
| Property | Type | Description |
| ----------- | ------ | ----------------------------------------------------------------- |
| `key` | string | Unique identifier for the variable (used in template expressions) |
| `label` | string | Display name shown to users |
| `values` | array | Static list of options for the dropdown |
| `valueFrom` | object | Dynamic options from config items (alternative to `values`) |

:::note One of values or valueFrom is required
Every variable must have exactly one of `values` (static list) or `valueFrom` (dynamic from configs) to populate the dropdown options. These fields are mutually exclusive.
:::

### Optional Properties

| Property | Type | Description |
| ----------- | ------ | -------------------------------------------------------------------- |
| `default` | string | Default value when view loads |
| `dependsOn` | array | List of variable keys this depends on |
| Property | Type | Description |
| ----------- | ------ | ------------------------------------- |
| `default` | string | Default value when view loads |
| `dependsOn` | array | List of variable keys this depends on |

## valueFrom Structure

When using dynamic values from config items, `valueFrom` has the following structure:

| Property | Type | Description |
|----------|------|-------------|
| `config` | object | Config selector to find matching config items |
| `config.types` | array | List of config types to match (e.g., `['Kubernetes::Cluster']`) |
| `config.tagSelector` | string | Tag selector for filtering configs (optional) |
| `config.search` | string | Free text search for configs (optional) |
| `config.limit` | int | Maximum number of configs to return (optional, default: no limit) |
| `label` | string | CEL expression for dropdown display labels (optional, defaults to config name) |
| `value` | string | CEL expression for dropdown values (optional, defaults to config name) |
| Property | Type | Description |
| -------------------- | ------ | ------------------------------------------------------------------------------ |
| `config` | object | Config selector to find matching config items |
| `config.types` | array | List of config types to match (e.g., `['Kubernetes::Cluster']`) |
| `config.tagSelector` | string | Tag selector for filtering configs (optional) |
| `config.search` | string | Free text search for configs (optional) |
| `config.limit` | int | Maximum number of configs to return (optional, default: no limit) |
| `label` | string | CEL expression for dropdown display labels (optional, defaults to config name) |
| `value` | string | CEL expression for dropdown values (optional, defaults to config name) |

**Example:**

Expand All @@ -132,8 +132,8 @@ valueFrom:
types: ['Kubernetes::Pod']
tagSelector: 'cluster=production'
limit: 50
label: 'row.name + " (" + row.tags.namespace + ")"' # Display: "nginx (default)"
value: 'row.name' # Value used in queries: "nginx"
label: 'row.name + " (" + row.tags.namespace + ")"' # Display: "nginx (default)"
value: 'row.name' # Value used in queries: "nginx"
```

## Variable Types
Expand Down Expand Up @@ -468,6 +468,7 @@ spec:
```

5. **Limit dynamic variable options** - Add reasonable limits to prevent huge lists

```yaml
valueFrom:
config:
Expand Down
28 changes: 21 additions & 7 deletions mission-control/docs/guide/views/queries/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ The `connection` field references a stored [Connection](/mission-control/guide/c
5. Resolving any environment variable references in connection properties

Connection properties that can be inherited:

- `url` - Base URL for the API
- `username` / `password` - HTTP Basic Authentication
- `bearer` - Bearer token for token-based auth
Expand All @@ -89,19 +90,33 @@ Connection properties that can be inherited:

**Example with connection:**

```yaml title="http-connection.yaml" file=<rootDir>/modules/mission-control/fixtures/views/http-connection.yaml

```yaml
queries:
users:
http:
url: /api/users
connection: connection://my-api
```

## Templating Support

The `body` field supports Go templating, allowing dynamic request payloads:

```yaml title="http-post-body.yaml" file=<rootDir>/modules/mission-control/fixtures/views/http-post-body.yaml

```yaml
queries:
search:
http:
url: https://api.example.com/search
method: POST
body: |
{
"query": "$(var.searchTerm)",
"limit": 100
}
```

Template variables available in the body:

- `$(var.<name>)` - View template variables
- Environment variables via `$(ENV_VAR_NAME)`

Expand All @@ -116,7 +131,7 @@ Set the property via environment variable or configuration:
```yaml
# Increase limit to 50 MB
properties:
view.http.body.max_size_bytes: "52428800"
view.http.body.max_size_bytes: '52428800'
```

### Size Limit Error Handling
Expand All @@ -128,6 +143,7 @@ http response body size (32 MB) exceeds maximum allowed (25 MB); increase limit
```

To resolve:

1. Increase the limit via the property (if you have sufficient memory)
2. Use pagination in the API request to fetch smaller chunks
3. Apply filters in the API request to reduce response size
Expand All @@ -142,5 +158,3 @@ queries:
url: https://api.example.com/items?page=1&per_page=100
connection: connection://my-api
```