Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application owner changes are not reflected in the SubscriptionDataStore application in memory map #2510

Closed
JanithaSampathBandara opened this issue Feb 23, 2024 · 0 comments · Fixed by wso2/carbon-apimgt#12506

Comments

@JanithaSampathBandara
Copy link

Description

Hi Team,

Even though the application owner has been changed from the /admin portal, still observing the previous application owner’s username as applicationOwner and userName in ELK metrics and as the value of $ctx:api.ut.userName in the custom sequence.

Steps to Reproduce

  1. Deploy the sample PizzaShack API.
  2. Engage below sequence in the request flow.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="FowardUsername">
  <property name="UserName" scope="transport" expression="$ctx:api.ut.userName"/>
  <log level="custom">
      <property name="User" expression="$trp:UserName"/>
  </log>
</sequence>
  1. Enable ELK metrics by applying below configs.

deployment.toml

[apim.analytics]
enable = true
type = "elk"

log4j2.properties

appenders=APIM_METRICS_APPENDER, CARBON_CONSOLE, …

appender.APIM_METRICS_APPENDER.type = RollingFile
appender.APIM_METRICS_APPENDER.name = APIM_METRICS_APPENDER
appender.APIM_METRICS_APPENDER.fileName = ${sys:carbon.home}/repository/logs/apim_metrics.log
appender.APIM_METRICS_APPENDER.filePattern = ${sys:carbon.home}/repository/logs/apim_metrics-%d{MM-dd-yyyy}-%i.log
appender.APIM_METRICS_APPENDER.layout.type = PatternLayout
appender.APIM_METRICS_APPENDER.layout.pattern = %d{HH:mm:ss,SSS} [%X{ip}-%X{host}] [%t] %5p %c{1} %m%n
appender.APIM_METRICS_APPENDER.policies.type = Policies
appender.APIM_METRICS_APPENDER.policies.time.type = TimeBasedTriggeringPolicy
appender.APIM_METRICS_APPENDER.policies.time.interval = 1
appender.APIM_METRICS_APPENDER.policies.time.modulate = true
appender.APIM_METRICS_APPENDER.policies.size.type = SizeBasedTriggeringPolicy
appender.APIM_METRICS_APPENDER.policies.size.size=1000MB
appender.APIM_METRICS_APPENDER.strategy.type = DefaultRolloverStrategy
appender.APIM_METRICS_APPENDER.strategy.max = 10

loggers = reporter, AUDIT_LOG, …

logger.reporter.name = org.wso2.am.analytics.publisher.reporter.elk
logger.reporter.level = INFO
logger.reporter.additivity = false
logger.reporter.appenderRef.APIM_METRICS_APPENDER.ref = APIM_METRICS_APPENDER
  1. Create two users called “Test1” and “Test2”
  2. Create an application using “Test1” user and subscribe to PizzaShack API.
  3. Log into the Devportal using “Test1” user, generate a token (both password & client_credentials grant types) and invoke the PizzaShack API.
  4. ELK metrics and property mediator value can be observed as below.

Client Credentials grant type

ELK metrics :

09:36:58,977 [-] [PassThroughMessageProcessor-22] INFO ELKCounterMetric apimMetrics: apim:response, properties :{"apiName":"PizzaShackAPI","proxyResponseCode":200,"destination":"https://localhost:9443/am/sample/pizzashack/v1/api/","apiCreatorTenantDomain":"carbon.super","platform":"Mac OS X","apiMethod":"GET","apiVersion":"1.0.0","gatewayType":"SYNAPSE","apiCreator":"admin","responseCacheHit":false,"backendLatency":341,"correlationId":"036306be-2afc-4b05-b706-64df09c79ca9","requestMediationLatency":5579,"keyType":"PRODUCTION","apiId":"1a74459e-ef9f-4c33-88d5-6351ab106078","applicationName":"TestApplication","targetResponseCode":200,"requestTimestamp":"2024-02-16T04:06:53.035Z","applicationOwner":"Test1","userAgent":"Chrome","userName":"Test1@carbon.super","apiResourceTemplate":"/menu","responseLatency":5927,"regionId":"default","responseMediationLatency":7,"userIp":"127.0.0.1","apiContext":"/pizzashack/1.0.0","applicationId":"3e3198b8-aec1-40e2-922f-0efa6b6d49a9","apiType":"HTTP","properties":{}}

Property mediator value :

INFO - LogMediator {api:PizzaShackAPI:v1.0.0} User = Test1@carbon.super

Password grant type

ELK Metrics :

