IBM Cloud Docs
Creating a tenant and a target destination

Creating a tenant and a target destination

To manage platform logs that are generated by IBM Cloud® services in a region of IBM Cloud, you must create a tenant in each region that you operate.

A tenant is the account-specific configuration of IBM Cloud Logs Routing running within a region. The tenant configuration includes a maximum of 2 target definitions. The target defines where the logs are routed.

The create request requores that you create a target destination when you create the tenant in a region.

Before you begin

Complete the following steps:

Retrieving the IAM bearer token

You must get an IBM Cloud® Identity and Access Management (IAM) access token to authenticate your requests to the IBM® Cloud Logs Routing service. For more information, see Retrieving an access token.

For example, you can retrieve your IAM bearer token and export it as an environment variable by running the following CLI command:

export IAM_TOKEN=`ibmcloud iam oauth-tokens --output json | jq -r '.iam_token'`

Choosing the management endpoint

A tenant is the account-specific configuration of IBM Cloud Logs Routing running within a region.

To get the details of a tenant in a region, you must use the management endpoint URL for the region where the tenant is configured.

You can use private or public endpoints.

For more information, see Management endpoint URLs.

Creating a tenant and target through the UI

When the IBM Cloud Logs Routing console is first displayed, any existing target information is displayed.

If no target is configured for a region, the region displays the Set target option. When the target is set for the first time, an IBM Cloud Logs Routing tenant is created (onboarded) and the target configured.

To create a tenant and a target for a region, complete the following steps:

  1. Log in to your IBM Cloud account.

  2. Click the Menu icon Menu icon > Observability.

  3. Click Logging > Routing.

  4. Click Set target.

  5. Select an IBM Cloud Logs instance or an IBM Log Analysis instance. This is the instance where you want to receive logs that are routed by IBM Cloud Logs Routing.

    You can select an IBM Log Analysis instance by selecting an instance from the list and an ingestion key. Only IBM Log Analysis instances in your account can be selected by name and ingestion key. If you want to route to an IBM Log Analysis instance in another account, you must select the target by CRN (Cloud Resource Name) and ingestion key. The CRN of an IBM Log Analysis instance can be found by the account administrator of the IBM Log Analysis instance by clicking Menu icon > Resource list and clicking the IBM Log Analysis instance. The CRN can be copied from the Details section.

    You can select a IBM Cloud Logs instance from the list. Before you do, check that you have a service to service authorization defined between the IBM Cloud Logs Routing service and the IBM Cloud Logs instance. For more information, see Creating a S2S authorization to grant access to send logs to IBM Cloud Logs.

  6. Click Save.

When you set a target in the UI, you create a tenant in that region. The name of the tenant is set as region-ID where region is set to the region where you are located when you create the target.

Creating a tenant and target by using the API

Run the following command to create a tenant for the IBM Cloud Logs Routing service by using the private endpoint:

curl -X POST  https://management.private.${REGION}.logs-router.cloud.ibm.com/v1/tenants \
-H "Content-Type: application/json" \
-H "Authorization: ${IAM_TOKEN}" \
-H "IBM-API-Version: API_VERSION_DATE" \
--data '{TARGET_DATA}'

Run the following command to create a tenant for the IBM Cloud Logs Routing service by using the public endpoint:

curl -X POST  https://management.${REGION}.logs-router.cloud.ibm.com/v1/tenants \
--H "Content-Type: application/json" \
-H "Authorization: ${IAM_TOKEN}" \
-H "IBM-API-Version: API_VERSION_DATE" \
--data '{TARGET_DATA}'

Where

  • REGION defines the location where the tenant is configured.
  • IAM_TOKEN defines the credentials that you use to authenticate your requests.
  • API_VERSION_DATE defines the date of the API version that you want to use to query your tenant definition. The format must be as follows: YYYY-MM-DD
  • TARGET_DATA defines the information about the target destination.

IBM Cloud Logs destination

For a target that defines an IBM Cloud Logs destination, the TARGET_DATA format is as follows:

{
    "name": "TENANT_NAME",
    "targets": [
        {
            "log_sink_crn": "CLOUD_LOGS_INSTANCE_CRN",
            "name": "TARGET_NAME",
            "parameters": {
                "host": "CLOUD_LOGS_INSTANCE_INGRESS_ENDPOINT",
                "port": CLOUD_LOGS_INSTANCE_TARGET_PORT
            }
        }
    ]
}

