You can publish data as tenant to BAM by only modifying the credetials, which receives the BAM events as tenant and saves in tenant space in cassandra. You can publish the events using in below two different spaces,
WSO2 Stratos Live
Use Local BAM setup
Use Local BAM setup
In this section we shall modify the KPI sample and publish the data as tenant to BAM. Please follow the below instructions to publish data to the tenant space.
Go to KPIAgent.java in directory location $BAM_HOME/samples/kpi-definition/src/main/java/org/wso2/carbon/bam/kpiagent.
Modify the KPIAgent.java as follows:
DataPublisher dataPublisher = new DataPublisher("tcp://" + host + ":7611", "tenantusername@tenantadmin.com", "admin123”, agent);
Here the 'tenantusername' is Tenant username which you have created and 'tenantadmin.com' is the domain name you have registered for the tenant. 'admin123' is the tenant password.Go to $BAM_HOME/samples/kpi-definition/ and run the ant script b typing 'ant' from the command line. This will publish the events to your tenant space.
Go to BAM admin console and login as tenant. The go to Main → Cassandra Explorer → Connect to cluster and login to the cassandra cluster with tenant credentials.
Eg:Connection URL = 9160 + <port-offsett> username = tenantusername@tenantadmin.com password = admin123
- Go to EVENY_KS and view the org_wso2_bam_phone_retail_store_kpi (stream name) column family. And you can see the published data there.