Skip to content

Commit 0103537

Browse files
committed
# updated default configs to capture usage data
1 parent 6a29798 commit 0103537

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

api-gateway-config/conf.d/includes/default_validators.conf

+6-2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ location @handle_gateway_validation_error {
103103
decorator:decorateResponse(ngx.var.validate_request_status, ngx.var.validate_request_response_body)
104104
';
105105

106-
# Capture the metrics for invalid api requests
107-
# log_by_lua_file /path/to/log_metrics.lua;
106+
# capture usage data
107+
log_by_lua '
108+
if ( ngx.apiGateway.metrics ~= nil ) then
109+
ngx.apiGateway.metrics.captureUsageData()
110+
end
111+
';
108112
}

api-gateway-config/conf.d/marathon_apis.conf

+25
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ server {
6363
return 500 '{"code":$status, "message":"Oops. Something went wrong. Check your URI and try again."}\n';
6464
}
6565

66+
set $publisher_org_name 'generic';
67+
set $consumer_org_name 'generic-consumer';
68+
set $app_name 'generic-app';
69+
6670
location / {
6771
# ----------------------------------
6872
# add X-Request-Id header
@@ -87,7 +91,17 @@ server {
8791
proxy_http_version 1.1; # Version 1.1 is recommended for use with keepalive connections.
8892
proxy_set_header Connection "";
8993

94+
set $service_id $marathon_app_name;
95+
set $service_name $marathon_app_name;
96+
9097
proxy_pass http://$marathon_app_name$request_uri;
98+
99+
# capture usage data
100+
log_by_lua '
101+
if ( ngx.apiGateway.metrics ~= nil ) then
102+
ngx.apiGateway.metrics.captureUsageData()
103+
end
104+
';
91105
}
92106
}
93107

@@ -129,6 +143,10 @@ server {
129143
#
130144
# set $marathon_app_name hello-world;
131145
#
146+
# location ~.*\.(png|jpg|jpeg|js)$ {
147+
# proxy_pass http://$marathon_app_name$request_uri;
148+
# }
149+
#
132150
# location / {
133151
# # ----------------------------------
134152
# # add X-Request-Id header
@@ -168,6 +186,13 @@ server {
168186
# access_by_lua "ngx.apiGateway.validation.validateRequest()";
169187
#
170188
# proxy_pass http://$marathon_app_name$request_uri;
189+
#
190+
# # capture usage data
191+
# log_by_lua '
192+
# if ( ngx.apiGateway.metrics ~= nil ) then
193+
# ngx.apiGateway.metrics.captureUsageData()
194+
# end
195+
# ';
171196
# }
172197
#}
173198

api-gateway-config/environment.conf.d/api-gateway-env.http.conf

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121
# *
2222
# */
2323

24-
# TO BE INCLUDED ON HTTP BLOCK
24+
# TO BE INCLUDED ON HTTP BLOCK
25+
more_set_headers 'Server: api-gateway/1.9.3.1';

init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if [[ -n "${marathon_host}" ]]; then
4444
while true; do \
4545
statsd_host=$(curl -s ${marathon_host}/v2/apps/api-gateway-graphite/tasks | grep 8125 | awk '{for(i=3;i<=NF;++i) printf("%s ", $i) }' | awk '{for(i=1;i<=NF;++i) sub(/\:\d+/,"",$i); print }' ); \
4646
if [[ -n "${statsd_host}" ]]; then python /etc/api-gateway/scripts/python/logger/StatsdLogger.py --statsd-host=${statsd_host} > /var/log/api-gateway/statsd-logger.log; fi; \
47-
sleep 60; \
47+
sleep 6; \
4848
done &
4949
fi
5050

0 commit comments

Comments
 (0)