Where

  • TENANT_NAME: Name of the tenant. The name must be unique across tenants for this account and can be up to 35 characters long. The value can only contain these characters: a-z,0-9,-./
  • TARGET_NAME: Name of the target destination. The name must be unique across all targets in the region and can be up to 35 characters long. The value can only contain these characters: a-z,0-9,-./
  • CLOUD_LOGS_INSTANCE_CRN is the CRN of the IBM Cloud Logs instance.
  • CLOUD_LOGS_INSTANCE_INGRESS_ENDPOINT is the full qualified ingress endpoint for the destination of logs.
  • CLOUD_LOGS_INSTANCE_TARGET_PORT defines the port to use. For example, 443.

IBM Log Analysis destination

For a target that defines an IBM Log Analysis destination, the TARGET_DATA format is as follows:

{
    "name": "tenant",
    "targets": [
        {
            "log_sink_crn": "LOG_ANALYSIS_INSTANCE_CRN",
            "name": "TARGET_NAME",
            "parameters": {
                "host": "LOG_ANALYSIS_INGESTION_ENDPOINT",
                "port": `LOG_ANALYSIS_INSTANCE_TARGET_PORT`,
                "access_credential": "INGESTION_KEY_TO SEND_DATA_TO_INSTANCE"
            }
        }
    ]
}

Where

  • TENANT_NAME: Name of the tenant. The name must be unique across tenants for this account and can be up to 35 characters long. The value can only contain these characters: a-z,0-9,-./
  • TARGET_NAME: Name of the target destination. The name must be unique across all targets in the region and can be up to 35 characters long. The value can only contain these characters: a-z,0-9,-./
  • LOG_ANALYSIS_INGESTION_ENDPOINT is the IBM Log Analysis endpoint in the region where you plan to collect logs. For more information, see Endpoints.
  • LOG_ANALYSIS_INSTANCE_TARGET_PORT defines the port to use. For example, 443.
  • INGESTION_KEY_TO SEND_DATA_TO_INSTANCE defines the ingestion key to use to route the data to this destination.

Creating a tenant and target by using Terraform

IBM Cloud Logs destination

To create tenant with a target of type logs, use the following:

resource "ibm_logs_router_tenant" "logs_router_tenant_instance_1" {
	ibm_api_version = "API_VERSION_DATE"
	name = "TENANT_NAME"
	targets {
	  log_sink_crn = "CLOUD_LOGS_INSTANCE_CRN"
	  name = "TARGET_NAME"
	  parameters {
		host = "CLOUD_LOGS_INSTANCE_INGRESS_ENDPOINT"
		port = CLOUD_LOGS_INSTANCE_TARGET_PORT
	  }
	}
  }

Where

  • TENANT_NAME: Name of the tenant. The name must be unique across tenants for this account and can be up to 35 characters long. The value can only contain these characters: a-z,0-9,-./
  • TARGET_NAME: Name of the target destination. The name must be unique across all targets in the region and can be up to 35 characters long. The value can only contain these characters: a-z,0-9,-./
  • CLOUD_LOGS_INSTANCE_CRN is the CRN of the IBM Cloud Logs instance.
  • CLOUD_LOGS_INSTANCE_INGRESS_ENDPOINT is the full qualified ingress endpoint for the destination of logs.
  • CLOUD_LOGS_INSTANCE_TARGET_PORT defines the port to use. For example, 443.

IBM Log Analysis destination

To create tenant with a target of type logdna, use the following:

resource "ibm_logs_router_tenant" "logs_router_tenant_instance_1" {
	ibm_api_version = "API_VERSION_DATE"
	name = "TENANT_NAME"
	targets {
	  log_sink_crn = "LOG_ANALYSIS_INSTANCE_CRN"
	  name = "TARGET_NAME"
	  parameters {
		"host": "LOG_ANALYSIS_INGESTION_ENDPOINT",
        "port": `LOG_ANALYSIS_INSTANCE_TARGET_PORT`,
        "access_credential": "INGESTION_KEY_TO SEND_DATA_TO_INSTANCE"
	  }
	}
  }

Where

  • TENANT_NAME: Name of the tenant. The name must be unique across tenants for this account and can be up to 35 characters long. The value can only contain these characters: a-z,0-9,-./
  • TARGET_NAME: Name of the target destination. The name must be unique across all targets in the region and can be up to 35 characters long. The value can only contain these characters: a-z,0-9,-./
  • LOG_ANALYSIS_INGESTION_ENDPOINT is the IBM Log Analysis endpoint in the region where you plan to collect logs. For more information, see Endpoints.
  • LOG_ANALYSIS_INSTANCE_TARGET_PORT defines the port to use. For example, 443.
  • INGESTION_KEY_TO SEND_DATA_TO_INSTANCE defines the ingestion key to use to route the data to this destination.