agentleFS
ElasticKnown publisherelastic/elastic-ramen/packages/opencode/src/elastic/skills/elasticsearch-esql/SKILL.md

elasticsearch-esql

Skill19 starsChanged 8 months agoMITView on GitHub

Use this skill when writing or debugging ES|QL queries for Elasticsearch. Activate when the user asks to query logs, metrics, traces, or any Elasticsearch data using ES|QL syntax.

We split this skill into the rules it gives an agent

8 rules. 0 are common, 1 is distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use the elastic CLI:

    line 30
  2. Very specific:

    Always specify a time range with WHERE @timestamp > NOW() - <duration> to avoid scanning too much data

    line 93
  3. Very specific:

    Use LIMIT to control output size

    line 94
  4. Very specific:

    Use KEEP to select specific columns before output

    line 95
  5. Very specific:

    Use DROP to exclude columns

    line 96
  6. Very specific:

    Use RENAME old AS new to rename columns

    line 97
  7. Very specific:

    Use EVAL new_field = expression to create computed columns

    line 98
  8. Very specific:

    Use DISSECT or GROK for parsing unstructured text fields

    line 99

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Elasticsearch ES|QL Query Authoring

ES|QL Basics

ES|QL (Elasticsearch Query Language) is a piped query language for filtering, transforming, and aggregating Elasticsearch data.

Syntax

FROM <index-pattern>
| WHERE <condition>
| STATS <aggregation> BY <field>
| SORT <field> [ASC|DESC]
| LIMIT <n>

Running Queries

Use the elastic CLI:

elastic es query 'FROM logs-* | WHERE @timestamp > NOW() - 1 HOUR | LIMIT 10'

Common Patterns

Filter by time range:

FROM logs-*
| WHERE @timestamp > NOW() - 24 HOURS

Count by field:

FROM logs-*
| STATS count = COUNT(*) BY service.name
| SORT count DESC

Percentiles:

FROM metrics-apm*
| STATS p50 = PERCENTILE(transaction.duration.us, 50),
        p95 = PERCENTILE(transaction.duration.us, 95),
        p99 = PERCENTILE(transaction.duration.us, 99)
  BY service.name

Time bucketing:

FROM logs-*
| WHERE log.level == "error"
| STATS errors = COUNT(*) BY bucket = BUCKET(@timestamp, 5 minute)
| SORT bucket

Multi-field filtering:

FROM logs-*
| WHERE service.name == "api-gateway" AND http.response.status_code >= 500
| KEEP @timestamp, message, http.response.status_code, trace.id
| SORT @timestamp DESC
| LIMIT 50

Type Functions

  • TO_STRING(field), TO_INTEGER(field), TO_DOUBLE(field) -- type conversions
  • DATE_TRUNC(interval, field) -- truncate timestamps
  • CONCAT(a, b) -- string concatenation
  • LENGTH(field) -- string length
  • TRIM(field), LEFT(field, n), RIGHT(field, n) -- string manipulation

Aggregation Functions

  • COUNT(*), COUNT(field), COUNT_DISTINCT(field)
  • SUM(field), AVG(field), MIN(field), MAX(field)
  • PERCENTILE(field, pct), MEDIAN(field)
  • VALUES(field) -- collect distinct values

Tips

  • Always specify a time range with WHERE @timestamp > NOW() - <duration> to avoid scanning too much data
  • Use LIMIT to control output size
  • Use KEEP to select specific columns before output
  • Use DROP to exclude columns
  • Use RENAME old AS new to rename columns
  • Use EVAL new_field = expression to create computed columns
  • Use DISSECT or GROK for parsing unstructured text fields

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.