# Recording rules

Manage [Coralogix recording rules](https://coralogix.com/docs/user-guides/data-transformation/metric-rules/recording-rules/index.md) directly from your AI agent. The Model Context Protocol (MCP) server provides a unified tool to create, retrieve, update, and delete recording rule group sets, and to generate infrastructure-as-code definitions from structured group configurations.

## Tool

Use `manage_recording_rules_groups_set` for all recording rule group set operations.

| Action value          | Description                                                                                                                                                                                           |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `create`              | Create a new recording rule group set.                                                                                                                                                                |
| `get`                 | Retrieve a specific recording rule group set by ID.                                                                                                                                                   |
| `list`                | List recording rule group sets with an optional case-insensitive name filter.                                                                                                                         |
| `update`              | Update an existing group set. The agent retrieves the current configuration first, then applies your changes.                                                                                         |
| `delete`              | Delete a recording rule group set by ID.                                                                                                                                                              |
| `generate_openapi`    | Generate the OpenAPI JSON payload for use with the Coralogix REST API.                                                                                                                                |
| `generate_kubernetes` | Generate a Kubernetes Operator YAML manifest for the [Coralogix Operator](https://coralogix.com/docs/developer-portal/infrastructure-as-code/coralogix-operator/index.md).                            |
| `generate_terraform`  | Generate Terraform configuration for the [Coralogix Terraform Provider](https://coralogix.com/docs/developer-portal/infrastructure-as-code/terraform-provider/coralogix-terraform-provider/index.md). |

## Example prompts

### Create a group set

```text
Create a recording rule group set named service-metrics. Add group
service-latency with interval 120 and rule service:latency:p95 using
expression histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le, service)).
```

### List group sets

```text
List Coralogix recording rule group sets whose name contains "service".
```

### Add a rule

```text
Update recording rule group set service-metrics by adding rule
service:latency:p99 to group service-latency.
```

### Generate Terraform configuration

```text
Generate Terraform configuration for a recording rule group set named service-preview
with 1 group service-errors and 1 rule service:errors:rate5m using
expression sum(rate(http_requests_total{status=~"5.."}[5m])) by (service).
Do not create it.
```

## Important behaviors

- **Structured groups only.** The tool rejects Terraform-only `yamlContent` input because OpenAPI, Kubernetes, and Terraform output do not share it.
- **Update requires retrieval first.** Retrieve the current group set, modify it, then update with the complete group set definition.
- **Each group needs rules.** The tool rejects empty groups and rules without `record` and `expression`.
