Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit eafcff3

Browse files
author
Chris Wiechmann
committed
On-Demand index creation changed - Using response status in cache
1 parent 31f5af2 commit eafcff3

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

apibuilder4elastic/flows/apim-elk-setup-Create indicies.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@
9797
},
9898
{
9999
"name": "body",
100-
"type": "jsonpath",
101-
"value": "$.indexConfig",
100+
"type": "object",
101+
"value": "{\n \"status\":\"ok\"\n}",
102102
"metaName": "Body",
103103
"metaDescription": "The response payload"
104104
}

logstash/pipelines/BeatsInputPipeline.conf

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,14 @@ filter {
6767
lowercase => [ "[@metadata][regionIndexSuffix]" ]
6868
}
6969
}
70-
# Cache-Lookup if the index for the region has been created before
70+
# Cache-Lookup if the indices for the region has been created before
7171
memcached {
7272
hosts => "${MEMCACHED}"
7373
namespace => "index_status"
74-
get => { "%{logtype}###%{gatewayRegion}" => "[indexExists]" }
75-
}
76-
# If we have nothing in the cache it can be assumed the required indicies do not exists
77-
# call the API at API-Builder to create the required indicies if needed
78-
if !([indexExists]) {
74+
get => { "%{logtype}###%{gatewayRegion}" => "[indicesStatus]" }
75+
}
76+
# Call the API at API-Builder to create the required indicies if needed
77+
if ([indicesStatus][status]!="ok") {
7978
http {
8079
url => "${API_BUILDER_URL}/api/elk/v1/api/index/%{logtype}"
8180
body_format => "json"
@@ -84,7 +83,7 @@ filter {
8483
"region" => "%{[gatewayRegion]}"
8584
}
8685
cacert => "${API_BUILDER_SSL_CERT}"
87-
target_body => "indexExists"
86+
target_body => "indicesStatus"
8887
add_field => { "[@metadata][updateCache]" => "true" }
8988
}
9089
} else {
@@ -101,7 +100,7 @@ filter {
101100
hosts => "${MEMCACHED}"
102101
namespace => "index_status"
103102
ttl => "3600" # Should not be checked anymore for the next hour
104-
set => { "[indexExists]" => "%{logtype}###%{gatewayRegion}" }
103+
set => { "[indicesStatus]" => "%{logtype}###%{gatewayRegion}" }
105104
}
106105
}
107106
# Remove the headers returned by the Logstash HTTP filter - we don't need them

0 commit comments

Comments
 (0)