Add logging for analytics
diff --git a/conf.d/api_gateway_logging.conf b/conf.d/api_gateway_logging.conf
index 2d303fe..d8524fc 100644
--- a/conf.d/api_gateway_logging.conf
+++ b/conf.d/api_gateway_logging.conf
@@ -32,4 +32,4 @@
'ua="$http_user_agent" xfwdf="$http_x_forwarded_for" '
'upadd="$upstream_addr" upstat=$upstream_status uprt=$upstream_response_time '
'tenantId="$tenant" tenantNamespace="$tenantNamespace" tenantInstance="$tenantInstance" '
- 'apiId="$apiId" apiKey="$apiKey" reqid="$requestId"';
+ 'apiId="$apiId" apiKey="$apiKey" analyticsUri="$analyticsUri" reqid="$requestId"';
diff --git a/conf.d/managed_endpoints.conf b/conf.d/managed_endpoints.conf
index b002d7b..d76fbad 100644
--- a/conf.d/managed_endpoints.conf
+++ b/conf.d/managed_endpoints.conf
@@ -67,8 +67,9 @@
set $tenantInstance '';
set $apiId '';
set $backendUrl '';
- set $apiKey '';
+ set $apiKey '-';
set $gatewayPath $2;
+ set $analyticsUri '';
set $cors '';
set $cors_methods '';
diff --git a/scripts/lua/routing.lua b/scripts/lua/routing.lua
index 9143487..a246ec1 100644
--- a/scripts/lua/routing.lua
+++ b/scripts/lua/routing.lua
@@ -44,6 +44,7 @@
local red = redis.init(REDIS_HOST, REDIS_PORT, REDIS_PASS, 10000)
local tenantId = ngx.var.tenant
local gatewayPath = ngx.var.gatewayPath
+ ngx.var.analyticsUri = ngx.var.request_uri:gsub("/api/([^/]+)", "")
local resourceKeys = redis.getAllResourceKeys(red, tenantId)
local redisKey = _M.findRedisKey(resourceKeys, tenantId, gatewayPath)
if redisKey == nil then
@@ -95,6 +96,7 @@
if cfUrl ~= nil and cfUrl ~= "" then
local u = url.parse(cfUrl)
redisKey = utils.concatStrings({"resources:", tenant, ":", path, u.path})
+ ngx.var.analyticsUri = (u.path == "") and "/" or u.path
end
for _, key in pairs(resourceKeys) do
if key == redisKey or key == redisKeyWithSlash then