Observing Your Application with Choreo

Choreo is a digital innovation platform that allows you to develop, deploy, and manage cloud-native applications at scale.

Info: If you already have login access to Choreo, see Observability Overview to observe your Ballerina program in Choreo.

Follow the steps below to observe a Ballerina service without logging in to Choreo.

Step 1 - Creating a Hello World Ballerina Service

Create a hello-world service as given below and save it as hello_world.bal.

Info: Import the ballerinax/choreo module to the Ballerina code as given in the sample below in-order to add the Choreo extension to the executable.

import ballerina/http;
import ballerinax/choreo as _;
service /hello on new http:Listener(9090) {
   resource function get sayHello(http:Caller caller, http:Request req) returns error? {
      check caller->respond("Hello, World!");

Step 2 - Configuring Choreo to Observe a Ballerina Service

Follow the steps below to add observability in the executable created by Ballerina because it is not enabled by default.

Info: For more information on setting up the configurations, see the Choreo observability extension.

  1. Use the –observability-included build flag or add the config below to the Ballerina.toml file.
      observabilityIncluded = true
  2. Add the configuration below to the Config.toml file.

Step 3 - Observing the Ballerina Service

  1. Once the configuration file has been created, execute the command below to pass it to the Ballerina program with the BAL_CONFIG_FILES environment variable.

     $ BAL_CONFIG_FILES=<path-to-conf>/Config.toml bal run --observability-included hello_world.bal

    You view the output below.

     Compiling source
     Running executable
     ballerina: initializing connection with observability backend periscope.choreo.dev:443
     ballerina: visit http://console.choreo.dev/observe/app/918e4591-b7a3-11eb-8af4-bb5c98e5b4d6/918e502d-b7a3-11eb-8af4-bb5c98e5b4d6 to access observability data
     ballerina: started publishing metrics to Choreo
     [ballerina/http] started HTTP/WS listener
  2. Click on the URL provided. You will be directed to the Choreo portal where you can view the metrics and traces exposed via the throughput and latency graphs.

    Note: If you haven’t sent any requests to the Ballerina service, you may see a banner with the message “No request received during the selected time period”.

Step 4 - Sending Few Requests

Execute the cURL command below to send few requests to the http://localhost:9090/hello/sayHello service.

$ curl http://localhost:9090/hello/sayHello

After sending a few requests, you view the graphs rendered with data. The sample Choreo Observability view for the hello_world.bal file is shown below.

Choreo Obserability View

Info: Currently monitoring logs is not supported by default. To enable log monitoring for your service, see Setting up Elastic Stack to configure Elastic Stack.