12:21:53,017 [-] [PassThroughMessageProcessor-46] INFO ELKCounterMetric apimMetrics: apim:response, properties :{"apiName":"PizzaShackAPI","proxyResponseCode":200,"destination":"https://localhost:9443/am/sample/pizzashack/v1/api/", "apiCreatorTenantDomain":"carbon.super","platform":"Other","apiMethod":"GET","apiVersion":"1.0.0","gatewayType":"SYNAPSE","apiCreator":"admin","responseCacheHit":false,"backendLatency":151,"correlationId":"82345f3d-141e-4e3d-8b62-043c3b3e95cb","requestMediationLatency":6233,"keyType":"PRODUCTION","apiId":"1a74459e-ef9f-4c33-88d5-6351ab106078","applicationName":"TestApplication","targetResponseCode":200,"requestTimestamp":"2024-02-16T06:51:44.941Z","applicationOwner":"Test1","userAgent":"curl","userName":"Test1@carbon.super","apiResourceTemplate":"/menu","responseLatency":6977,"regionId":"default","responseMediationLatency":593,"userIp":"127.0.0.1","apiContext":"/pizzashack/1.0.0","applicationId":"3e3198b8-aec1-40e2-922f-0efa6b6d49a9","apiType":"HTTP","properties":{}}

Property mediator value :

INFO - LogMediator {api:PizzaShackAPI:v1.0.0} User = Test1@carbon.super

  1. Change the application owner from “Test1” to “Tes2” from /admin portal.
  2. Log into the Devportal using “Test2” user, generate a token (both password & client_credentials grant types) and invoke the PizzaShack API.
  3. ELK metrics and property mediator values can be observed as below.

Client credentials grant type

ELK Metrics :

09:41:43,958 [-] [PassThroughMessageProcessor-25] INFO ELKCounterMetric apimMetrics: apim:response, properties :{"apiName":"PizzaShackAPI","proxyResponseCode":200,"destination":"https://localhost:9443/am/sample/pizzashack/v1/api/","apiCreatorTenantDomain":"carbon.super","platform":"Mac OS X","apiMethod":"GET","apiVersion":"1.0.0","gatewayType":"SYNAPSE","apiCreator":"admin","responseCacheHit":false,"backendLatency":433,"correlationId":"e0ce7138-9260-49b5-9384-ddc8526723c7","requestMediationLatency":5356,"keyType":"PRODUCTION","apiId":"1a74459e-ef9f-4c33-88d5-6351ab106078","applicationName":"TestApplication","targetResponseCode":200,"requestTimestamp":"2024-02-16T04:11:38.153Z","applicationOwner":"Test1","userAgent":"Chrome","userName":"Test1@carbon.super","apiResourceTemplate":"/menu","responseLatency":5792,"regionId":"default","responseMediationLatency":3,"userIp":"127.0.0.1","apiContext":"/pizzashack/1.0.0","applicationId":"3e3198b8-aec1-40e2-922f-0efa6b6d49a9","apiType":"HTTP","properties":{}}

Property mediator value :

INFO - LogMediator {api:PizzaShackAPI:v1.0.0} User = Test1@carbon.super

Password grant type

ELK Metrics :

12:26:24,006 [-] [PassThroughMessageProcessor-50] INFO ELKCounterMetric apimMetrics: apim:response, properties :{"apiName":"PizzaShackAPI","proxyResponseCode":200,"destination":"https://localhost:9443/am/sample/pizzashack/v1/api/",
"apiCreatorTenantDomain":"carbon.super","platform":"Other","apiMethod":"GET","apiVersion":"1.0.0","gatewayType":"SYNAPSE","apiCreator":"admin","responseCacheHit":false,"backendLatency":72,"correlationId":"2a38e9d3-5e9f-4007-ba86-f8fa460beb7f","requestMediationLatency":28,"keyType":"PRODUCTION","apiId":"1a74459e-ef9f-4c33-88d5-6351ab106078","applicationName":"TestApplication","targetResponseCode":200,"requestTimestamp":"2024-02-16T06:56:23.897Z","applicationOwner":"Test1","userAgent":"curl","userName":"Test2@carbon.super","apiResourceTemplate":"/menu","responseLatency":102,"regionId":"default","responseMediationLatency":2,"userIp":"127.0.0.1","apiContext":"/pizzashack/1.0.0","applicationId":"3e3198b8-aec1-40e2-922f-0efa6b6d49a9","apiType":"HTTP","properties":{}}

Property mediator value :
INFO - LogMediator {api:PizzaShackAPI:v1.0.0} User = Test2@carbon.super

Observations

Eventhough we have changed the application owner, still we can observe the previous owners username in above mentioned ELK metrics and property mediator value.

Note : New application owners username can be observed as expected once the APIM server is restarted. Hence waited for 15 minutes to check whether any caching related issue, but observed the same issue even after 15 minutes. By the way, server restart provides the expected results.

Affected Component

APIM

Version

4.0.0

Environment Details (with versions)

No response

Relevant Log Output

No response

Related Issues

No response

Suggested Labels

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment