Skip to content

Commit 2ad7177

Browse files
thekofimensahmarciwCopilot
authored
[DOCS] Opster Migration: Add errors to troubleshooting pages (#1116)
- Created a new `Errors` section in troubleshooting with specific errors inside - Added to security troubleshooting 2 errors, attempting to follow existing formatting Attempted to follow https://docs.elastic.dev/content-architecture/content-type/troubleshooting/error Via discussion with @marciw , this section is still being organized so these may be moved around. --------- Co-authored-by: Marci W <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 4a1a822 commit 2ad7177

File tree

7 files changed

+518
-0
lines changed

7 files changed

+518
-0
lines changed
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
---
2+
applies_to:
3+
stack:
4+
deployment:
5+
eck:
6+
ess:
7+
ece:
8+
self:
9+
navigation_title: "Error: All shards failed"
10+
---
11+
12+
# Fix error: All shards failed [all-shards-failed]
13+
14+
```console
15+
Error: all shards failed
16+
```
17+
18+
The `all shards failed` error indicates that {{es}} couldn't get a successful response from any of the shards involved in the query. Possible causes include shard allocation issues, misconfiguration, insufficient resources, or unsupported operations such as aggregating on text fields.
19+
20+
## Unsupported operations on text fields
21+
22+
The `all shards failed` error can occur when you try to sort or aggregate on `text` fields. These fields are designed for full-text search and don't support exact-value operations like sorting and aggregation.
23+
24+
To fix this issue, use a `.keyword` subfield:
25+
26+
```console
27+
GET my-index/_search
28+
{
29+
"aggs": {
30+
"names": {
31+
"terms": {
32+
"field": "name.keyword"
33+
}
34+
}
35+
}
36+
}
37+
```
38+
39+
If no `.keyword` subfield exists, define a [multi-field](elasticsearch://reference/elasticsearch/mapping-reference/field-data-types.md#types-multi-fields) mapping:
40+
41+
```console
42+
PUT my-index
43+
{
44+
"mappings": {
45+
"properties": {
46+
"name": {
47+
"type": "text",
48+
"fields": {
49+
"keyword": {
50+
"type": "keyword"
51+
}
52+
}
53+
}
54+
}
55+
}
56+
}
57+
```
58+
59+
### Metric aggregations on text fields
60+
61+
The `all shards failed` error can also occur when you use a metric aggregation on a text field. [Metric aggregations](elasticsearch://reference/aggregations/metrics.md) require numeric fields.
62+
63+
You can use a script to convert the text value to a number at query time:
64+
65+
```console
66+
GET my-index/_search
67+
{
68+
"aggs": {
69+
"total_cost": {
70+
"sum": {
71+
"script": {
72+
"source": "Integer.parseInt(doc.cost.value)"
73+
}
74+
}
75+
}
76+
}
77+
}
78+
```
79+
80+
Or change the field mapping to a numeric type:
81+
82+
```console
83+
PUT my-index
84+
{
85+
"mappings": {
86+
"properties": {
87+
"cost": {
88+
"type": "integer"
89+
}
90+
}
91+
}
92+
}
93+
```
94+
95+
## Failed shard recovery
96+
97+
A shard failure during recovery can prevent successful queries.
98+
99+
To identify the cause, check the cluster health:
100+
101+
```console
102+
GET _cluster/health
103+
```
104+
105+
As a last resort, you can delete the problematic index.
106+
107+
## Misused global aggregation
108+
109+
[Global aggregations](elasticsearch://reference/aggregations/search-aggregations-bucket-global-aggregation.md) must be defined at the top level of the aggregations object. Nesting can cause errors.
110+
111+
To fix this issue, structure the query so that the `global` aggregation appears at the top level:
112+
113+
```console
114+
GET my-index/_search
115+
{
116+
"size": 0,
117+
"aggs": {
118+
"all_products": {
119+
"global": {},
120+
"aggs": {
121+
"genres": {
122+
"terms": {
123+
"field": "cost"
124+
}
125+
}
126+
}
127+
}
128+
}
129+
}
130+
```
131+
132+
## Reverse_nested usage errors
133+
134+
Using a [`reverse_nested`](elasticsearch://reference/aggregations/search-aggregations-bucket-reverse-nested-aggregation.md) aggregation outside of a `nested` context causes errors.
135+
136+
To fix this issue, structure the query so that the `reverse_nested` aggregation is inside a `nested` aggregation:
137+
138+
```console
139+
GET my-index/_search
140+
{
141+
"aggs": {
142+
"comments": {
143+
"nested": {
144+
"path": "comments"
145+
},
146+
"aggs": {
147+
"top_usernames": {
148+
"terms": {
149+
"field": "comments.username"
150+
},
151+
"aggs": {
152+
"comment_issue": {
153+
"reverse_nested": {},
154+
"aggs": {
155+
"top_tags": {
156+
"terms": {
157+
"field": "tags"
158+
}
159+
}
160+
}
161+
}
162+
}
163+
}
164+
}
165+
}
166+
}
167+
}
168+
```
169+
170+
## Further troubleshooting
171+
172+
Use the `_cat/shards` API to view shard status and troubleshoot further.
173+
174+
```console
175+
GET _cat/shards
176+
```
177+
178+
For a specific index:
179+
180+
```console
181+
GET _cat/shards/my-index
182+
```
183+
184+
Example output:
185+
186+
```console-result
187+
my-index 5 p STARTED 0 283b 127.0.0.1 ziap
188+
my-index 5 r UNASSIGNED
189+
my-index 2 p STARTED 1 3.7kb 127.0.0.1 ziap
190+
my-index 2 r UNASSIGNED
191+
my-index 3 p STARTED 3 7.2kb 127.0.0.1 ziap
192+
my-index 3 r UNASSIGNED
193+
my-index 1 p STARTED 1 3.7kb 127.0.0.1 ziap
194+
my-index 1 r UNASSIGNED
195+
my-index 4 p STARTED 2 3.8kb 127.0.0.1 ziap
196+
my-index 4 r UNASSIGNED
197+
my-index 0 p STARTED 0 283b 127.0.0.1 ziap
198+
my-index 0 r UNASSIGNED
199+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
navigation_title: Error reference
3+
---
4+
5+
# Troubleshoot common errors in {{es}}
6+
7+
Use the topics in this section to troubleshoot common errors in {{es}} deployments.
8+
9+
* [](/troubleshoot/elasticsearch/all-shards-failed.md)
10+
* [](/troubleshoot/elasticsearch/failed-to-parse-field-of-type.md)
11+
* [](/troubleshoot/elasticsearch/unable-to-retrieve-node-fs-stats.md)
12+
* [](/troubleshoot/elasticsearch/unable-to-parse-response-body.md)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
applies_to:
3+
stack:
4+
deployment:
5+
eck:
6+
ess:
7+
ece:
8+
self:
9+
navigation_title: "Error: Failed to parse field of type in document with id"
10+
---
11+
12+
# Fix error: Failed to parse field [failed-to-parse-field-of-type]
13+
14+
```console
15+
Error: failed to parse field [field] of type [type] in document with id [id]
16+
```
17+
18+
This error occurs when you try to index a document, but one of the field values doesn't match the expected data type. {{es}} rejects the document when it encounters incompatible values, like a string in a numeric field or an invalid IP address.
19+
20+
To fix this issue, make sure each field value matches the data type defined in the mapping.
21+
22+
## Field types and mapping
23+
24+
When no explicit mapping exists, {{es}} uses [dynamic mappings](../../manage-data/data-store/mapping/dynamic-field-mapping.md) to infer a field's type based on the **first value indexed**.
25+
26+
For example, if you index:
27+
28+
```console
29+
PUT test/_doc/1
30+
{
31+
"ip_address": "179.152.62.82",
32+
"boolean_field": "off"
33+
}
34+
```
35+
36+
Without explicit mapping, {{es}} will treat `ip_address` and `boolean_field` as `text`, which might not be the intended result.
37+
38+
To avoid this, define the mapping explicitly:
39+
40+
```console
41+
PUT test
42+
{
43+
"mappings": {
44+
"properties": {
45+
"ip_address": { "type": "ip" },
46+
"boolean_field": { "type": "boolean" }
47+
}
48+
}
49+
}
50+
```
51+
52+
To check the data type of the field causing the error, first get the mapping:
53+
54+
```console
55+
GET your-index-name/_mapping
56+
```
57+
58+
Make sure the incoming data matches the expected type. If not, you'll need to fix the data or update the mapping. If necessary, create a new index with the correct mapping and reindex your data.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
applies_to:
3+
stack:
4+
deployment:
5+
eck:
6+
ess:
7+
ece:
8+
self:
9+
navigation_title: "Error: Token invalid or expired"
10+
---
11+
12+
# Fix errors: Invalid token or token expired in {{es}} [token-invalid-expired]
13+
14+
```console
15+
Error: token expired
16+
```
17+
18+
```console
19+
Error: invalid token
20+
```
21+
22+
These errors occur when {{es}} receives a request containing an invalid or expired token during authentication. They're typically caused by missing, incorrect, or outdated tokens. If an invalid or expired token is used, {{es}} rejects the request.
23+
24+
## Invalid token
25+
26+
{{es}} rejects requests with invalid authentication tokens. Common causes include:
27+
28+
- The token is expired or revoked
29+
- The token format is incorrect or malformed
30+
- The Authorization header is missing or doesn’t start with Bearer
31+
- The client or middleware failed to attach the token properly
32+
- Security settings in {{es}} are misconfigured
33+
34+
To resolve this error:
35+
36+
- Verify the token and ensure it's correctly formatted and current.
37+
- Check expiration and generate a new token if needed.
38+
- Inspect your client and confirm the token is sent in the `Authorization` header.
39+
- Review {{es}} settings and check that token auth is enabled:
40+
41+
```yaml
42+
xpack.security.authc.token.enabled: true
43+
```
44+
45+
- Use logs for details: {{es}} logs may provide context about the failure.
46+
47+
48+
## Token expired
49+
50+
This error occurs when {{es}} receives a request containing an expired token during authentication.
51+
52+
To resolve this issue:
53+
54+
- Refresh the token, and obtain a new token using your token refresh workflow.
55+
- Implement automatic token refresh and ensure your application is configured to refresh tokens before expiration.
56+
- Avoid using expired tokens and do not reuse tokens after logout or expiration.
57+
- Adjust token lifespan if needed and configure a longer token expiration in `elasticsearch.yml`, though this should be balanced against security needs:
58+
59+
```yaml
60+
xpack.security.authc.token.timeout: 20m
61+
```
62+

0 commit comments

Comments
 (0)