@techwavedev/agi-agent-kit 1.1.7 → 1.2.1
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.
Potentially problematic release.
This version of @techwavedev/agi-agent-kit might be problematic. Click here for more details.
- package/CHANGELOG.md +82 -1
- package/README.md +190 -12
- package/bin/init.js +30 -2
- package/package.json +6 -3
- package/templates/base/AGENTS.md +54 -23
- package/templates/base/README.md +325 -0
- package/templates/base/directives/memory_integration.md +95 -0
- package/templates/base/execution/memory_manager.py +309 -0
- package/templates/base/execution/session_boot.py +218 -0
- package/templates/base/execution/session_init.py +320 -0
- package/templates/base/skill-creator/SKILL_skillcreator.md +23 -36
- package/templates/base/skill-creator/scripts/init_skill.py +18 -135
- package/templates/skills/ec/README.md +31 -0
- package/templates/skills/ec/aws/SKILL.md +1020 -0
- package/templates/skills/ec/aws/defaults.yaml +13 -0
- package/templates/skills/ec/aws/references/common_patterns.md +80 -0
- package/templates/skills/ec/aws/references/mcp_servers.md +98 -0
- package/templates/skills/ec/aws-terraform/SKILL.md +349 -0
- package/templates/skills/ec/aws-terraform/references/best_practices.md +394 -0
- package/templates/skills/ec/aws-terraform/references/checkov_reference.md +337 -0
- package/templates/skills/ec/aws-terraform/scripts/configure_mcp.py +150 -0
- package/templates/skills/ec/confluent-kafka/SKILL.md +655 -0
- package/templates/skills/ec/confluent-kafka/references/ansible_playbooks.md +792 -0
- package/templates/skills/ec/confluent-kafka/references/ec_deployment.md +579 -0
- package/templates/skills/ec/confluent-kafka/references/kraft_migration.md +490 -0
- package/templates/skills/ec/confluent-kafka/references/troubleshooting.md +778 -0
- package/templates/skills/ec/confluent-kafka/references/upgrade_7x_to_8x.md +488 -0
- package/templates/skills/ec/confluent-kafka/scripts/kafka_health_check.py +435 -0
- package/templates/skills/ec/confluent-kafka/scripts/upgrade_preflight.py +568 -0
- package/templates/skills/ec/confluent-kafka/scripts/validate_config.py +455 -0
- package/templates/skills/ec/consul/SKILL.md +427 -0
- package/templates/skills/ec/consul/references/acl_setup.md +168 -0
- package/templates/skills/ec/consul/references/ha_config.md +196 -0
- package/templates/skills/ec/consul/references/troubleshooting.md +267 -0
- package/templates/skills/ec/consul/references/upgrades.md +213 -0
- package/templates/skills/ec/consul/scripts/consul_health_report.py +530 -0
- package/templates/skills/ec/consul/scripts/consul_status.py +264 -0
- package/templates/skills/ec/consul/scripts/generate_values.py +170 -0
- package/templates/skills/ec/documentation/SKILL.md +351 -0
- package/templates/skills/ec/documentation/references/best_practices.md +201 -0
- package/templates/skills/ec/documentation/scripts/analyze_code.py +307 -0
- package/templates/skills/ec/documentation/scripts/detect_changes.py +460 -0
- package/templates/skills/ec/documentation/scripts/generate_changelog.py +312 -0
- package/templates/skills/ec/documentation/scripts/sync_docs.py +272 -0
- package/templates/skills/ec/documentation/scripts/update_skill_docs.py +366 -0
- package/templates/skills/ec/gitlab/SKILL.md +529 -0
- package/templates/skills/ec/gitlab/references/agent_installation.md +416 -0
- package/templates/skills/ec/gitlab/references/api_reference.md +508 -0
- package/templates/skills/ec/gitlab/references/gitops_flux.md +465 -0
- package/templates/skills/ec/gitlab/references/troubleshooting.md +518 -0
- package/templates/skills/ec/gitlab/scripts/generate_agent_values.py +329 -0
- package/templates/skills/ec/gitlab/scripts/gitlab_agent_status.py +414 -0
- package/templates/skills/ec/jira/SKILL.md +484 -0
- package/templates/skills/ec/jira/references/jql_reference.md +148 -0
- package/templates/skills/ec/jira/scripts/add_comment.py +91 -0
- package/templates/skills/ec/jira/scripts/bulk_log_work.py +124 -0
- package/templates/skills/ec/jira/scripts/create_ticket.py +162 -0
- package/templates/skills/ec/jira/scripts/get_ticket.py +191 -0
- package/templates/skills/ec/jira/scripts/jira_client.py +383 -0
- package/templates/skills/ec/jira/scripts/log_work.py +154 -0
- package/templates/skills/ec/jira/scripts/search_tickets.py +104 -0
- package/templates/skills/ec/jira/scripts/update_comment.py +67 -0
- package/templates/skills/ec/jira/scripts/update_ticket.py +161 -0
- package/templates/skills/ec/karpenter/SKILL.md +301 -0
- package/templates/skills/ec/karpenter/references/ec2nodeclasses.md +421 -0
- package/templates/skills/ec/karpenter/references/migration.md +396 -0
- package/templates/skills/ec/karpenter/references/nodepools.md +400 -0
- package/templates/skills/ec/karpenter/references/troubleshooting.md +359 -0
- package/templates/skills/ec/karpenter/scripts/generate_ec2nodeclass.py +187 -0
- package/templates/skills/ec/karpenter/scripts/generate_nodepool.py +245 -0
- package/templates/skills/ec/karpenter/scripts/karpenter_status.py +359 -0
- package/templates/skills/ec/opensearch/SKILL.md +720 -0
- package/templates/skills/ec/opensearch/references/ml_neural_search.md +576 -0
- package/templates/skills/ec/opensearch/references/operator.md +532 -0
- package/templates/skills/ec/opensearch/references/query_dsl.md +532 -0
- package/templates/skills/ec/opensearch/scripts/configure_mcp.py +148 -0
- package/templates/skills/ec/victoriametrics/SKILL.md +598 -0
- package/templates/skills/ec/victoriametrics/references/kubernetes.md +531 -0
- package/templates/skills/ec/victoriametrics/references/prometheus_migration.md +333 -0
- package/templates/skills/ec/victoriametrics/references/troubleshooting.md +442 -0
- package/templates/skills/knowledge/SKILLS_CATALOG.md +274 -4
- package/templates/skills/knowledge/intelligent-routing/SKILL.md +237 -164
- package/templates/skills/knowledge/parallel-agents/SKILL.md +345 -73
- package/templates/skills/knowledge/plugin-discovery/SKILL.md +582 -0
- package/templates/skills/knowledge/plugin-discovery/scripts/platform_setup.py +1083 -0
- package/templates/skills/knowledge/design-md/README.md +0 -34
- package/templates/skills/knowledge/design-md/SKILL.md +0 -193
- package/templates/skills/knowledge/design-md/examples/DESIGN.md +0 -154
- package/templates/skills/knowledge/notebooklm-mcp/SKILL.md +0 -71
- package/templates/skills/knowledge/notebooklm-mcp/assets/example_asset.txt +0 -24
- package/templates/skills/knowledge/notebooklm-mcp/references/api_reference.md +0 -34
- package/templates/skills/knowledge/notebooklm-mcp/scripts/example.py +0 -19
- package/templates/skills/knowledge/react-components/README.md +0 -36
- package/templates/skills/knowledge/react-components/SKILL.md +0 -53
- package/templates/skills/knowledge/react-components/examples/gold-standard-card.tsx +0 -80
- package/templates/skills/knowledge/react-components/package-lock.json +0 -231
- package/templates/skills/knowledge/react-components/package.json +0 -16
- package/templates/skills/knowledge/react-components/resources/architecture-checklist.md +0 -15
- package/templates/skills/knowledge/react-components/resources/component-template.tsx +0 -37
- package/templates/skills/knowledge/react-components/resources/stitch-api-reference.md +0 -14
- package/templates/skills/knowledge/react-components/resources/style-guide.json +0 -27
- package/templates/skills/knowledge/react-components/scripts/fetch-stitch.sh +0 -30
- package/templates/skills/knowledge/react-components/scripts/validate.js +0 -68
- package/templates/skills/knowledge/self-update/SKILL.md +0 -60
- package/templates/skills/knowledge/self-update/scripts/update_kit.py +0 -103
- package/templates/skills/knowledge/stitch-loop/README.md +0 -54
- package/templates/skills/knowledge/stitch-loop/SKILL.md +0 -235
- package/templates/skills/knowledge/stitch-loop/examples/SITE.md +0 -73
- package/templates/skills/knowledge/stitch-loop/examples/next-prompt.md +0 -25
- package/templates/skills/knowledge/stitch-loop/resources/baton-schema.md +0 -61
- package/templates/skills/knowledge/stitch-loop/resources/site-template.md +0 -104
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: opensearch
|
|
3
|
+
description: OpenSearch specialist covering querying (Query DSL, SQL), performance optimization, cluster management, monitoring, OpenSearch Dashboards, ML/AI (neural search, embeddings, ML Commons), data ingestion (Logstash, Fluent Bit, Data Prepper), OpenSearch Operator for Kubernetes, and MCP integration. Use for any task involving: (1) Writing or optimizing OpenSearch queries, (2) Index design and mapping, (3) Cluster health and performance tuning, (4) OpenSearch Dashboards visualization, (5) Neural/semantic search with vectors, (6) Log and data ingestion pipelines, (7) Kubernetes deployments with OpenSearch Operator.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# OpenSearch Skill
|
|
7
|
+
|
|
8
|
+
Expert-level guidance for OpenSearch operations, from query optimization to ML-powered semantic search.
|
|
9
|
+
|
|
10
|
+
## Quick Reference
|
|
11
|
+
|
|
12
|
+
| Task | Command/Tool |
|
|
13
|
+
| -------------- | ---------------------- |
|
|
14
|
+
| Cluster Health | `GET _cluster/health` |
|
|
15
|
+
| List Indices | `GET _cat/indices?v` |
|
|
16
|
+
| Index Mapping | `GET <index>/_mapping` |
|
|
17
|
+
| Search | `POST <index>/_search` |
|
|
18
|
+
| Bulk Ingest | `POST _bulk` |
|
|
19
|
+
| SQL Query | `POST _plugins/_sql` |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## MCP Server Configuration
|
|
24
|
+
|
|
25
|
+
### Option 1: Standalone MCP Server
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"opensearch-mcp": {
|
|
30
|
+
"command": "npx",
|
|
31
|
+
"args": ["-y", "opensearch-mcp-server"],
|
|
32
|
+
"env": {
|
|
33
|
+
"OPENSEARCH_URL": "https://localhost:9200",
|
|
34
|
+
"OPENSEARCH_USERNAME": "admin",
|
|
35
|
+
"OPENSEARCH_PASSWORD": "${OPENSEARCH_PASSWORD}",
|
|
36
|
+
"OPENSEARCH_SSL_VERIFY": "false"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Option 2: Built-in MCP (OpenSearch 3.0+)
|
|
43
|
+
|
|
44
|
+
Enabled via ML Commons plugin. Configure in `opensearch.yml`:
|
|
45
|
+
|
|
46
|
+
```yaml
|
|
47
|
+
plugins.ml_commons.mcp_server.enabled: true
|
|
48
|
+
plugins.ml_commons.mcp_server.transport.port: 9600
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Run `scripts/configure_mcp.py` to auto-configure.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## MCP Tools
|
|
56
|
+
|
|
57
|
+
| Tool | Purpose |
|
|
58
|
+
| -------------------------- | ------------------------------ |
|
|
59
|
+
| `ListIndexTool` | List all indices with stats |
|
|
60
|
+
| `IndexMappingTool` | Get mapping for specific index |
|
|
61
|
+
| `SearchIndexTool` | Execute Query DSL searches |
|
|
62
|
+
| `ClusterHealthTool` | Check cluster health status |
|
|
63
|
+
| `CountTool` | Count documents matching query |
|
|
64
|
+
| `ExplainTool` | Explain query match scoring |
|
|
65
|
+
| `MsearchTool` | Execute multiple searches |
|
|
66
|
+
| `GetShardsTool` | Get shard information |
|
|
67
|
+
| `GenericOpenSearchApiTool` | Call any OpenSearch API |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Query DSL Patterns
|
|
72
|
+
|
|
73
|
+
### Basic Match Query
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"query": {
|
|
78
|
+
"match": {
|
|
79
|
+
"message": "error connection timeout"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Bool Query (AND/OR/NOT)
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"query": {
|
|
90
|
+
"bool": {
|
|
91
|
+
"must": [{ "match": { "status": "error" } }],
|
|
92
|
+
"should": [
|
|
93
|
+
{ "match": { "service": "api-gateway" } },
|
|
94
|
+
{ "match": { "service": "auth-service" } }
|
|
95
|
+
],
|
|
96
|
+
"must_not": [{ "term": { "environment": "development" } }],
|
|
97
|
+
"filter": [{ "range": { "@timestamp": { "gte": "now-1h" } } }],
|
|
98
|
+
"minimum_should_match": 1
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Aggregations
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"size": 0,
|
|
109
|
+
"aggs": {
|
|
110
|
+
"status_codes": {
|
|
111
|
+
"terms": { "field": "response.status_code" },
|
|
112
|
+
"aggs": {
|
|
113
|
+
"avg_duration": { "avg": { "field": "duration_ms" } }
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"requests_over_time": {
|
|
117
|
+
"date_histogram": {
|
|
118
|
+
"field": "@timestamp",
|
|
119
|
+
"fixed_interval": "5m"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Full-Text with Highlighting
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"query": {
|
|
131
|
+
"multi_match": {
|
|
132
|
+
"query": "kubernetes deployment failed",
|
|
133
|
+
"fields": ["title^2", "description", "logs"]
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"highlight": {
|
|
137
|
+
"fields": {
|
|
138
|
+
"description": {},
|
|
139
|
+
"logs": { "fragment_size": 150 }
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
See `references/query_dsl.md` for complete patterns.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Index Design
|
|
150
|
+
|
|
151
|
+
### Mapping Best Practices
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
PUT /logs-2024.01
|
|
155
|
+
{
|
|
156
|
+
"settings": {
|
|
157
|
+
"number_of_shards": 3,
|
|
158
|
+
"number_of_replicas": 1,
|
|
159
|
+
"refresh_interval": "30s",
|
|
160
|
+
"index.mapping.total_fields.limit": 2000
|
|
161
|
+
},
|
|
162
|
+
"mappings": {
|
|
163
|
+
"dynamic": "strict",
|
|
164
|
+
"properties": {
|
|
165
|
+
"@timestamp": { "type": "date" },
|
|
166
|
+
"message": { "type": "text", "analyzer": "standard" },
|
|
167
|
+
"level": { "type": "keyword" },
|
|
168
|
+
"service": { "type": "keyword" },
|
|
169
|
+
"trace_id": { "type": "keyword" },
|
|
170
|
+
"duration_ms": { "type": "long" },
|
|
171
|
+
"metadata": {
|
|
172
|
+
"type": "object",
|
|
173
|
+
"dynamic": true
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Index Templates
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
PUT _index_template/logs-template
|
|
184
|
+
{
|
|
185
|
+
"index_patterns": ["logs-*"],
|
|
186
|
+
"priority": 100,
|
|
187
|
+
"template": {
|
|
188
|
+
"settings": {
|
|
189
|
+
"number_of_shards": 3,
|
|
190
|
+
"number_of_replicas": 1
|
|
191
|
+
},
|
|
192
|
+
"mappings": {
|
|
193
|
+
"properties": {
|
|
194
|
+
"@timestamp": { "type": "date" },
|
|
195
|
+
"message": { "type": "text" }
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Index Lifecycle Management (ISM)
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
PUT _plugins/_ism/policies/log-retention
|
|
206
|
+
{
|
|
207
|
+
"policy": {
|
|
208
|
+
"description": "Log retention policy",
|
|
209
|
+
"default_state": "hot",
|
|
210
|
+
"states": [
|
|
211
|
+
{
|
|
212
|
+
"name": "hot",
|
|
213
|
+
"actions": [],
|
|
214
|
+
"transitions": [
|
|
215
|
+
{ "state_name": "warm", "conditions": { "min_index_age": "7d" } }
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"name": "warm",
|
|
220
|
+
"actions": [
|
|
221
|
+
{ "replica_count": { "number_of_replicas": 0 } },
|
|
222
|
+
{ "force_merge": { "max_num_segments": 1 } }
|
|
223
|
+
],
|
|
224
|
+
"transitions": [
|
|
225
|
+
{ "state_name": "delete", "conditions": { "min_index_age": "30d" } }
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"name": "delete",
|
|
230
|
+
"actions": [{ "delete": {} }]
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Performance Optimization
|
|
240
|
+
|
|
241
|
+
### Query Optimization
|
|
242
|
+
|
|
243
|
+
| Issue | Solution |
|
|
244
|
+
| --------------------- | ------------------------------------------------------- |
|
|
245
|
+
| Slow full-text search | Use `keyword` for exact matches, limit `_source` fields |
|
|
246
|
+
| High memory usage | Avoid `*` wildcards, use pagination with `search_after` |
|
|
247
|
+
| Slow aggregations | Pre-aggregate with transforms, use `doc_values` |
|
|
248
|
+
| Large result sets | Use `scroll` or `point-in-time` for deep pagination |
|
|
249
|
+
|
|
250
|
+
### Shard Sizing
|
|
251
|
+
|
|
252
|
+
- **Target:** 10-50GB per shard
|
|
253
|
+
- **Max docs:** ~2 billion per shard
|
|
254
|
+
- **Rule:** `shards = index_size / 30GB`
|
|
255
|
+
|
|
256
|
+
### Indexing Performance
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
PUT /high-throughput-index/_settings
|
|
260
|
+
{
|
|
261
|
+
"index": {
|
|
262
|
+
"refresh_interval": "30s",
|
|
263
|
+
"translog.durability": "async",
|
|
264
|
+
"translog.sync_interval": "30s"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Search Performance
|
|
270
|
+
|
|
271
|
+
```json
|
|
272
|
+
{
|
|
273
|
+
"_source": ["field1", "field2"],
|
|
274
|
+
"track_total_hits": false,
|
|
275
|
+
"size": 20,
|
|
276
|
+
"query": { ... }
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
See `references/optimization.md` for detailed tuning guide.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## ML/AI & Neural Search
|
|
285
|
+
|
|
286
|
+
### Enable ML Commons
|
|
287
|
+
|
|
288
|
+
```yaml
|
|
289
|
+
# opensearch.yml
|
|
290
|
+
plugins.ml_commons.only_run_on_ml_node: false
|
|
291
|
+
plugins.ml_commons.model_access_control_enabled: true
|
|
292
|
+
plugins.ml_commons.native_memory_threshold: 90
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Deploy Embedding Model
|
|
296
|
+
|
|
297
|
+
```json
|
|
298
|
+
POST /_plugins/_ml/models/_register
|
|
299
|
+
{
|
|
300
|
+
"name": "sentence-transformers/all-MiniLM-L6-v2",
|
|
301
|
+
"version": "1.0.1",
|
|
302
|
+
"model_format": "TORCH_SCRIPT",
|
|
303
|
+
"model_config": {
|
|
304
|
+
"model_type": "bert",
|
|
305
|
+
"embedding_dimension": 384,
|
|
306
|
+
"framework_type": "sentence_transformers"
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Neural Search Pipeline
|
|
312
|
+
|
|
313
|
+
```json
|
|
314
|
+
PUT /_ingest/pipeline/neural-pipeline
|
|
315
|
+
{
|
|
316
|
+
"description": "Generate embeddings for semantic search",
|
|
317
|
+
"processors": [
|
|
318
|
+
{
|
|
319
|
+
"text_embedding": {
|
|
320
|
+
"model_id": "<model_id>",
|
|
321
|
+
"field_map": {
|
|
322
|
+
"description": "description_embedding"
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### KNN Index for Vectors
|
|
331
|
+
|
|
332
|
+
```json
|
|
333
|
+
PUT /semantic-index
|
|
334
|
+
{
|
|
335
|
+
"settings": {
|
|
336
|
+
"index.knn": true,
|
|
337
|
+
"default_pipeline": "neural-pipeline"
|
|
338
|
+
},
|
|
339
|
+
"mappings": {
|
|
340
|
+
"properties": {
|
|
341
|
+
"description": { "type": "text" },
|
|
342
|
+
"description_embedding": {
|
|
343
|
+
"type": "knn_vector",
|
|
344
|
+
"dimension": 384,
|
|
345
|
+
"method": {
|
|
346
|
+
"name": "hnsw",
|
|
347
|
+
"space_type": "cosinesimil",
|
|
348
|
+
"engine": "nmslib",
|
|
349
|
+
"parameters": {
|
|
350
|
+
"ef_construction": 128,
|
|
351
|
+
"m": 16
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Semantic Search Query
|
|
361
|
+
|
|
362
|
+
```json
|
|
363
|
+
{
|
|
364
|
+
"query": {
|
|
365
|
+
"neural": {
|
|
366
|
+
"description_embedding": {
|
|
367
|
+
"query_text": "machine learning for log analysis",
|
|
368
|
+
"model_id": "<model_id>",
|
|
369
|
+
"k": 10
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Hybrid Search (Semantic + Keyword)
|
|
377
|
+
|
|
378
|
+
```json
|
|
379
|
+
{
|
|
380
|
+
"query": {
|
|
381
|
+
"hybrid": {
|
|
382
|
+
"queries": [
|
|
383
|
+
{
|
|
384
|
+
"match": {
|
|
385
|
+
"description": "machine learning"
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"neural": {
|
|
390
|
+
"description_embedding": {
|
|
391
|
+
"query_text": "machine learning",
|
|
392
|
+
"model_id": "<model_id>",
|
|
393
|
+
"k": 10
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
See `references/ml_neural_search.md` for complete ML patterns.
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
## Data Ingestion
|
|
408
|
+
|
|
409
|
+
### Logstash Pipeline
|
|
410
|
+
|
|
411
|
+
```ruby
|
|
412
|
+
input {
|
|
413
|
+
beats { port => 5044 }
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
filter {
|
|
417
|
+
grok {
|
|
418
|
+
match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:level} %{GREEDYDATA:message}" }
|
|
419
|
+
}
|
|
420
|
+
date {
|
|
421
|
+
match => [ "timestamp", "ISO8601" ]
|
|
422
|
+
target => "@timestamp"
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
output {
|
|
427
|
+
opensearch {
|
|
428
|
+
hosts => ["https://opensearch:9200"]
|
|
429
|
+
index => "logs-%{+YYYY.MM.dd}"
|
|
430
|
+
user => "admin"
|
|
431
|
+
password => "${OPENSEARCH_PASSWORD}"
|
|
432
|
+
ssl => true
|
|
433
|
+
ssl_certificate_verification => false
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### Fluent Bit
|
|
439
|
+
|
|
440
|
+
```ini
|
|
441
|
+
[OUTPUT]
|
|
442
|
+
Name opensearch
|
|
443
|
+
Match *
|
|
444
|
+
Host opensearch
|
|
445
|
+
Port 9200
|
|
446
|
+
Index fluent-bit
|
|
447
|
+
HTTP_User admin
|
|
448
|
+
HTTP_Passwd ${OPENSEARCH_PASSWORD}
|
|
449
|
+
tls On
|
|
450
|
+
tls.verify Off
|
|
451
|
+
Suppress_Type_Name On
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Data Prepper
|
|
455
|
+
|
|
456
|
+
```yaml
|
|
457
|
+
# data-prepper-config.yaml
|
|
458
|
+
log-pipeline:
|
|
459
|
+
source:
|
|
460
|
+
otel_logs_source:
|
|
461
|
+
port: 21892
|
|
462
|
+
processor:
|
|
463
|
+
- grok:
|
|
464
|
+
match:
|
|
465
|
+
log: "%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:level}"
|
|
466
|
+
sink:
|
|
467
|
+
- opensearch:
|
|
468
|
+
hosts: ["https://opensearch:9200"]
|
|
469
|
+
username: "admin"
|
|
470
|
+
password: "${OPENSEARCH_PASSWORD}"
|
|
471
|
+
index: "otel-logs"
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Bulk API
|
|
475
|
+
|
|
476
|
+
```bash
|
|
477
|
+
curl -X POST "https://localhost:9200/_bulk" \
|
|
478
|
+
-H "Content-Type: application/x-ndjson" \
|
|
479
|
+
-u admin:$OPENSEARCH_PASSWORD \
|
|
480
|
+
--data-binary @bulk-data.ndjson
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
```json
|
|
484
|
+
{"index":{"_index":"logs","_id":"1"}}
|
|
485
|
+
{"@timestamp":"2024-01-20T00:00:00Z","message":"Log entry 1"}
|
|
486
|
+
{"index":{"_index":"logs","_id":"2"}}
|
|
487
|
+
{"@timestamp":"2024-01-20T00:00:01Z","message":"Log entry 2"}
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
See `references/ingestion.md` for complete patterns.
|
|
491
|
+
|
|
492
|
+
---
|
|
493
|
+
|
|
494
|
+
## OpenSearch Dashboards
|
|
495
|
+
|
|
496
|
+
### Saved Search
|
|
497
|
+
|
|
498
|
+
Create reusable search definitions for:
|
|
499
|
+
|
|
500
|
+
- Log analysis patterns
|
|
501
|
+
- Error tracking queries
|
|
502
|
+
- Performance monitoring
|
|
503
|
+
|
|
504
|
+
### Visualizations
|
|
505
|
+
|
|
506
|
+
| Type | Use Case |
|
|
507
|
+
| ---------- | ----------------------- |
|
|
508
|
+
| Line | Time-series metrics |
|
|
509
|
+
| Bar | Categorical comparisons |
|
|
510
|
+
| Pie | Distribution |
|
|
511
|
+
| Data Table | Detailed breakdowns |
|
|
512
|
+
| Metric | Single KPIs |
|
|
513
|
+
| Gauge | Threshold-based metrics |
|
|
514
|
+
|
|
515
|
+
### Dashboard Best Practices
|
|
516
|
+
|
|
517
|
+
1. **Limit visualizations**: 10-15 per dashboard
|
|
518
|
+
2. **Use time filters**: Global time picker for consistency
|
|
519
|
+
3. **Organize by role**: Create role-specific dashboards
|
|
520
|
+
4. **Performance**: Avoid expensive aggregations
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## Cluster Monitoring
|
|
525
|
+
|
|
526
|
+
### Key Metrics
|
|
527
|
+
|
|
528
|
+
```bash
|
|
529
|
+
# Cluster health
|
|
530
|
+
GET _cluster/health
|
|
531
|
+
|
|
532
|
+
# Node stats
|
|
533
|
+
GET _nodes/stats
|
|
534
|
+
|
|
535
|
+
# Index stats
|
|
536
|
+
GET _stats
|
|
537
|
+
|
|
538
|
+
# Pending tasks
|
|
539
|
+
GET _cluster/pending_tasks
|
|
540
|
+
|
|
541
|
+
# Hot threads
|
|
542
|
+
GET _nodes/hot_threads
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### Alert Conditions
|
|
546
|
+
|
|
547
|
+
| Metric | Warning | Critical |
|
|
548
|
+
| ---------------- | ------- | -------- |
|
|
549
|
+
| Cluster Status | Yellow | Red |
|
|
550
|
+
| Heap Usage | 75% | 90% |
|
|
551
|
+
| Disk Usage | 80% | 90% |
|
|
552
|
+
| Search Latency | 500ms | 2000ms |
|
|
553
|
+
| Indexing Latency | 100ms | 500ms |
|
|
554
|
+
|
|
555
|
+
### Performance Analyzer
|
|
556
|
+
|
|
557
|
+
```bash
|
|
558
|
+
# Enable Performance Analyzer
|
|
559
|
+
curl -X POST "https://localhost:9200/_plugins/_performanceanalyzer/cluster/config" \
|
|
560
|
+
-H "Content-Type: application/json" \
|
|
561
|
+
-d '{"enabled": true}'
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
See `references/monitoring.md` for alerting setup.
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
## OpenSearch Operator (Kubernetes)
|
|
569
|
+
|
|
570
|
+
### Installation
|
|
571
|
+
|
|
572
|
+
```bash
|
|
573
|
+
# Add Helm repo
|
|
574
|
+
helm repo add opensearch-operator https://opster.github.io/opensearch-k8s-operator/
|
|
575
|
+
helm repo update
|
|
576
|
+
|
|
577
|
+
# Install operator
|
|
578
|
+
helm install opensearch-operator opensearch-operator/opensearch-operator \
|
|
579
|
+
--namespace opensearch-operator-system \
|
|
580
|
+
--create-namespace
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### Cluster CRD
|
|
584
|
+
|
|
585
|
+
```yaml
|
|
586
|
+
apiVersion: opensearch.opster.io/v1
|
|
587
|
+
kind: OpenSearchCluster
|
|
588
|
+
metadata:
|
|
589
|
+
name: my-cluster
|
|
590
|
+
namespace: opensearch
|
|
591
|
+
spec:
|
|
592
|
+
general:
|
|
593
|
+
serviceName: my-cluster
|
|
594
|
+
version: 2.11.0
|
|
595
|
+
httpPort: 9200
|
|
596
|
+
vendor: opensearch
|
|
597
|
+
setVMMaxMapCount: true
|
|
598
|
+
dashboards:
|
|
599
|
+
enable: true
|
|
600
|
+
replicas: 1
|
|
601
|
+
version: 2.11.0
|
|
602
|
+
nodePools:
|
|
603
|
+
- component: masters
|
|
604
|
+
replicas: 3
|
|
605
|
+
diskSize: "30Gi"
|
|
606
|
+
roles:
|
|
607
|
+
- master
|
|
608
|
+
- data
|
|
609
|
+
resources:
|
|
610
|
+
requests:
|
|
611
|
+
memory: "4Gi"
|
|
612
|
+
cpu: "1000m"
|
|
613
|
+
limits:
|
|
614
|
+
memory: "4Gi"
|
|
615
|
+
cpu: "2000m"
|
|
616
|
+
persistence:
|
|
617
|
+
storageClass: gp3
|
|
618
|
+
accessModes:
|
|
619
|
+
- ReadWriteOnce
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
### Security Configuration
|
|
623
|
+
|
|
624
|
+
```yaml
|
|
625
|
+
spec:
|
|
626
|
+
security:
|
|
627
|
+
config:
|
|
628
|
+
securityConfigSecret:
|
|
629
|
+
name: security-config
|
|
630
|
+
adminCredentialsSecret:
|
|
631
|
+
name: admin-credentials
|
|
632
|
+
tls:
|
|
633
|
+
transport:
|
|
634
|
+
generate: true
|
|
635
|
+
http:
|
|
636
|
+
generate: true
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
See `references/operator.md` for complete Kubernetes patterns.
|
|
640
|
+
|
|
641
|
+
---
|
|
642
|
+
|
|
643
|
+
## Testing
|
|
644
|
+
|
|
645
|
+
### Query Validation
|
|
646
|
+
|
|
647
|
+
```bash
|
|
648
|
+
# Validate query syntax
|
|
649
|
+
POST /index/_validate/query?explain=true
|
|
650
|
+
{
|
|
651
|
+
"query": { "match": { "field": "value" } }
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
# Profile query execution
|
|
655
|
+
POST /index/_search
|
|
656
|
+
{
|
|
657
|
+
"profile": true,
|
|
658
|
+
"query": { ... }
|
|
659
|
+
}
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
### Performance Testing
|
|
663
|
+
|
|
664
|
+
```bash
|
|
665
|
+
# opensearch-benchmark (rally fork)
|
|
666
|
+
opensearch-benchmark execute-test \
|
|
667
|
+
--pipeline=benchmark-only \
|
|
668
|
+
--target-hosts=https://localhost:9200 \
|
|
669
|
+
--client-options="use_ssl:true,verify_certs:false,basic_auth_user:'admin',basic_auth_password:'admin'"
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
---
|
|
673
|
+
|
|
674
|
+
## Security
|
|
675
|
+
|
|
676
|
+
### Authentication
|
|
677
|
+
|
|
678
|
+
| Method | Configuration |
|
|
679
|
+
| -------------- | --------------------------- |
|
|
680
|
+
| Internal Users | `internal_users.yml` |
|
|
681
|
+
| LDAP | `config.yml` ldap section |
|
|
682
|
+
| SAML | `config.yml` saml section |
|
|
683
|
+
| OpenID | `config.yml` openid section |
|
|
684
|
+
|
|
685
|
+
### Role-Based Access Control
|
|
686
|
+
|
|
687
|
+
```yaml
|
|
688
|
+
# roles.yml
|
|
689
|
+
log_reader:
|
|
690
|
+
cluster_permissions:
|
|
691
|
+
- cluster_composite_ops_ro
|
|
692
|
+
index_permissions:
|
|
693
|
+
- index_patterns:
|
|
694
|
+
- "logs-*"
|
|
695
|
+
allowed_actions:
|
|
696
|
+
- read
|
|
697
|
+
- search
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
### Field-Level Security
|
|
701
|
+
|
|
702
|
+
```yaml
|
|
703
|
+
index_permissions:
|
|
704
|
+
- index_patterns: ["sensitive-*"]
|
|
705
|
+
allowed_actions: ["read"]
|
|
706
|
+
fls:
|
|
707
|
+
- "~password"
|
|
708
|
+
- "~ssn"
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
---
|
|
712
|
+
|
|
713
|
+
## References
|
|
714
|
+
|
|
715
|
+
- [OpenSearch Documentation](https://opensearch.org/docs/latest/)
|
|
716
|
+
- [Query DSL Reference](https://opensearch.org/docs/latest/query-dsl/)
|
|
717
|
+
- [ML Commons](https://opensearch.org/docs/latest/ml-commons-plugin/index/)
|
|
718
|
+
- [OpenSearch Operator GitHub](https://github.com/opensearch-project/opensearch-k8s-operator)
|
|
719
|
+
- [OpenSearch Operator Docs](https://docs.opensearch.org/latest/install-and-configure/install-opensearch/operator/)
|
|
720
|
+
- See `references/` for detailed guides
|