Graphrt

Elasticsearch

Query DSL search, count and ES\|QL, get/multi-get documents, cluster health, indices and mappings (ApiKey or basic), agent writes need an opt-in, deletes and bulk are node only, system indices are off limits for agents

Beta v0.1.0 Node.js 16 actions
Use in Graphrt Desktop

About

A Graphrt plugin for the Elasticsearch REST API: Query DSL search, counts, ES|QL, getting and writing documents, and index metadata. It works with self-managed clusters (8.x and 9.x), Elastic Cloud deployments and Elastic Cloud Serverless. It is built with the declarative REST layer (definition.mjs).

What it can do

  • Cluster and indices: get_cluster_info, get_cluster_health, list_indices (_cat/indices as JSON, open and closed indices, hidden and system indices are left out), get_mapping
  • Search: search (Query DSL, sort, search_after, _source filtering, aggregations, highlight, kNN), count, esql_query (ES|QL with ? parameters, agents need an opt-in)
  • Documents: get_document, multi_get, index_document (PUT by id), create_document (generated id), update_document (partial doc merge, optional upsert, no scripts), delete_document (node only), delete_by_query (node only), bulk (NDJSON lines, node only)
  • api_request: any other endpoint, e.g. /<index>/_settings (agents: GET only, on an allowlist)

Actions

Each action is a step you can add to a workflow. Agents can also use most of them as tools.

  • Cluster info elasticsearch.get_cluster_info
  • Cluster health elasticsearch.get_cluster_health
  • List indices elasticsearch.list_indices
  • Get mapping elasticsearch.get_mapping
  • Search elasticsearch.search
  • Count elasticsearch.count
  • ES|QL query elasticsearch.esql_query
  • Get document elasticsearch.get_document
  • Get documents elasticsearch.multi_get
  • Index document elasticsearch.index_document
Show all 16 actions
  • Create document elasticsearch.create_document
  • Update document elasticsearch.update_document
  • Delete document elasticsearch.delete_document
  • Delete by query elasticsearch.delete_by_query
  • Bulk elasticsearch.bulk
  • Elasticsearch REST API request elasticsearch.api_request

Settings

Graphrt starts plugins with a clean environment. Only these values reach the plugin, and secrets stay out of logs.

  • ELASTICSEARCH_URL Optional
    Cluster URL, default http://localhost:9200. Must be https:// (plain http:// only for localhost), no credentials in it.
  • ELASTICSEARCH_API_KEY One auth
    API key, sent as Authorization: ApiKey <key> (the base64 "encoded" value)
  • ELASTICSEARCH_USERNAME One auth
    Basic auth, used when no API key is set
  • ELASTICSEARCH_TOOL_ALLOW_WRITES Optional
    1 lets agent tools index, create and update documents
  • ELASTICSEARCH_TOOL_ALLOW_ESQL Optional
    1 lets agent tools run esql_query (its sources are checked, see Agent policy)
  • ELASTICSEARCH_TOOL_API_EXTRA_PATHS Optional
    More read paths for agent api_request, comma-separated, * = one segment
  • ELASTICSEARCH_PASSWORD

How to use it

In Graphrt Desktop

  1. Open Plugins and search for Elasticsearch.
  2. Click Install and approve it.
  3. Follow the setup steps on the plugin's page, then paste the settings it needs.
  4. Describe a job that needs it, and the builder adds the steps.
Plugins in Graphrt Desktop

With the CLI

terminal
$ graphrt plugin install elasticsearch
workflow.yaml
- id: errors
  type: elasticsearch.search
  index: logs-*
  size: 20
  query: { bool: { filter: [ { term: { level: error } }, { range: { "@timestamp": { gte: now-1h } } } ] } }
  sort: [ { "@timestamp": desc } ]
- id: by_host
  type: elasticsearch.esql_query
  query: "FROM logs-* | WHERE level == ? | STATS c = COUNT(*) BY host.name | SORT c DESC | LIMIT 10"
  params: [error]
- id: save
  type: elasticsearch.index_document
  index: incidents
  doc_id: "{{#run.id#}}"
  document: { summary: "{{#summary.text#}}" }
  refresh: wait_for
Plugins in the docs