elasticsearch-skill 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # elasticsearch
2
+
3
+ Minimal package with core Elasticsearch and Kibana REST API guidance.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install elasticsearch-skill
9
+ ```
10
+
11
+ Or install locally:
12
+
13
+ ```bash
14
+ cd elasticsearch
15
+ npm pack
16
+ npm install ./elasticsearch-skill-1.0.0.tgz
17
+ ```
18
+
19
+ ## Use
20
+
21
+ Provides concise examples for:
22
+
23
+ - auth and request patterns
24
+ - basic search (Query DSL)
25
+ - aggregations and date histograms
26
+ - index/mapping operations and bulk
27
+ - lightweight Kibana API pointers
28
+
29
+ ## Package layout
30
+
31
+ - `SKILL.md` - when to use and core rules
32
+ - `references/` - short examples and tips
33
+
34
+ ## Publish
35
+
36
+ 1. Bump `version` in `package.json`.
37
+ 2. Run `npm pack` and verify contents.
38
+ 3. Publish with `npm publish`.
39
+
40
+ ## Thanks
41
+
42
+ Consolidated from local Elasticsearch skill guidance.
package/SKILL.md ADDED
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: elasticsearch
3
+ description: >
4
+ Core Elasticsearch and Kibana REST guidance for querying, indexing, aggregations,
5
+ and basic troubleshooting via `curl`. Use when the user asks for Query DSL examples,
6
+ index/mapping changes, aggregations, basic cluster checks, or Kibana saved-object APIs.
7
+ ---
8
+
9
+ # Elasticsearch
10
+
11
+ Use this skill for concise, copy-ready REST examples and operational tips that work across
12
+ Elastic Cloud, self-managed, and serverless clusters (with serverless limitations noted).
13
+
14
+ ## Core rules
15
+
16
+ 1. Always require `ES_URL` and `ES_API_KEY` (ApiKey header) from the user.
17
+ 2. Prefer small, copy-paste `curl` examples that include `jq` for readability.
18
+ 3. Note serverless limitations (many cluster APIs are unavailable).
19
+ 4. Point to compact reference examples in `references/` for Query DSL, aggregations, and index ops.
20
+
21
+ ## When to use
22
+
23
+ - The user asks how to run searches, aggregations, create mappings, or index documents.
24
+ - The user wants quick troubleshooting commands (health, nodes, pending tasks).
25
+ - The user needs Kibana API endpoints for dashboards or saved objects.
26
+
27
+ ## On-demand references
28
+
29
+ - `references/auth-and-tips.md` — auth pattern and serverless notes
30
+ - `references/query-dsl.md` — short Query DSL examples
31
+ - `references/aggregations.md` — top aggregations examples
32
+ - `references/index.md` — create index, mappings, bulk, and reindex
33
+ - `references/kibana.md` — basic Kibana API examples
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "elasticsearch-skill",
3
+ "version": "1.0.0",
4
+ "description": "Core Elasticsearch/Kibana REST API guidance for querying, indexing, and basic ops",
5
+ "license": "MIT",
6
+ "private": false,
7
+ "files": [
8
+ "SKILL.md",
9
+ "README.md",
10
+ "references"
11
+ ],
12
+ "keywords": [
13
+ "elasticsearch",
14
+ "kibana",
15
+ "search",
16
+ "aggregation",
17
+ "devops",
18
+ "skill"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/Dharun235/ai-skills.git",
23
+ "directory": "elasticsearch"
24
+ },
25
+ "homepage": "https://github.com/Dharun235/ai-skills/tree/main/elasticsearch",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ }
29
+ }
@@ -0,0 +1,21 @@
1
+ ## Aggregations — common patterns
2
+
3
+ Terms aggregation (top values):
4
+
5
+ ```bash
6
+ curl -s "${ES_URL%/}/my-index/_search?size=0" \
7
+ -H "Authorization: ApiKey $(printenv ES_API_KEY)" \
8
+ -H "Content-Type: application/json" \
9
+ -d '{"aggs": {"top_levels": {"terms": {"field": "level", "size": 10}}}}' | jq .aggregations
10
+ ```
11
+
12
+ Date histogram with nested metric:
13
+
14
+ ```bash
15
+ curl -s "${ES_URL%/}/my-index/_search?size=0" \
16
+ -H "Authorization: ApiKey $(printenv ES_API_KEY)" \
17
+ -H "Content-Type: application/json" \
18
+ -d '{"query":{"range":{"@timestamp":{"gte":"now-24h"}}},"aggs":{"over_time":{"date_histogram":{"field":"@timestamp","fixed_interval":"1h"},"aggs":{"avg_count":{"avg":{"field":"count"}}}}}}' | jq .aggregations
19
+ ```
20
+
21
+ Advice: use `?size=0` when only retrieving aggregations to skip hits. Use composite aggregations for high-cardinality faceting.
@@ -0,0 +1,22 @@
1
+ ## Auth & Tip Summary
2
+
3
+ - Export the cluster URL and API key in your session:
4
+
5
+ ```bash
6
+ ES_URL="https://your-cluster.es.cloud.elastic.co:443"
7
+ ES_API_KEY="base64-id:api_key"
8
+ ```
9
+
10
+ - Use this header pattern in `curl`:
11
+
12
+ ```bash
13
+ curl -s "${ES_URL%/}/_cat/indices?v" \
14
+ -H "Authorization: ApiKey $(printenv ES_API_KEY)" \
15
+ -H "Content-Type: application/json"
16
+ ```
17
+
18
+ - Tips:
19
+ - Use `${ES_URL%/}` to avoid double slashes.
20
+ - Use `$(printenv ES_API_KEY)` in headers to avoid empty auth.
21
+ - Prefer `jq` for formatting responses.
22
+ - Serverless clusters may not support cluster-level APIs (`_cluster/*`, `_nodes/*`, ILM).
@@ -0,0 +1,33 @@
1
+ ## Index & Document — create, mappings, bulk
2
+
3
+ Create index with mappings:
4
+
5
+ ```bash
6
+ curl -s -X PUT "${ES_URL%/}/my-index" \
7
+ -H "Authorization: ApiKey $(printenv ES_API_KEY)" \
8
+ -H "Content-Type: application/json" \
9
+ -d '{"settings":{"number_of_shards":1},"mappings":{"properties":{"message":{"type":"text"},"@timestamp":{"type":"date"}}}}'
10
+ ```
11
+
12
+ Index a document (auto ID):
13
+
14
+ ```bash
15
+ curl -s -X POST "${ES_URL%/}/my-index/_doc" \
16
+ -H "Authorization: ApiKey $(printenv ES_API_KEY)" \
17
+ -H "Content-Type: application/json" \
18
+ -d '{"message":"hello","@timestamp":"2026-01-31T12:00:00Z"}' | jq .
19
+ ```
20
+
21
+ Bulk NDJSON example (use `--data-binary @-`):
22
+
23
+ ```bash
24
+ curl -s -X POST "${ES_URL%/}/_bulk" \
25
+ -H "Authorization: ApiKey $(printenv ES_API_KEY)" \
26
+ -H "Content-Type: application/x-ndjson" \
27
+ --data-binary @- << 'EOF'
28
+ {"index":{"_index":"my-index"}}
29
+ {"message":"bulk 1","@timestamp":"2026-01-31T12:00:00Z"}
30
+ EOF
31
+ ```
32
+
33
+ Reindex (rename/transform): use `_reindex` with `source` and `dest`.
@@ -0,0 +1,14 @@
1
+ ## Kibana API — quick pointers
2
+
3
+ - Kibana saved objects (dashboards, visualizations, index patterns) are available via the Kibana API on the Kibana host.
4
+
5
+ Example: export a saved object (dashboard):
6
+
7
+ ```bash
8
+ curl -s "${KIBANA_URL%/}/api/saved_objects/_export" \
9
+ -H "kbn-xsrf: true" \
10
+ -H "Content-Type: application/json" \
11
+ -d '{"type":["dashboard"],"objects":[],"includeReferencesDeep":true}' > export.ndjson
12
+ ```
13
+
14
+ Note: Kibana uses `kbn-xsrf` header for non-browser requests and may require a different auth method (API key or session cookie).
@@ -0,0 +1,12 @@
1
+ ## OpenTelemetry & OTEL data
2
+
3
+ Use ES|QL or Query DSL to query OTEL logs/traces stored in Elasticsearch. ES|QL example:
4
+
5
+ ```bash
6
+ curl -s -X POST "${ES_URL%/}/_query" \
7
+ -H "Authorization: ApiKey $(printenv ES_API_KEY)" \
8
+ -H "Content-Type: application/json" \
9
+ -d '{"query":"FROM traces-* | WHERE status.code == \"ERROR\" | STATS count = COUNT(*) BY service.name | LIMIT 10"}' | jq .
10
+ ```
11
+
12
+ Check OTEL index names (`traces-*`, `logs-*`, `metrics-*`) and mappings before querying.
@@ -0,0 +1,21 @@
1
+ ## Query DSL — concise examples
2
+
3
+ Match query:
4
+
5
+ ```bash
6
+ curl -s "${ES_URL%/}/my-index/_search" \
7
+ -H "Authorization: ApiKey $(printenv ES_API_KEY)" \
8
+ -H "Content-Type: application/json" \
9
+ -d '{"query":{"match":{"message":"error"}},"size":10}' | jq .
10
+ ```
11
+
12
+ Bool query (must + filter + must_not):
13
+
14
+ ```bash
15
+ curl -s "${ES_URL%/}/my-index/_search" \
16
+ -H "Authorization: ApiKey $(printenv ES_API_KEY)" \
17
+ -H "Content-Type: application/json" \
18
+ -d '{"query":{"bool":{"must":[{"match":{"message":"error"}}],"filter":[{"range":{"@timestamp":{"gte":"now-1h"}}}],"must_not":[{"term":{"level":"debug"}}]}},"size":20}' | jq .
19
+ ```
20
+
21
+ Sorting and pagination tips: use `size`, `sort`, and prefer `search_after` or PIT for large result sets.