Publishing Data to BAM as tenant
 You can publish events to BAM in the tenant mode using WSO2 products or using the samples shipped with WSO2 BAM product packs.
Using a data agent
You can use any configured external data agent to publish data to BAM in the tenant mode. For example, by using the BAM tenant credentials as the data receiver credentials, you can use WSO2 products to publish data to BAM in the tenant mode. Follow the below instructions to publish service statistics to BAM tenant space from WSO2 Application Server.
Configure a service data agent in WSO2 Application Server.  For instructions, on creating a tenant in WSO2 ESB, see Setting up Service Statistics Data Agent.
When configuring the service data agent in WSO2 Application Server, replace the default admin credentials with the credentials of the respective BAM tenant, under Data Receiver Credentials.
Log in to BAM Admin Console using the tenant credentials.
- In the Tools menu, click Connect to cluster, and log in to the Cassandra cluster using the tenant credentials.
- Click EVENT_KS and you can view published data column family under the defined stream name.
Using a sample
By modifying the credentials, you can use the samples shipped with the product pack, to publish data to BAM in the tenant mode. Through these samples, BAM will receive events as tenant, and will save them in tenant space in Cassandra. For an example, modifying the KPI sample to publish data as tenant to BAM is described below.Â
Navigate to
<PRODUCT_HOME>/samples/kpi-definition/src/main/java/org/wso2/carbon/bam/kpiagent/KPIAgent.java
 file.
Modify the default values of the
url
,username
, andpassword
parameters defined in the theKPIAgent.java
file as per the below example:String url = getProperty("url", "tcp://" + host + ":" + "7611"); String username = getProperty("username", "tenantusername@tenantadmin.com"); String password = getProperty("password", "admin123");
In the above example,tenantusername
is the username of the created tenant,tenantadmin.com
is the domain name you have registered for the tenant, andadmin123
is the tenant password.Navigate to
<PRODUCT_HOME>/samples/kpi-definition/
directory and run the Ant script by typingant
from the command line. This will publish the events to your tenant space. Â
Log in to BAM Admin Console using the tenant credentials.
In the Tools menu, click Connect to cluster, and log in to the Cassandra cluster using the tenant credentials. For example:
Connection URL = 9160 + <port-offsett> username = tenantusername@tenantadmin.com password = admin123
- Click EVENT_KS and you can view published data column family under the org_wso2_bam_phone_retail_store_kpi stream name as follows:Â