# Events2Metrics

Manage [Coralogix Events2Metrics](https://coralogix.com/docs/user-guides/monitoring-and-insights/events2metrics/index.md) directly from your AI agent. The Model Context Protocol (MCP) server provides a unified tool to create, retrieve, update, and delete Events2Metrics resources, and to generate infrastructure-as-code definitions from resource configurations.

## Tool

Use `manage_events2metrics` for all Events2Metrics operations.

| Action value          | Description                                                                                                                                                                                           |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `create`              | Create a new Events2Metrics resource.                                                                                                                                                                 |
| `get`                 | Retrieve a specific Events2Metrics resource by ID.                                                                                                                                                    |
| `list`                | List Events2Metrics resources with an optional case-insensitive name filter.                                                                                                                          |
| `update`              | Update an existing resource. The agent retrieves the current configuration first, then applies your changes.                                                                                          |
| `delete`              | Delete an Events2Metrics resource 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). |

## Supported shape

The tool supports 1 query source per resource: logs or spans. It supports metric labels, metric fields, permutation limits, query filters, and the min, max, count, average, sum, samples, and histogram aggregations.

## Example prompts

### Create a logs metric

```text
Create a Coralogix Events2Metrics resource named logs-status-count.
Convert logs matching Lucene query status:* with severity Error into a count
metric. Use source field status, target base metric name status_count,
metric label Status from field status, and permutations limit 1000.
```

### Create a spans metric

```text
Create a Coralogix Events2Metrics resource named spans-duration-samples.
Convert spans matching operationName:* into a samples metric over source field
duration. Use sample type Max, target base metric name duration_samples,
metric label Service from field service_name, service filter contains api,
and action filter contains GET.
```

### Export an existing resource

```text
Generate OpenAPI JSON, Kubernetes YAML, and Terraform configuration for the
Events2Metrics resource named logs-status-count.
```

## Important behaviors

- **Use 1 query type.** A resource must use either `logsQuery` or `spansQuery`, not both.
- **Custom aggregation target metric names are not supported.** Use the generated target metric naming.
- **Logs query aliases are not exposed.** The tool rejects fetched resources with unsupported aliases for the shared infrastructure-as-code path.
- **Update requires retrieval first.** Retrieve the current resource, modify it, then update with the complete definition.
