Skip to content

Latest commit

 

History

History
107 lines (79 loc) · 7.42 KB

43-Multi-Tenancy-Features-Observability.md

File metadata and controls

107 lines (79 loc) · 7.42 KB

Observability

In Test and Troubleshoot, you can find information about out-of-the-box logs provided by SAP BTP Cloud Foundry runtime. These logs are helpful when it comes to ad hoc error analysis. However, they don't allow for sophisticated analyses and are only stored for a specific time.

The SAP Cloud Logging service provides the big picture of the behavior and health of your application, since it offers more features by collecting logs, traces, and metrics in a central place with a longer storage time. In this way, it helps you ensure and improve efficiency, scalability, resilience, and availability.

Note: This service is not intended for the users of the app, but rather the app provider.

To explore this feature with the Poetry Slam Manager, you have two options:

  1. Clone the repository of the Partner Reference Application. Check out the main-multi-tenant branch and enhance the application step by step.

  2. Alternatively, check out the main-multi-tenant-features branch where the feature is already included.

The following describes how to enhance the main-multi-tenant branch (option 1).

Integrate the SAP Cloud Logging Service

The SAP Cloud Logging service is an instance-based and environment-agnostic observability service that stores, visualizes, and helps analyze application logs, metrics, and traces from the SAP BTP Cloud Foundry. The service builds upon OpenSearch, which offers features such as querying, dashboarding, alerting, anomaly detection, and access management.

For more information, refer to the documentation on the SAP Cloud Logging service.

For the Partner Reference Application, an SAP Cloud Logging instance is created with service plan standard using the mta.yaml file:

  1. Enable the SAP Cloud Logging service instance and OpenTelemetry by adding the following code snippet to the resources in the mta.yaml:

    # Cloud Logging Service
    - name: poetry-slams-cloud-logging
      type: org.cloudfoundry.managed-service
      parameters:
        service: cloud-logging
        service-plan: standard
        config:
          ingest_otlp:
            enabled: true
          backend:
            api_enabled: true

    The parameters ingest_otlp and backend are explained in the SAP Cloud Logging configuration documentation. They allow the ingestion of OpenTelemetry data and backend/API access to the SAP Cloud Logging Service.

  2. Add service bindings to all modules that create logs in the SAP Cloud Logging service. For the Poetry Slam Manager, the SAP Cloud Logging service instance is bound to the application service, multitenancy and extensibility tool (mtx-tool), and approuter modules.

    # Service module
    - name: poetry-slams-srv
      requires:
      - name: poetry-slams-cloud-logging
    # MTX module
    - name: poetry-slams-mtx
      requires:
      - name: poetry-slams-cloud-logging
    # Approuter
    - name: poetry-slams
      requires:
      - name: poetry-slams-cloud-logging

Add Telemetry Plugin, Metrics, and Trace Exporters

By enabling the telemetry plugin in your project, various kinds of telemetry data will be automatically collected and exported to the SAP Cloud Logging service.

For more information, refer to the CDS plugin @cap-js/telemetry and Telemetry.

  1. Open a terminal and run the command npm add @cap-js/telemetry. As a result, a dependency to the latest version of the @cap-js/telemetry is added to the package.json of your project.

  2. Add the dependencies for the OpenTelemetry Collector Metrics Exporter and the OpenTelemetry Collector Traces Exporter to the package.json.

    1. Open a terminal.

    2. Run the command npm add @opentelemetry/exporter-metrics-otlp-grpc.

    3. Run the command npm add @opentelemetry/exporter-trace-otlp-grpc.

  3. Make CDS write telemetry data to the SAP Cloud Logging service by adding the following code snippet to the profile [production] in the package.json:

    "telemetry": {
      "kind": "to-cloud-logging"
    }

Note: The OpenTelemetry modules that export metrics and traces, as well as the CAP Telemetry feature, are (as of June 2024) still in beta phase. New releases may include breaking changes.

  1. Build and deploy the multi-tenant application to the provider SAP BTP subaccount.

Access Logs in the SAP Cloud Logging Service

Create a service key for the service instance of the SAP Cloud Logging service:

  1. In your provider subaccount, choose Services and go to Instances and Subscriptions.
  2. In the Instances section, in the row of the SAP Cloud Logging instance, select Actions and choose Create Service Key.
  3. Enter a service key name and choose Create.
  4. Open the Credentials of the SAP Cloud Logging instance.
  5. In the Credentials dialog box, select the previously created key and look for the following fields:
    "dashboards-username": "{{dashboards-username}}",
    "dashboards-password": "{{dashboards-password}}",

To access the OpenSearch Dashboards, click on the link poetry-slams-cloud-logging in the Instances section, and enter the credentials as described above. You will find a list of pre-built OpenSearch Dashboards by navigating to Dashboard in the main menu. The dashboards for Cloud Foundry distinguish between request logs and application logs. Request logs offer detailed information about web requests, such as response times and statuses. The dashboards enable the monitoring of traffic, errors, latency and request rates, facilitating thorough analysis and troubleshooting. If you feel the dashboards are not sufficient, you may create your own.

In addition to the OpenSearch UI you can also access the SAP Cloud Logging Service via API. For this, you will find three additional attributes in the Credentials section of the service key: backend-endpoint, backend-password and backend-username. For documentation on how to use the OpenSearch APIs, you may start at the OpenSearch Query DSL documentation.

For more information, refer to Access and Analyze Observability Data and OpenSearch Dashbords.