# updated default configs to capture usage data
diff --git a/api-gateway-config/conf.d/includes/default_validators.conf b/api-gateway-config/conf.d/includes/default_validators.conf
index ff01054..b153c45 100644
--- a/api-gateway-config/conf.d/includes/default_validators.conf
+++ b/api-gateway-config/conf.d/includes/default_validators.conf
@@ -103,6 +103,10 @@
decorator:decorateResponse(ngx.var.validate_request_status, ngx.var.validate_request_response_body)
';
- # Capture the metrics for invalid api requests
- # log_by_lua_file /path/to/log_metrics.lua;
+ # capture usage data
+ log_by_lua '
+ if ( ngx.apiGateway.metrics ~= nil ) then
+ ngx.apiGateway.metrics.captureUsageData()
+ end
+ ';
}
\ No newline at end of file
diff --git a/api-gateway-config/conf.d/marathon_apis.conf b/api-gateway-config/conf.d/marathon_apis.conf
index 5f4275e..230f397 100644
--- a/api-gateway-config/conf.d/marathon_apis.conf
+++ b/api-gateway-config/conf.d/marathon_apis.conf
@@ -63,6 +63,10 @@
return 500 '{"code":$status, "message":"Oops. Something went wrong. Check your URI and try again."}\n';
}
+ set $publisher_org_name 'generic';
+ set $consumer_org_name 'generic-consumer';
+ set $app_name 'generic-app';
+
location / {
# ----------------------------------
# add X-Request-Id header
@@ -87,7 +91,17 @@
proxy_http_version 1.1; # Version 1.1 is recommended for use with keepalive connections.
proxy_set_header Connection "";
+ set $service_id $marathon_app_name;
+ set $service_name $marathon_app_name;
+
proxy_pass http://$marathon_app_name$request_uri;
+
+ # capture usage data
+ log_by_lua '
+ if ( ngx.apiGateway.metrics ~= nil ) then
+ ngx.apiGateway.metrics.captureUsageData()
+ end
+ ';
}
}
@@ -129,6 +143,10 @@
#
# set $marathon_app_name hello-world;
#
+# location ~.*\.(png|jpg|jpeg|js)$ {
+# proxy_pass http://$marathon_app_name$request_uri;
+# }
+#
# location / {
# # ----------------------------------
# # add X-Request-Id header
@@ -168,6 +186,13 @@
# access_by_lua "ngx.apiGateway.validation.validateRequest()";
#
# proxy_pass http://$marathon_app_name$request_uri;
+#
+# # capture usage data
+# log_by_lua '
+# if ( ngx.apiGateway.metrics ~= nil ) then
+# ngx.apiGateway.metrics.captureUsageData()
+# end
+# ';
# }
#}
diff --git a/api-gateway-config/environment.conf.d/api-gateway-env.http.conf b/api-gateway-config/environment.conf.d/api-gateway-env.http.conf
index dfc574c..f18e4da 100644
--- a/api-gateway-config/environment.conf.d/api-gateway-env.http.conf
+++ b/api-gateway-config/environment.conf.d/api-gateway-env.http.conf
@@ -21,4 +21,5 @@
# *
# */
-# TO BE INCLUDED ON HTTP BLOCK
\ No newline at end of file
+# TO BE INCLUDED ON HTTP BLOCK
+more_set_headers 'Server: api-gateway/1.9.3.1';
\ No newline at end of file
diff --git a/init.sh b/init.sh
index 6876a5d..e924d3a 100755
--- a/init.sh
+++ b/init.sh
@@ -44,7 +44,7 @@
while true; do \
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 }' ); \
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; \
- sleep 60; \
+ sleep 6; \
done &
fi