Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: ✉️ : [APIM][Doc] Missing steps in analytics configuration

In WSO2 API Manager 1.10.0 Analytics can be configured using both (WSO2 APIM), you can configure Analytics either via the UI or XML.

Note

If you wish to configure Analytics in WSO2 API Manager via the UI, see Publishing API Runtime Statistics.

Follow the instructions below to configure Analytics in APIM WSO2 API Manager using XML:

  1. Open the <APIM_HOME>/repository/conf/api-manager.xml file.
  2. Carryout Carry out the following configuration changes under the <APIUsageTracking> element in the XML file.
    1. Enable Analytics in APIM by uncommenting and setting the <Enabled> element to true.

      Code Block
      <Enabled>false<<Enabled>true</Enabled>
    2. Define the <DASServerURL> value based on the WSO2 Data Analytics Server (WSO2 DAS) receivers.Example:

      Code Block
      titleExample
      <DASServerURL> {tcp://localhost:7612/,tcp://localhost:7613/} </DASServerURL>
    3. Define the <DASUsername> and <DASPassword> based on the DAS receivers.

    4. Define the <DASRestApiURL> element according to the DAS master node, because this URL is used to fetch data from DAS REST API.

    5. Set <DASRestApiUsername> and <DASRestApiPassword> according the <DASRestApiUsername> and <DASRestApiPassword> element according to the DAS REST API.

    Use the default configurations for the other configurations in this the <APIUsageTracking> section.

    Configure Statistics client.
    By default APIM is configured for the DAS REST client

    Select the RDBMS Client.
    Do this by setting the <StatisticClientProvider> element as follow in the <APIM_HOME>/repository/conf/api-manager.xml file.

    Code Block
    <!-- For APIM implemented Statistic client for DAS REST API -->
    <StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl</StatisticClientProvider>

    Define a datasource for the RDBMS client.
    Do this by adding the following configuration in both the <APIM_HOME>/repository/conf/datasources/master-datasources.xml and <DAS_HOME>/repository/conf/datasources/master-datasources.xml files.

    Code Block<datasource> <name>WSO2AM_STATS_DB</name> <description>The datasource used for registry and user manager</description> <jndiConfig>
    Code Block
    <!--
            API usage tracker configuration used by the DAS data publisher and
            Google Analytics publisher in API gateway.
        -->
        <APIUsageTracking>
    
            <!--
                Below property is used to enable API Manager analytics configuration via api-manager.xml
          
    <name>jdbc/WSO2AM_STATS_DB</name>
         
    </jndiConfig>
     Enabling analytics via a 
    <definition type="RDBMS"> <configuration>
    configuration file can be useful in scenarios such as automated deployments where
               
    <url>jdbc:mysql://localhost:3306/APIM_STAT?autoReconnect=true&</url>
     UI integration is inconvenient.
    
           
    <username>root</username>
         If you uncomment this property, analytics configurations added 
    <password>pass</password>
    via admin-dashboard UI will
             
    <driverClassName>com.mysql.jdbc.Driver</driverClassName>
       get overwritten by tha configuration details provided below when you 
    <maxActive>50</maxActive>
    restart the server.
            -->
     
    <maxWait>60000</maxWait>
           <Enabled>true</Enabled>
    
        
    <testOnBorrow>true</testOnBorrow>
        <!--
            
    <validationQuery>SELECT
     
    1</validationQuery>
       Server URL of the remote DAS/CEP server used to 
    <validationInterval>30000</validationInterval>
    collect statistics. Must
                be specified 
    <defaultAutoCommit>false</defaultAutoCommit>
    in protocol://hostname:port/ format.
    
              
    </configuration>
      An event can 
    </definition> </datasource>
  3. Copy the appropriate RDBMS driver into both the DAS and APIM /repository/components/lib directories.
  4. Deploy CApp
    As the summarization logic is defined in the DAS CApp, you need to depoy it in all the DAS nodes. When configuring Analytics using XML, you need to deploy CApps manually; however, when configuring Analytics via the UI the CApp deployment takes place automatically. The APIM Analytics related CApps are found in the <APIM_HOME>/statistics/ directory. Use the API_Manager_Analytics_RDBMS.car for RDBMS configurations and the API_Manager_Analytics_REST.car for REST client. Use one of the following methods to deploy the CApp into DAS.
  5. Copy the <APIM_HOME>/statistics/API_Manager_Analytics_RDBMS.car file into the <DAS_HOME>/repository/deployment/server/carbonapps directory. If the /carbonapps directory does not exist create the directory. Thereafter restart WSO2 DAS.
  6. Start WSO2 DAS and sign in to the DAS Management Console. Navigate to the main menu and click Carbon Applications. Click Add and deploy the CApp from the <APIM_HOME>/statistics/ directory.

    Code Block<!--
    also be published to multiple Receiver Groups each having 1 or more receivers. Receiver
                Groups are delimited by curly braces whereas receivers are delimited by commas.
            Ex - Multiple Receivers within a single group
             tcp://localhost:7612/,tcp://localhost:7613/,tcp://localhost:7614/
            Ex - Multiple Receiver Groups with two receivers each
                     {tcp://localhost:7612/,tcp://localhost:7613},{tcp://localhost:7712/,tcp://localhost:7713/}
            
    API
    -->
    
    usage
     
    tracker
     
    configuration
     
    used
     
    by
     
    the
     
    DAS
     
    data publisher and
     <DASServerURL>{tcp://localhost:7612/}</DASServerURL>
    
            
    Google
    <!--
    
    Analytics
     
    publisher
     
    in
     
    API
     
    gateway.
         
    -->
       Administrator username 
    <APIUsageTracking>
    to login to the remote DAS server.
       
    <!--
         -->
           
    Below
     
    property
    <DASUsername>admin</DASUsername>
    
    is
    
    
    used
     
    to
     
    enable
     
    API
     
    Manager
     
    analytics
     
    configuration
     
    via
     
    api-manager.xml
    <!--
                
    Enabling
    Administrator 
    analytics
    password 
    via
    to 
    a
    login 
    configuration
    to 
    file
    the 
    can
    remote 
    be
    DAS 
    useful
    server.
    
    in
     
    scenarios
     
    such
     
    as
     
    automated
     
    deployments
     
    where
      -->
            
    <DASPassword>admin</DASPassword>
    
    UI
    
    
    integration
     
    is
     
    inconvenient.
          <!--
            
    If
     
    you
     
    uncomment
     
    this
     
    property,
    DAS 
    analytics
    REST 
    configurations
    API 
    added
    configuration
    
    via
     
    admin-dashboard
     
    UI
     
    will
                 
    get
    Set 
    overwritten
    the 
    by
    values 
    tha configuration details provided below when you restart the server.
    if .'org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl'
                    
    -->
    is used as Statistic Client
        
    <Enabled>true</Enabled>
        -->
         
    <!--
       <DASRestApiURL>https://localhost:9444</DASRestApiURL>
            <DASRestApiUsername>admin</DASRestApiUsername>
       
    Server
     
    URL
     
    of
     
    the
     
    remote
     
    DAS
    <DASRestApiPassword>admin</
    CEP
    DASRestApiPassword>
    
    
    server
     
    used
     
    to
     
    collect
     
    statistics.
     
    Must
       <!--
             
    be
     
    specified
     
    in protocol://hostname:port/ format. An event can also be published to multiple Receiver Groups each having 1 or more receivers. Receiver
     Below property is used to skip trying to connect to event receiver nodes when publishing events even if
                the stats enabled flag is set to true.
          
    Groups
     
    are
     
    delimited
    -->
    
    by
     
    curly
     
    braces
     
    whereas
     
    receivers
     
    are
     
    delimited
     
    by
     
    commas.
    <SkipEventReceiverConnection>false</SkipEventReceiverConnection>
    
           
    Ex
     <!--
    
    Multiple
     
    Receivers
     
    within
     
    a
     
    single
     
    group
           API Usage 
    tcp://localhost:7612/,tcp://localhost:7613/,tcp://localhost:7614/
    Data Publisher.
            
    Ex - Multiple Receiver Groups with two receivers each
    -->
            <PublisherClass>org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher</PublisherClass>
    
            <!--
                If below property set 
    {tcp://localhost:7612/,tcp://localhost:7613},{tcp://localhost:7712/,tcp://localhost:7713/} -->
    to true,then the response message size will be calculated and publish 
            
    <DASServerURL>{tcp://localhost:7612/}</DASServerURL>
        with each successful API invocation event.
    
    <!--
            -->
        
    Administrator
     
    username
     
    to
     
    login
     
    to
    <PublishResponseMessageSize>false</PublishResponseMessageSize>
    
    the
     
    remote
     
    DAS
     
    server.
         <!--
       
    -->
             
    <DASUsername>admin</DASUsername>
        Data publishing stream names and versions 
    <!--
    of API requests, responses and faults. If the default values
       
    Administrator
     
    password
     
    to
     
    login to
              are changed, the 
    remote DAS server
    toolbox also needs to be changed accordingly.
            -->
            
    <DASPassword>admin</DASPassword>
    <Streams>
             
    <!--
       <Request>
             
    DAS
     
    REST
     
    API
     
    configuration
        <Name>org.wso2.apimgt.statistics.request</Name>
                
    Set
     
    the
     
    values
     
    if
     <Version>1.
    'org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl'
    0.0</Version>
                </Request>
       
    is
     
    used
     
    as
     
    Statistic
     
    Client
         <Response>
       
    -->
             
    <DASRestApiURL>https://localhost:9444</DASRestApiURL>
        <Name>org.wso2.apimgt.statistics.response</Name>
        
    <DASRestApiUsername>admin</DASRestApiUsername>
             
    <DASRestApiPassword>admin</DASRestApiPassword>
       <Version>1.0.0</Version>
          
    <!--
          </Response>
          
    Below
     
    property
     
    is
     
    used
     
    to
     
    skip
     
    trying to connect
    <Fault>
    
    to
     
    event receiver
     
    nodes
     
    when
     
    publishing
     
    events
     
    even
     
    if
             <Name>org.wso2.apimgt.statistics.fault</Name>
       
    the
     
    stats
     
    enabled
     
    flag
     
    is
     
    set
     
    to
     
    true.
          <Version>1.0.0</Version>
       
    -->
             
    <SkipEventReceiverConnection>false</SkipEventReceiverConnection>
    </Fault>
                
    <!--
    <Destination>
                
    API
     
    Usage
     
    Data
     
    Publisher.
     <Name>org_wso2_apimgt_statistics_destination</Name>
           
    -->
             
    <PublisherClass>org
    <Version>1.
    wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher</PublisherClass>
    0.0</Version>
               
    <!--
         <BAMProfileName>bam-profile</BAMProfileName>
           
    If
     
    below
     
    property
     
    set
     
    to true,then the response message size will be calculated and publish
     </Destination>
                <Throttle>
             
    with
     
    each
     
    successful
     
    API
     
    invocation
     
    event.
      <Name>org.wso2.apimgt.statistics.throttle</Name>
          
    -->
             
    <PublishResponseMessageSize>false</PublishResponseMessageSize>
     <Version>1.0.0</Version>
           
    <!--
         </Throttle>
               
    Data
     
    publishing
    <Workflow>
    
    stream
     
    names
     
    and
     
    versions
     
    of
     
    API
     
    requests,
     
    responses
     
    and
     
    faults.
     
    If
     
    the
     
    default
     
    values
       <Name>org.wso2.apimgt.statistics.workflow</Name>
                 
    are
     
    changed,
     
    the toolbox also needs to be changed accordingly.
     <Version>1.0.0</Version>
                </Workflow>
     
    -->
           </Streams>
    
    
    <Streams>
        
    <Request> <Name>org.wso2.apimgt.statistics.request</Name> <Version>1.0.0</Version> </Request> <Response> <Name>org.wso2.apimgt.statistics.response</Name> <Version>1.0.0</Version> </Response> <Fault>
    </APIUsageTracking>
  7. Configure the statistics client.

    Localtabgroup
    Localtab
    activetrue
    idRDBMS-stat-client
    titleRDBMS client
    1. Set the RDBMS client using the <StatisticClientProvider> element in the <APIM_HOME>/repository/conf/api-manager.xml file as follows:

      1. By default APIM is configured for the DAS REST client. Therefore, disable the REST client by commenting out the following:

        Code Block
        <!-- For APIM implemented Statistic client for DAS REST API -->
        <!-- StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl</StatisticClientProvider -->
      2. Set the RDBMS client by uncommenting the following:

        Code Block
        <!-- For APIM implemented Statistic client for RDBMS -->
            <StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRdbmsClientImpl</StatisticClientProvider>
    2. Define a datasource for the RDBMS client.
      Do this by adding the following configuration in both the <APIM_HOME>/repository/conf/datasources/master-datasources.xml and <DAS_HOME>/repository/conf/datasources/master-datasources.xml files.

      Code Block
      <datasource>
          <name>WSO2AM_STATS_DB</name>
          <description>The datasource used for registry and user manager</description>
          <jndiConfig>
              
    <Name>org.wso2.apimgt.statistics.fault</Name>
    1. <name>jdbc/WSO2AM_STATS_DB</name>
          </jndiConfig>
          <definition type="RDBMS">
           
    <Version>1.0.0</Version>
    1.    <configuration>
               
    </Fault>
    1.    <url>jdbc:mysql://localhost:3306/APIM_STAT?autoReconnect=true&</url>
               
    <Destination>
    1.    <username>root</username>
                  
    <Name>org_wso2_apimgt_statistics_destination</Name>
    1. <password>pass</password>
                  
    <Version>1.0.0</Version>
    1. <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                  <maxActive>50</maxActive>
         
    <BAMProfileName>bam-profile</BAMProfileName>
    1.          
    </Destination>
    1. <maxWait>60000</maxWait>
                  
    <Throttle>
    1. <testOnBorrow>true</testOnBorrow>
                  
    <Name>org.wso2.apimgt.statistics.throttle</Name>
    1. <validationQuery>SELECT 1</validationQuery>
                  
    <Version>1.0.0</Version>
    1. <validationInterval>30000</validationInterval>
                  
    <
    1. <defaultAutoCommit>false</
    Throttle>
    1. defaultAutoCommit>
              </configuration>
         
    <Workflow>
    1.  
    <Name>org.wso2.apimgt.statistics.workflow</Name> <Version>1.0.0</Version> </Workflow> </Streams> </APIUsageTracking> <!-- For APIM implemented Statistic client for DAS REST API --> <StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl</StatisticClientProvider>
    1. </definition>
      </datasource>
    2. If you are using MySQL as the database, run <APIM_HOME>/dbscript/stat/sql/mysql.sql to create scemas in the database. Use the appropriate script according to your database.
    3. Copy the appropriate RDBMS driver into both the WSO2 DAS and WSO2 APIM /repository/components/lib directories.
    Localtab
    idREST-stat-client
    titleREST client

    Set the REST client using the <StatisticClientProvider> element in the <APIM_HOME>/repository/conf/api-manager.xml file as follows:

    1. By default APIM is configured for the DAS REST client. However, if it has been disabled, enable it by uncommenting the following:

      Code Block
      <!-- For APIM implemented Statistic client for DAS REST 
    RDBMS
    1. API -->
      
    <!--StatisticClientProvider>org
    1. <StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.
    APIUsageStatisticsRdbmsClientImpl</StatisticClientProvider--> Configure analytics in APIM 2.0.x In APIM 2.0.x UI based analytics configuration is not available and need to use XML based configuration. APIM 2.0.x it is compatible to APIM analytics by default. APIM analytics is Special distribute of DAS with additional APIM related functionalities. So here we used APIM-analytics and it can be download from here. To configure analytics follow the below steps. Open <APIM_HOME>/repository/conf/api-manager.xml Find the Tag Analytics in the xml and edit the configuration To enable analytics set Enabled value to true Set the DASServerURL value according to DAS receiversEx: {tcp://localhost:7612/,tcp://localhost:7613/} Set DASUsername and DASPassword according to DAS receivers DASRestApiURL is used to fetch data from DAS REst api Set it as according to DAS master node Set DASRestApiUsername and DASRestApiPassword accroding to DAS REST Leave other configuration as default Configure Statistics client By default APIM is configured for DAS REST client In order to select RDBMS Client set the StatsProviderImpl as follow <!-- For APIM implemented Statistic client for DAS REST API --> <StatsProviderImpl>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl</StatsProviderImpl> Since RDBMS client need to define Datasource, define following configuration on both <APIM_HOME>/repository/conf/datasources/master-datasources.xml and <DAS_HOME> <datasource> <name>WSO2AM_STATS_DB</name> <description>The datasource used for registry and user manager</description> <jndiConfig> <name>jdbc/WSO2AM_STATS_DB</name> </jndiConfig> <definition type="RDBMS"> <configuration> <url>jdbc:mysql://localhost:3306/APIM_STAT?autoReconnect=true&</url> <username>root</username> <password>pass</password> <driverClassName>com.mysql.jdbc.Driver</driverClassName> <maxActive>50</maxActive> <maxWait>60000</maxWait> <testOnBorrow>true</testOnBorrow> <validationQuery>SELECT 1</validationQuery> <validationInterval>30000</validationInterval> <defaultAutoCommit>false</defaultAutoCommit> </configuration> </definition> </datasource>
    1. APIUsageStatisticsRestClientImpl</StatisticClientProvider>
    2. Disable the RDBMS client if it has been already enabled by commenting the following:

      Code Block
      <!-- For APIM implemented Statistic client for RDBMS -->
          <!-- StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRdbmsClientImpl</StatisticClientProvider-->
  8. Deploy CApp.
    As the summarization logic is defined in the DAS CApp, you need to depoy it in all the DAS nodes. When configuring Analytics using XML, you need to deploy the CApp manually.

    Info

    If you were to configure Analytics via the UI the CApp deployment process takes place automatically. 

    Use one of the following methods to deploy the CApp into DAS.

    1. Deploy the CApp via the file system.
      1. Copy the respective CAR file into the <DAS_HOME>/repository/deployment/server/carbonapps directory.

        Stats ClientCAR file
        RDBMS client<APIM_HOME>/statistics/API_Manager_Analytics_RDBMS.car 
        REST client<APIM_HOME>/statistics/API_Manager_Analytics_REST.car
        Tip

        If the /carbonapps directory does not exist create the directory. 

      2. Restart WSO2 DAS.
    2. Deploy the CApp via the UI

      1. Start WSO2 DAS and sign in to the DAS Management Console. 

      2. Navigate to the main menu and click Carbon Applications

      3. Click Add and deploy the CApp which is in the <APIM_HOME>/statistics directory.