View logs

Kalix provides logs that you can view in the Console or access with the CLI. For each service instance we aggregate a maximum of 1MB of log data. You can capture all log output by attaching a logging provider, such as Google Cloud’s operations suite (formerly Stackdriver), as described in Configuring log export.

Aggregated logs

To view aggregated logs:

Browser
  1. From the project Dashboard, select a deployed service.

  2. From the service Overview page, select Logs from the top tab or from the left navigation menu. The Logs table displays logging output, which you can filter with the control on top.

CLI

With a command window set to your project, use the kalix logs command to view the logs for a running service:

kalix logs <<service-name>>

Configuring log export

Kalix supports exporting logs to a log aggregator. Currently the only log aggregator supported is Google Cloud’s operations suite (formerly Stackdriver).

When Kalix exports logs, it places metadata about the logs in a field called kalix. The log message itself is placed into a field called log. If the log message is valid JSON, Kalix will parse that message and place the parsed message in a field called log_processed.

Configure operations suite

Kalix uses the Global operations suite resource. To configure logging, you will first need to create a service account with the roles/logging.logWriter role, and create a service account key to authenticate as that service account. Details on doing this can be found in the Google documentation. We provide simplified steps below.

To set up a service account and generate the key, follow these steps:

  1. Navigate to https://console.cloud.google.com/new tab.

  2. From the blue bar, click the dropdown menu next to Google Cloud Platform.

  3. Click New Project to create a project and save the <gcp-project-id>, which you will need later.

  4. Enter the following gcloud command to set up the gcloud environment:

    gcloud auth login
    gcloud projects list
    gcloud config set project <gcp-project-id>
  5. Enter the following command to create the service account. The example uses the name kalix-log-writer, but you can use any name.

    gcloud iam service-accounts create kalix-log-writer
  6. Enter the following commands to grant the GCP logging writer role to the service account. Substitute your project ID for <gcp-project-id>.

    gcloud projects add-iam-policy-binding <gcp-project-id> \
        --member "serviceAccount:kalix-log-writer@<gcp-project-id>.iam.gserviceaccount.com" \
        --role "roles/logging.logWriter"
  7. Generate a key file for your service account:

    gcloud iam service-accounts keys create keyfile.json \
        --iam-account kalix-log-writer@<gcp-project-id>.iam.gserviceaccount.com

Now that you have a service account key file, you can configure Kalix to use this to export logs:

Browser
  1. Select a project to open the Dashboard.

  2. From the horizontal tabs list, select Integrations.

    This page displays the current log aggregator, if any, and allows you to add or remove new ones.

  3. Click + to open a dialog where you can upload your keyfile.json.

  4. Enter the location of your keyfile.json in the table.

  5. Click Add.

You should now be able to see log output in your operations suite web application.

CLI

After logging into your project, enter the following command:

kalix projects config set log-aggregator --project <project-id> \
      --log-service stackdriver --gcp-key-file keyfile.json

Removing log aggregator configuration

To remove your log aggregator configuration:

Browser
  1. Select a project to open the Dashboard.

  2. From the horizontal tabs list, select Integrations.

  3. Click Delete log aggregator to remove the currently set log aggregator.

CLI

While logged into your project, enter the following command to remove a log aggregator configuration:

kalix projects config unset log-aggregator --project <project-id>