Skip to content

Commit 3d4919f

Browse files
committed
Add processor for health_status field in status_change_logs data stream
1 parent 425b6a3 commit 3d4919f

File tree

4 files changed

+48
-17
lines changed

4 files changed

+48
-17
lines changed

packages/elastic_agent/changelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# newer versions go on top
22
- version: "2.6.7"
33
changes:
4-
- description: Adds health_status field to status change logs data stream
4+
- description: Adds processor for health_status field to status change logs data stream
55
type: enhancement
66
link: https://github.com/elastic/integrations/pull/15852
77
- version: "2.6.6"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
description: Pipeline for Elastic Agent status change logs.
3+
processors:
4+
- script:
5+
description: Derive health_status from status field
6+
if: ctx.status != null
7+
lang: painless
8+
source: |
9+
String status = ctx.status;
10+
String healthStatus;
11+
12+
switch (status) {
13+
case 'online':
14+
healthStatus = 'healthy';
15+
break;
16+
case 'error':
17+
case 'degraded':
18+
healthStatus = 'unhealthy';
19+
break;
20+
case 'updating':
21+
case 'enrolling':
22+
case 'unenrolling':
23+
healthStatus = 'updating';
24+
break;
25+
default:
26+
healthStatus = status;
27+
}
28+
29+
ctx.health_status = healthStatus;
30+
ignore_failure: true
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
2-
"@timestamp": 1576280412771,
3-
"data_stream": {
4-
"type": "logs",
5-
"dataset": "elastic_agent.status_change",
6-
"namespace": "default"
7-
},
8-
"agent": {
9-
"id": "f2b3c4d5-e6f7-8a9b-b0c1-d2e3f4g5h6i7"
10-
},
11-
"status": "HEALTHY",
12-
"policy_id": "test-policy",
13-
"agentless": false,
14-
"space_id": "default",
15-
"hostname": "test-host"
16-
}
2+
"@timestamp": 1576280412771,
3+
"data_stream": {
4+
"type": "logs",
5+
"dataset": "elastic_agent.status_change",
6+
"namespace": "default"
7+
},
8+
"agent": {
9+
"id": "f2b3c4d5-e6f7-8a9b-b0c1-d2e3f4g5h6i7"
10+
},
11+
"status": "online",
12+
"health_status": "healthy",
13+
"policy_id": "test-policy",
14+
"agentless": false,
15+
"space_id": "default",
16+
"hostname": "test-host"
17+
}

packages/elastic_agent/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ format_version: 3.5.0
77
categories: ["elastic_stack"]
88
conditions:
99
kibana:
10-
version: "^9.2.2 || ^9.3.0"
10+
version: "^8.15.0 || ^9.0.0"
1111
elastic:
1212
subscription: basic
1313
owner:

0 commit comments

Comments
 (0)