All Products
Search
Document Center

Simple Log Service:Import Ingress trace data from Kubernetes clusters to Simple Log Service

Last Updated:Aug 29, 2023

This topic describes how to import Ingress trace data from Kubernetes clusters to the Trace application of Simple Log Service by using OpenTelemetry.

Prerequisites

A trace instance is created. For more information, see Create a trace instance.

Step 1: Install the OpenTelemetry Collector

  1. Log on to your Kubernetes cluster.

  2. Install cert-manager.

    kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.6.1/cert-manager.yaml
  3. Deploy the OpenTelemetry Operator.

    1. Download the opentelemetry-operator.yaml file.

      wget https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml
    2. Open the opentelemetry-operator.yaml file and replace the image information in the file.

      Replace ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator in the opentelemetry-operator.yaml file with sls-registry.cn-beijing.cr.aliyuncs.com/opentelemetry-operator/opentelemetry-operator, as shown in the following figure. Collect Ingress trace data

    3. Run the following command to apply the configuration:

      kubectl apply -f opentelemetry-operator.yaml
  4. Deploy the OpenTelemetry Collector.

    1. Create a YAML file.

      vim collector.yaml
    2. Enter the following code in the YAML file and configure the parameters based on your business scenario:

      apiVersion: opentelemetry.io/v1alpha1
      kind: OpenTelemetryCollector
      metadata:
        name: otel
      spec:
        image: otel/opentelemetry-collector-contrib:latest
        config: |
          receivers:
            otlp:
              protocols:
                grpc:
                http:
            jaeger:
                  protocols:
                    grpc:
                thrift_http:
                thrift_compact:
                thrift_binary:
            zipkin:
          exporters:
            alibabacloud_logservice/logs:
              endpoint: "cn-hangzhou.log.aliyuncs.com"
              project: "demo-project"
              logstore: "store-logs"
              access_key_id: "access-key-id"
              access_key_secret: "access-key-secret"
            alibabacloud_logservice/metrics:
              endpoint: "cn-hangzhou.log.aliyuncs.com"
              project: "demo-project"
              logstore: "store-traces-metrics"
              access_key_id: "access-key-id"
              access_key_secret: "access-key-secret"
            alibabacloud_logservice/traces:
              endpoint: "cn-hangzhou.log.aliyuncs.com"
              project: "demo-project"
              logstore: "store-traces"
              access_key_id: "access-key-id"
              access_key_secret: "access-key-secret"
      
          service:
            pipelines:
              traces:
                receivers: [otlp, jaeger, zipkin]
                exporters: [alibabacloud_logservice/traces]
              metrics:
                receivers: [otlp]
                exporters: [alibabacloud_logservice/metrics]
                                      

      Parameter

      Description

      endpoint

      The Simple Log Service endpoint. Example: cn-hangzhou.log.aliyuncs.com. For more information, see Endpoints.

      project

      The name of the project that you specify when you create a trace instance. For more information, see Create a trace instance.

      logstore

      The name of the Logstore. After you create a trace instance, Simple Log Service automatically generates three Logstores in the specified project to store log data, metric data, and trace data. Replace the Logstore name based on your business scenario.

      • trace_instance_id-logs

      • trace_instance_id-traces-metrics

      • trace_instance_id-traces

      trace_instance_id specifies the ID of the trace instance. For more information, see Create a trace instance.

      access_key_id

      The AccessKey ID that is used to access Simple Log Service.

      We recommend that you use the AccessKey pair of a RAM user that has only the write permissions on the Simple Log Service project. An AccessKey pair consists of an AccessKey ID and an AccessKey secret. For more information about how to grant the write permissions on a specified project to a RAM user, see Use custom policies to grant permissions to a RAM user. For more information about how to obtain an AccessKey pair, see AccessKey pair.

      access_key_secret

      The AccessKey secret that is used to access Simple Log Service.

      We recommend that you use the AccessKey pair of a RAM user that has only the write permissions on the Simple Log Service project.

    3. Run the following command to apply the configuration.

      otel-test indicates the namespace where your service resides.

      kubectl apply -f collector.yaml --namespace=otel-test

Step 2: Configure Ingress OpenTracing

In this example, an Alibaba Cloud Container Service for Kubernetes (ACK) cluster is used.

  1. Log on to the ACK console.

  2. On the Clusters page, click the cluster that you want to manage.

  3. In the left-side navigation pane, choose Configurations > ConfigMaps.

  4. On the ConfigMap page, select kube-system from the Namespace drop-down list. In the ConfigMap list, find nginx-configuration and click Edit in the Actions column.

  5. In the Edit panel, configure the following two parameters and click OK.

    otel-test indicates the namespace where your service resides. This namespace must be the same as the namespace that you specified in Step 4.iii.

    zipkin-collector-host: otel-collector.otel-test.svc.cluster.local:9411/api/v1/spans?
    enable-opentracing: true
    Parameters

    After you complete the preceding configuration, OpenTelemetry uploads the Ingress trace data that is generated by your Kubernetes cluster to Trace. You can view the trace data in the Trace application. For more information, see View the details of a trace.