-
Notifications
You must be signed in to change notification settings - Fork 0
/
from-datastreams
67 lines (62 loc) · 1.31 KB
/
from-datastreams
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
input {
# Input for the first data stream
elasticsearch {
hosts => ["http://localhost:9200"]
index => "data_stream_1"
query => '{
"size": 1,
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}'
tags => ["data_stream_1"]
}
# Input for the second data stream
elasticsearch {
hosts => ["http://localhost:9200"]
index => "data_stream_2"
query => '{
"size": 1,
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}'
tags => ["data_stream_2"]
}
# Add more inputs as needed for additional data streams
}
filter {
ruby {
code => '
require "time"
event_time = Time.parse(event.get("@timestamp"))
current_time = Time.now
difference_in_hours = (current_time - event_time) / 3600
status = difference_in_hours > 24 ? "unhealthy" : "healthy"
data_stream = event.get("tags")[0]
event.set("status_object", {
"data_stream" => data_stream,
"status" => status
})
'
}
}
output {
# Output to console for debugging
stdout {
codec => json
}
# Output to Elasticsearch or another destination
elasticsearch {
hosts => ["http://localhost:9200"]
index => "status_entries"
}
}