# Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap
metadata:
  name: dash-conf
data:
  deployment.yaml: |
    ################################################################################
    #   Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved
    #
    #   Licensed under the Apache License, Version 2.0 (the \"License\");
    #   you may not use this file except in compliance with the License.
    #   You may obtain a copy of the License at
    #
    #   http://www.apache.org/licenses/LICENSE-2.0
    #
    #   Unless required by applicable law or agreed to in writing, software
    #   distributed under the License is distributed on an \"AS IS\" BASIS,
    #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    #   See the License for the specific language governing permissions and
    #   limitations under the License.
    ################################################################################

      # Carbon Configuration Parameters
    wso2.carbon:
      type: wso2-apim-analytics
        # value to uniquely identify a server
      id: wso2-am-analytics
        # server name
      name: WSO2 API Manager Analytics Server
        # enable/disable hostname verifier
      hostnameVerificationEnabled: false
        # ports used by this server
      ports:
          # port offset
        offset: 3

      # Configuration used for the databridge communication
    databridge.config:
        # No of worker threads to consume events
        # THIS IS A MANDATORY FIELD
      workerThreads: 10
        # Maximum amount of messages that can be queued internally in MB
        # THIS IS A MANDATORY FIELD
      maxEventBufferCapacity: 10000000
        # Queue size; the maximum number of events that can be stored in the queue
        # THIS IS A MANDATORY FIELD
      eventBufferSize: 2000
        # Keystore file path
        # THIS IS A MANDATORY FIELD
      keyStoreLocation : ${sys:carbon.home}/resources/security/wso2carbon.jks
        # Keystore password
        # THIS IS A MANDATORY FIELD
      keyStorePassword : wso2carbon
        # Session Timeout value in mins
        # THIS IS A MANDATORY FIELD
      clientTimeoutMin: 30
        # Data receiver configurations
        # THIS IS A MANDATORY FIELD
      dataReceivers:
      -
          # Data receiver configuration
        dataReceiver:
            # Data receiver type
            # THIS IS A MANDATORY FIELD
          type: Thrift
            # Data receiver properties
          properties:
            tcpPort: '7611'
            sslPort: '7711'

      -
          # Data receiver configuration
        dataReceiver:
            # Data receiver type
            # THIS IS A MANDATORY FIELD
          type: Binary
            # Data receiver properties
          properties:
            tcpPort: '9611'
            sslPort: '9711'
            tcpReceiverThreadPoolSize: '100'
            sslReceiverThreadPoolSize: '100'
            hostName: 0.0.0.0

      # Configuration of the Data Agents - to publish events through databridge
    data.agent.config:
        # Data agent configurations
        # THIS IS A MANDATORY FIELD
      agents:
      -
          # Data agent configuration
        agentConfiguration:
            # Data agent name
            # THIS IS A MANDATORY FIELD
          name: Thrift
            # Data endpoint class
            # THIS IS A MANDATORY FIELD
          dataEndpointClass: org.wso2.carbon.databridge.agent.endpoint.thrift.ThriftDataEndpoint
            # Data publisher strategy
          publishingStrategy: async
            # Trust store path
          trustStorePath: '${sys:carbon.home}/resources/security/client-truststore.jks'
            # Trust store password
          trustStorePassword: 'wso2carbon'
            # Queue Size
          queueSize: 32768
            # Batch Size
          batchSize: 200
            # Core pool size
          corePoolSize: 1
            # Socket timeout in milliseconds
          socketTimeoutMS: 30000
            # Maximum pool size
          maxPoolSize: 1
            # Keep alive time in pool
          keepAliveTimeInPool: 20
            # Reconnection interval
          reconnectionInterval: 30
            # Max transport pool size
          maxTransportPoolSize: 250
            # Max idle connections
          maxIdleConnections: 250
            # Eviction time interval
          evictionTimePeriod: 5500
            # Min idle time in pool
          minIdleTimeInPool: 5000
            # Secure max transport pool size
          secureMaxTransportPoolSize: 250
            # Secure max idle connections
          secureMaxIdleConnections: 250
            # secure eviction time period
          secureEvictionTimePeriod: 5500
            # Secure min idle time in pool
          secureMinIdleTimeInPool: 5000
            # SSL enabled protocols
          sslEnabledProtocols: TLSv1.1,TLSv1.2
            # Ciphers
          ciphers: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
      -
          # Data agent configuration
        agentConfiguration:
            # Data agent name
            # THIS IS A MANDATORY FIELD
          name: Binary
            # Data endpoint class
            # THIS IS A MANDATORY FIELD
          dataEndpointClass: org.wso2.carbon.databridge.agent.endpoint.binary.BinaryDataEndpoint
            # Data publisher strategy
          publishingStrategy: async
            # Trust store path
          trustStorePath: '${sys:carbon.home}/resources/security/client-truststore.jks'
            # Trust store password
          trustStorePassword: 'wso2carbon'
            # Queue Size
          queueSize: 32768
            # Batch Size
          batchSize: 200
            # Core pool size
          corePoolSize: 1
            # Socket timeout in milliseconds
          socketTimeoutMS: 30000
            # Maximum pool size
          maxPoolSize: 1
            # Keep alive time in pool
          keepAliveTimeInPool: 20
            # Reconnection interval
          reconnectionInterval: 30
            # Max transport pool size
          maxTransportPoolSize: 250
            # Max idle connections
          maxIdleConnections: 250
            # Eviction time interval
          evictionTimePeriod: 5500
            # Min idle time in pool
          minIdleTimeInPool: 5000
            # Secure max transport pool size
          secureMaxTransportPoolSize: 250
            # Secure max idle connections
          secureMaxIdleConnections: 250
            # secure eviction time period
          secureEvictionTimePeriod: 5500
            # Secure min idle time in pool
          secureMinIdleTimeInPool: 5000
            # SSL enabled protocols
          sslEnabledProtocols: TLSv1.1,TLSv1.2
            # Ciphers
          ciphers: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256

      # Deployment configuration parameters
    wso2.artifact.deployment:
        # Scheduler update interval
      updateInterval: 5

      # HA Configuration
    state.persistence:
      enabled: false
      intervalInMin: 1
      revisionsToKeep: 2
      persistenceStore: org.wso2.carbon.streaming.integrator.core.persistence.FileSystemPersistenceStore
      config:
        location: siddhi-app-persistence

      # Secure Vault Configuration
    wso2.securevault:
      secretRepository:
        type: org.wso2.carbon.secvault.repository.DefaultSecretRepository
        parameters:
          privateKeyAlias: wso2carbon
          keystoreLocation: ${sys:carbon.home}/resources/security/securevault.jks
          secretPropertiesFile: ${sys:carbon.home}/conf/${sys:wso2.runtime}/secrets.properties
      masterKeyReader:
        type: org.wso2.carbon.secvault.reader.DefaultMasterKeyReader
        parameters:
          masterKeyReaderFile: ${sys:carbon.home}/conf/${sys:wso2.runtime}/master-keys.yaml


    # Data Sources Configuration
    wso2.datasources:
      dataSources:
      # Dashboard data source
      - name: WSO2_DASHBOARD_DB
        description: The datasource used for dashboard feature
        jndiConfig:
          name: jdbc/DASHBOARD_DB
          useJndiReference: true
        definition:
          type: RDBMS
          configuration:
            jdbcUrl: 'jdbc:mysql://wso2apim-with-analytics-rdbms-service:3306/DASHBOARD_DB?useSSL=false'
            username: wso2carbon
            password: wso2carbon
            driverClassName: com.mysql.cj.jdbc.Driver
            maxPoolSize: 20
            idleTimeout: 60000
            connectionTestQuery: SELECT 1
            validationTimeout: 30000
            isAutoCommit: false
      - name: BUSINESS_RULES_DB
        description: The datasource used for dashboard feature
        jndiConfig:
          name: jdbc/BUSINESS_RULES_DB
          useJndiReference: true
        definition:
          type: RDBMS
          configuration:
            jdbcUrl: 'jdbc:mysql://wso2apim-with-analytics-rdbms-service:3306/BUSINESS_RULES_DB?useSSL=false'
            username: wso2carbon
            password: wso2carbon
            driverClassName: com.mysql.cj.jdbc.Driver
            maxPoolSize: 20
            idleTimeout: 60000
            connectionTestQuery: SELECT 1
            validationTimeout: 30000
            isAutoCommit: false

      # carbon metrics data source
      - name: WSO2_METRICS_DB
        description: The datasource used for dashboard feature
        jndiConfig:
          name: jdbc/WSO2MetricsDB
        definition:
          type: RDBMS
          configuration:
            jdbcUrl: 'jdbc:h2:${sys:carbon.home}/wso2/dashboard/database/metrics;AUTO_SERVER=TRUE'
            username: wso2carbon
            password: wso2carbon
            driverClassName: org.h2.Driver
            maxPoolSize: 20
            idleTimeout: 60000
            connectionTestQuery: SELECT 1
            validationTimeout: 30000
            isAutoCommit: false

      - name: WSO2_PERMISSIONS_DB
        description: The datasource used for dashboard feature
        jndiConfig:
          name: jdbc/PERMISSION_DB
          useJndiReference: true
        definition:
          type: RDBMS
          configuration:
            jdbcUrl: 'jdbc:mysql://wso2apim-with-analytics-rdbms-service:3306/PERMISSION_DB?useSSL=false'
            username: wso2carbon
            password: wso2carbon
            driverClassName: com.mysql.cj.jdbc.Driver
            maxPoolSize: 10
            idleTimeout: 60000
            connectionTestQuery: SELECT 1
            validationTimeout: 30000
            isAutoCommit: false

      #Data source for APIM Analytics
      - name: APIM_ANALYTICS_DB
        description: Datasource used for APIM Analytics
        jndiConfig:
          name: jdbc/APIM_ANALYTICS_DB
        definition:
          type: RDBMS
          configuration:
            jdbcUrl: 'jdbc:mysql://wso2apim-with-analytics-rdbms-service:3306/APIM_ANALYTICS_DB?useSSL=false'
            username: wso2carbon
            password: wso2carbon
            driverClassName: com.mysql.cj.jdbc.Driver
            maxPoolSize: 50
            idleTimeout: 60000
            connectionTestQuery: SELECT 1
            validationTimeout: 30000
            isAutoCommit: false

       #Main datasource used in API Manager
      - name: AM_DB
        description: Main datasource used by API Manager
        jndiConfig:
          name: jdbc/AM_DB
        definition:
          type: RDBMS
          configuration:
            jdbcUrl: "jdbc:mysql://wso2apim-with-analytics-rdbms-service:3306/WSO2AM_APIMGT_DB?useSSL=false"
            username: wso2carbon
            password: wso2carbon
            driverClassName: com.mysql.cj.jdbc.Driver
            maxPoolSize: 10
            idleTimeout: 60000
            connectionTestQuery: SELECT 1
            validationTimeout: 30000
            isAutoCommit: false

    wso2.business.rules.manager:
      datasource: BUSINESS_RULES_DB
      # rule template wise configuration for deploying business rules
      deployment_configs:
        -
         # <IP>:<HTTPS Port> of the Worker node
         wso2apim-analytics-service:9444:
           # UUIDs of rule templates that are needed to be deployed on the node
           - stock-data-analysis
           - stock-exchange-input
           - stock-exchange-output
           - identifying-continuous-production-decrease
           - popular-tweets-analysis
           - http-analytics-processing
           - message-tracing-source-template
           - message-tracing-app-template
      # credentials for worker nodes
      username: admin
      password: admin

    wso2.transport.http:
      transportProperties:
        - name: "server.bootstrap.socket.timeout"
          value: 60
        - name: "client.bootstrap.socket.timeout"
          value: 60
        - name: "latency.metrics.enabled"
          value: true

      listenerConfigurations:
        - id: "default"
          host: "0.0.0.0"
          port: 9089

        - id: "default-https"
          host: "0.0.0.0"
          port: 9640
          scheme: https
          keyStoreFile: "${carbon.home}/resources/security/wso2carbon.jks"
          keyStorePassword: wso2carbon
          certPass: wso2carbon

    ## Dashboard data provider authorization
    data.provider.configs:
      authorizingClass: org.wso2.analytics.apim.dashboards.core.data.provider.Authorizer

    ## Additional APIs that needs to be added to the server.
    ## Should be provided as a key value pairs { API context path: Microservice implementation class }
    ## The configured APIs will be available as https://{host}:{port}/analytics-dashboard/{API_context_path}
    additional.apis:
      /apis/analytics/v1.0/apim: org.wso2.analytics.apim.rest.api.proxy.ApimApi
      /apis/v1.0/report: org.wso2.analytics.apim.rest.api.report.ReportApi

    report:
      implClass: org.wso2.analytics.apim.rest.api.report.reportgen.DefaultReportGeneratorImpl

    ## Authentication configuration
    auth.configs:
      type: apim
      ssoEnabled: true
      properties:
        adminScope: apim_analytics:admin_carbon.super
        allScopes: apim_analytics:admin openid apim:api_view apim:subscribe apim_analytics:monitoring_dashboard:own apim_analytics:monitoring_dashboard:edit apim_analytics:monitoring_dashboard:view apim_analytics:business_analytics:own apim_analytics:business_analytics:edit apim_analytics:business_analytics:view apim_analytics:api_analytics:own apim_analytics:api_analytics:edit apim_analytics:api_analytics:view apim_analytics:application_analytics:own apim_analytics:application_analytics:edit apim_analytics:application_analytics:view
        adminUsername: admin
        adminPassword: admin
        kmDcrUrl: https://wso2apim:9443/client-registration/v0.17/register
        kmTokenUrlForRedirection: https://wso2apim:32001/oauth2
        kmTokenUrl: https://wso2apim:9443/oauth2
        kmUsername: admin
        kmPassword: admin
        portalAppContext: analytics-dashboard
        businessRulesAppContext : business-rules
        cacheTimeout: 30
        baseUrl: https://wso2apim-analytics:32201
        grantType: authorization_code
        publisherUrl: https://wso2apim:9443
        devPortalUrl: https://wso2apim:9443
        externalLogoutUrl: https://wso2apim:32001/oidc/logout

    wso2.dashboard:
      roles:
        creators:
          - apim_analytics:admin_carbon.super
      themeConfigProviderClass: org.wso2.carbon.dashboards.core.DefaultDashboardThemeConfigProvider
