Skip to content

osquery_manager: map action responses error to ECS error.message - #22748

Draft
marc-gr wants to merge 2 commits into
elastic:mainfrom
marc-gr:osquery-manager-error-ecs
Draft

marc-gr wants to merge 2 commits into
elastic:mainfrom
marc-gr:osquery-manager-error-ecs

Conversation

@marc-gr

@marc-gr marc-gr commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Draft. Do not merge until elastic/kibana#307730 is in a Kibana release and conditions.kibana.version is raised to that release.

Proposed commit message

osquery_manager: map action responses error to ECS error.message

Osquerybeat reports a failed action as a top-level error string, and
the action_responses data stream mapped it as text with a keyword
multi-field. ECS defines error as an object, so any search that spans
this data stream and ECS-conformant indices sees a text vs object
conflict on error.

Rename a string error to error.message in the ingest pipeline and
map error.message from ECS. Documents that already carry an error
object are left alone, so a future osquerybeat that writes
error.message itself keeps working.

This is a breaking change: queries, visualizations and rules that use
error or error.keyword on this data stream must move to
error.message. The Kibana osquery plugin reads error.keyword to
decide per-agent success or failure, so this package must require a
Kibana version that reads error.message.

Background

The *.sections part of the linked issues was fixed in #16650 and #18989
(result data stream). #16650 also described renaming error to
error.message in action_responses, but that change is not in its diff:
on main, error is still text and the pipeline has no rename. This PR
does that remaining part.

What changes for data

Before After
error: "no such table: foo" (text + error.keyword) error.message: "no such table: foo" (ECS, match_only_text)
no error unchanged

Only logs-osquery_manager.action.responses-* changes. The result data
stream, .fleet-actions-results (written by Fleet Server) and the
Kibana-managed .logs-osquery_manager.action.responses index are not
touched by this package.

Downstream impact

Kibana must ship first

The osquery plugin reads the old field shape in four places:

File What it does Effect after this PR
x-pack/platform/plugins/shared/osquery/server/search_strategy/osquery/factory/actions/results/query.action_results.dsl.ts:167 Painless runtime field doc['error.keyword'] → success / error counts per live query New backing indices have no error.keyword mapping, so the script throws and those shards fail. Counts become wrong or the request errors.
x-pack/platform/plugins/shared/osquery/server/lib/get_result_counts_for_actions.ts:123 Same script, for action history counts Same as above.
x-pack/platform/plugins/shared/osquery/public/action_results/transform_status_results.ts:37,65 Row status from fields['error.keyword'], error text from fields.error Failed agents show as success with an empty error column. Silent and misleading.
x-pack/platform/plugins/shared/osquery/public/action_results/enrich_edges.ts:21 Skips enrichment when fields.error is present Expired/skipped logic can overwrite a real error.

query.scheduled_action_results.dsl.ts already uses exists: { field: 'error' }.
exists on an object field matches any subfield, so it should work for both
shapes (not tested here).

The Kibana fix is elastic/kibana#307730 (must land and release first):

  1. The two Painless scripts become a filters aggregation on
    exists: error (same as the scheduled query). This works on old indices
    (error text) and new ones (error.message), and on
    .fleet-actions-results, which Kibana falls back to. Checked on
    Elasticsearch 9.2 with both mappings searched together.
  2. The UI reads the message from error.message, falling back to error,
    and derives the status from that, not from error.keyword.
  3. It does not rely on doc values for error.message: ECS maps it as
    match_only_text, which has none.

Kibana has to read both shapes for good, not only during upgrade. Old
backing indices keep the text mapping until they are deleted, and the
default logs ILM policy has no delete phase.

Other internal products

  • Security Solution osquery response actions (detection rule response
    actions, investigation guides, alert flyout) render results through the
    osquery plugin. They get the fix for free once the plugin reads both
    shapes, and show the same wrong "success" status if they don't.
  • Osquerybeat needs no change: the pipeline handles the string it sends
    today, and leaves an error object alone. Writing error.message at the
    source is optional follow-up work for the beats issue.
  • Fleet / Fleet Server: .fleet-actions-results keeps its own error
    field. The Kibana transform that copies it into
    .logs-osquery_manager.action.responses is not affected.
  • Elastic Defend endpoint actions use .logs-endpoint.action.responses,
    a different index. Not affected.

Customer impact

  • Custom content breaks: saved searches, Lens/TSVB visualizations,
    dashboards, alerting rules, watches, transforms and ES|QL queries that use
    error or error.keyword on logs-osquery_manager.action.responses-*
    stop matching new documents. They must switch to error.message (and use
    exists instead of a keyword term match).
  • Field type conflict inside the data stream: after upgrade, older
    backing indices map error as text and new ones as an object. Data views
    over this data stream show error as a conflict until the old indices are
    deleted. This replaces today's conflict across data streams with one that
    ages out.
  • Upgrade path: Fleet updates the index template on package upgrade.
    text → object is not a compatible mapping change, so Fleet rolls the data
    stream over; new documents land in the new mapping. No reindex is needed.
  • Mixed agent versions: all osquerybeat versions send the string form,
    so the pipeline handles every agent the same way.
  • Version skew: the conditions.kibana.version bump stops this package
    from being installed on a Kibana that cannot read error.message.
    Without it, Kibana would show failed queries as successful.
  • Serverless: same constraint applies. The package must not be promoted
    before the Kibana change is deployed.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines. Blocked on the Kibana PR.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices (no dashboards changed)

Author's Checklist

How to test this PR locally

cd packages/osquery_manager
elastic-package check
elastic-package stack up -d --services elasticsearch
elastic-package test pipeline --data-streams action_responses

Related issues

🤖 Generated with Claude Code

Osquerybeat reports a failed action as a top-level "error" string, and
the action_responses data stream mapped it as text with a keyword
multi-field. ECS defines "error" as an object, so any search that spans
this data stream and ECS-conformant indices sees a text vs object
conflict on "error".

Rename a string "error" to "error.message" in the ingest pipeline and
map "error.message" from ECS. Documents that already carry an "error"
object are left alone, so a future osquerybeat that writes
"error.message" itself keeps working.

This is a breaking change: queries, visualizations and rules that use
"error" or "error.keyword" on this data stream must move to
"error.message". The Kibana osquery plugin reads "error.keyword" to
decide per-agent success or failure, so this package must require a
Kibana version that reads "error.message".

Assisted-By: Claude Code
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

✅ All changelog entries have the correct PR link.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Elastic Docs Style Checker (Vale)

No issues found on modified lines!


The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale.

@infra-vault-gh-plugin-prod

infra-vault-gh-plugin-prod Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

💔 Build Failed

Failed CI Steps

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant