// Complete MXQL (Metrics Query Language) toolkit for generating, analyzing, validating, and testing queries. Supports conversational query generation, automated validation, comprehensive analysis with optimization suggestions, and test query generation with sample data. Use this for all MXQL-related tasks including creating queries, debugging, optimization, and testing.
| name | mxql |
| description | Complete MXQL (Metrics Query Language) toolkit for generating, analyzing, validating, and testing queries. Supports conversational query generation, automated validation, comprehensive analysis with optimization suggestions, and test query generation with sample data. Use this for all MXQL-related tasks including creating queries, debugging, optimization, and testing. |
This skill provides a complete toolkit for working with MXQL (Metrics Query Language), WhaTap's query language for metrics monitoring. It combines four key capabilities:
Supported Products (631 categories across 36+ product types):
Activate when users:
Examples:
Activate when users:
Examples:
Activate when users:
Conversational Approach: Guide users through query creation step-by-step.
Quick Start:
1. Understand intent (What, Where, How, When)
2. Clarify product/category if ambiguous
3. Suggest relevant fields and filters
4. Generate query with explanations
5. Offer test query version
Detailed Guide: See generating-guide.md
Comprehensive Review: Syntax, semantics, performance, best practices.
Quick Start:
# Step 1: Automated validation
from mxql_validator import MXQLValidator, format_validation_result
validator = MXQLValidator()
is_valid, issues = validator.validate(query)
print(format_validation_result(is_valid, issues))
# Step 2: Manual deep analysis (if needed)
# Step 3: Offer test query generation
Analysis Levels:
Detailed Guide: See analyzing-guide.md
Python Validator (mxql_validator.py): Fast syntax validation without Java.
Features:
Usage:
from mxql_validator import MXQLValidator, format_validation_result
validator = MXQLValidator()
is_valid, issues = validator.validate(query_text)
result = format_validation_result(is_valid, issues)
Output:
โ
Query is valid (0 critical, 1 warning, 2 info)
๐ก Warnings:
Line 5: LIMIT without ORDER - results may be arbitrary
Test Generator (test_query_generator.py): Create testable queries with ADDROW.
Features:
Usage:
from test_query_generator import TestQueryGenerator
generator = TestQueryGenerator()
# Generate test query with sample data
test_query = generator.generate_simple_test_example(original_query)
# Or comprehensive testing guide
guide = generator.generate_test_guide(original_query)
Output Example:
SUB {id: test_data}
ADDROW {'time':1700000000000, 'oid':1000, 'oname':'server-1', 'cpu':50}
ADDROW {'time':1700000060000, 'oid':1001, 'oname':'server-2', 'cpu':75}
END
CATEGORY db_mysql_counter
TAGLOAD
APPEND {query: test_data}
SELECT [oname, cpu]
ORDER {key: [cpu], sort: "desc"}
LIMIT 10
User: "Create MXQL query for MySQL high CPU instances"
Claude: [Activates mxql skill - Generation mode]
Step 1: Understanding intent
- What: CPU usage
- Where: MySQL
- How: Find high CPU instances (Top-N query)
- When: Current
Step 2: Generate query
```mxql
CATEGORY db_mysql_counter
TAGLOAD
SELECT [oname, cpu(xos), mem_pct]
FILTER {key: "cpu(xos)", cmp: "gt", value: "70"}
ORDER {key: [cpu(xos)], sort: "desc"}
LIMIT 10
Step 3: Validate automatically โ Query is valid!
Step 4: Offer test query "Would you like a test version with sample data?"
### Workflow 2: Analyze + Fix + Test
User: "Analyze this query: [pastes MXQL with errors]"
Claude: [Activates mxql skill - Analysis mode]
Step 1: Automated validation โ Query has critical issues (2 critical, 1 warning)
๐ด Critical Issues: Line 3: UPDATE without preceding GROUP
Step 2: Provide corrected query Step 3: Generate test version of corrected query
### Workflow 3: Category Recommendation
User: "Create MXQL query to monitor pod CPU usage"
Claude: [Activates mxql skill - Generation mode with category discovery]
Step 1: User intent lacks specific category
Step 2: Present options using AskUserQuestion Options:
Step 3: User selects "kube_pod_stat"
Step 4: Load category metadata and generate query with appropriate fields
### Workflow 4: Test Query Generation Only
User: "Generate test query for this MXQL"
Claude: [Uses test_query_generator.py] [Provides comprehensive testing guide with ADDROW examples]
## Reference Files
For detailed documentation:
- **[generating-guide.md](generating-guide.md)** - Complete query generation guide
- Conversational workflow
- Category and field selection
- Common patterns and examples
- **[analyzing-guide.md](analyzing-guide.md)** - Complete analysis guide
- Validation rules
- Performance optimization patterns
- Common issues and solutions
- **[analysis-checklist.md](analysis-checklist.md)** - Validation checklist
- **[optimization-patterns.md](optimization-patterns.md)** - Performance patterns
- **[common-issues.md](common-issues.md)** - Troubleshooting guide
## Python Utilities
- **`mxql_validator.py`** - Automated syntax validator
- **`test_query_generator.py`** - Test query generator
- **`category_finder.py`** - Category search and recommendation engine
### 5. Category Discovery & Recommendation ๐
**Category Finder** (`category_finder.py`): Intelligent category search and recommendation.
**Features**:
- Search 631 categories by keyword
- Recommend categories based on user intent
- Browse categories by product type
- Get detailed category metadata (tags, fields, platforms)
- Multi-language support (English, Korean, Japanese)
**Usage**:
```python
from category_finder import CategoryFinder, format_category_list
finder = CategoryFinder()
# Search by keyword
results = finder.search("postgresql")
print(format_category_list(results))
# Recommend based on intent
recommendations = finder.recommend("monitor kubernetes pod CPU usage")
# Get category details
info = finder.get_category_info("db_postgresql_counter", language="ko")
# List all product types
products = finder.list_all_products()
Command-line usage:
# Search categories
python category_finder.py search postgresql
# Get recommendations
python category_finder.py recommend "monitor kubernetes pod CPU usage"
# List product types
python category_finder.py products
# Get category info
python category_finder.py info db_postgresql_counter
READ THIS CAREFULLY - This is the most common mistake!
# โ
CORRECT - Use special keywords: pk, timeunit, merge, etc.
GROUP {pk: "service"} # Group by field
GROUP {pk: ["service", "host"]} # Group by multiple fields
GROUP {timeunit: "5m"} # Time-based grouping
GROUP {timeunit: "5m", pk: "service"} # Both time and field
GROUP {pk: "service", first: ["status"], last: ["update_time"]}
# โ
CORRECT - Use key-value pairs (must come AFTER GROUP)
UPDATE {key: "cpu", value: "avg"}
UPDATE {key: "count", value: "sum"}
UPDATE {value: "sum"} # key is optional - applies to all numeric fields
# โ This is NOT valid MXQL syntax!
GROUP {key: "service", value: "sum"} # WRONG!
GROUP {key: ["field"], value: ["avg"]} # WRONG!
# This mistake comes from confusing MXQL with SQL's GROUP BY
See generating-guide.md for detailed GROUP/UPDATE syntax and examples.
pk in GROUP, never key# Validate query
python mxql_validator.py < query.mxql
# Generate test query
python test_query_generator.py < query.mxql
This skill integrates all MXQL operations:
The goal is to provide end-to-end support for MXQL query development, from creation to testing.