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

# Overview

# MMQL (Metrics Man Query Language)

## What is MMQL?

MMQL (Metrics Man Query Language) is a domain-specific language (DSL) for querying and filtering metrics data. It provides a structured way to express complex logic for filtering, transforming, and analyzing metrics in your applications.

## What is MMQL used for?

MMQL is designed for:

* **Querying metrics data** - Extract specific metrics from large datasets
* **Filtering conditions** - Apply complex logical conditions to filter data
* **Data transformation** - Transform data using arithmetic, string, and date operations
* **Conditional logic** - Implement conditional expressions in your queries
* **Statistical analysis** - Perform aggregations like sum, average, and median

## How to use MMQL?

MMQL queries are expressed as JSON objects with operators that start with a `$` character. Each operator performs a specific function, such as comparison, arithmetic, or logical operations.

Here's a simple example:

```json theme={null}
{
  "$gte": [
    {
      "$input": "temperature"
    },
    20
  ]
}
```

This query evaluates to `true` if the `temperature` field in the input data is greater than or equal to 20.

### Basic Structure

MMQL expressions follow this pattern:

```json theme={null}
{
  "$operator": [operands...]
}
```

* The key is the MMQL operator (starts with `$`)
* The value is an array of operands or sub-expressions
* Operators can be nested to create complex expressions

### Field Access

Access fields in your data using the `$input` operator:

```json theme={null}
{
  "$input": "field.path"
}
```

For nested objects, use dot notation:

```json theme={null}
{
  "$input": "user.profile.age"
}
```

## Where to use MMQL?

MMQL is typically used in:

* **Metrics processing systems** - Filtering and transforming metrics streams
* **Business rule engines** - Implementing complex business logic
* **API endpoints** - Dynamic query generation
* **Dashboard filters** - User-defined filtering criteria
* **Alerting systems** - Complex alert conditions

## Features of MMQL

MMQL supports a wide range of operators grouped into categories:

### Logical Operators

* `$and`, `$or`, `$not`, `$nor`, `$nand`

### Comparison Operators

* `$lt`, `$lte`, `$gt`, `$gte`, `$eq`, `$ne`, `$cmp`

### Arithmetic Operators

* `$add`, `$subtract`, `$multiply`, `$divide`, `$mod`, `$min`, `$max`, and more

### String Operators

* `$contains`, `$startsWith`, `$endsWith`, `$regex`, `$toUpper`, `$toLower`, and more

### Time/Date Operators

* `$toDate`, `$toTimestamp`, `$year`, `$month`, `$day`, and more for date operations

### Array Operators

* `$first`, `$last`, `$nth`, `$filter`, `$map`, `$reduce`, and more

### Object Operators

* `$keys`, `$values`, `$hasKey` for object manipulation

### Special Features

* **Caching support**: Improves performance for complex queries
* **Type conversion**: Automatic type conversion between numbers, strings, and booleans
* **Nested field access**: Access deeply nested properties using dot notation
* **Block operators**: Support for variable assignment and scoped execution
* **Extensibility**: Easy to add custom operators to the interpreter
