Fixing Wazuh Dashboard's 'illegal_argument_exception' Error
Resolving a text-field error in Wazuh Dashboard visualizations/sorting via an OpenSearch index mapping fix.
Problem
Certain Wazuh Dashboard visualizations failed to load, and sorting by fields like manager.name/agent.name threw 'illegal_argument_exception: Text fields are not optimised for operations that require per-document field data...', leaving the affected panels empty.
Cause
While fields like manager.name were expected to be of type keyword, after custom index templates or a system update OpenSearch had converted them to type text. Text-type fields don't support the fielddata required for aggregation/sorting by default.
Solution
Solved in two phases: (1) A high-priority (priority: 500) index template was created to guarantee that manager.name is mapped as keyword in all future wazuh-alerts-4.x-* indices. (2) On already-existing indices, fielddata:true was temporarily enabled on manager.name so sorting/aggregation would also work on existing data. Finally, 'Refresh field list' was run for the wazuh-alerts-* index pattern under Stack Management > Index Patterns so the Dashboard would pick up the corrected field types. The full steps and an up-to-date script are shared in the <a href="https://github.com/seyfullahbilgic/Wazuh-Mapping-Fix" target="_blank" rel="noopener">Wazuh-Mapping-Fix repository</a>.
// Faz 1: Gelecekteki indexler icin kalici cozum (Dev Tools)
PUT /_index_template/wazuh_fix_manager
{
"index_patterns": ["wazuh-alerts-4.x-*"],
"priority": 500,
"template": {
"mappings": {
"properties": {
"manager": {
"properties": {
"name": {
"type": "keyword",
"fields": {
"keyword": { "type": "keyword", "ignore_above": 256 }
}
}
}
}
}
}
}
}
// Faz 2: Mevcut indexleri duzeltme
PUT /wazuh-alerts-*/_mapping
{
"properties": {
"manager.name": { "type": "text", "fielddata": true }
}
}
// Faz 3: Stack Management > Index Patterns > wazuh-alerts-*
// "Refresh field list" tiklanir