菜单
文档breadcrumb arrow Grafana Tempobreadcrumb arrow 管理breadcrumb arrow 使用 Google Cloud Run 进行搜索
开源

使用 Google Cloud Run 进行搜索

注意

Tempo 无服务器功能现已弃用,并将在即将发布的版本中移除。

本文档将引导您设置 Google Cloud Run 以进行无服务器后端搜索。有关完整后端搜索的配置选项的更多指导,请在此处查看

  1. 构建 Docker 镜像

    bash
    cd ./cmd/tempo-serverless && make build-docker-gcr

    这将创建要部署到 Google Cloud Run 的 Docker 容器镜像。Docker 镜像将被命名为:`tempo-serverless:latest` 和 `tempo-serverless:<branch>-<commit hash>`。以下是名称示例:

    bash
    $ docker images | grep tempo-serverless
    tempo-serverless                                                           cloud-run-3be4efa               146c9d9fa63c   58 seconds ago   47.9MB
    tempo-serverless                                                           latest                          146c9d9fa63c   58 seconds ago   47.9MB
  2. 将镜像推送到 Google Container Registry 仓库。

  3. 配置 Google Cloud Run 服务。此示例使用 Terraform。应调整配置值以满足您的安装需求。

    locals {
      // this can be increased if you would like to use multiple functions
      count = 1
    }
    
    resource "google_cloud_run_service" "run" {
      count = local.count
    
      name     = "<service name>"
      location = "<appropriate region>"
    
      metadata {
        annotations = {
            "run.googleapis.com/ingress"      = "internal",     # this annotation can be used to limit connectivity to the service
        }
      }
    
      template {
        metadata {
          annotations = {
              "autoscaling.knative.dev/minScale"                   = "1",
              "autoscaling.knative.dev/maxScale"                   = "1000",
              "autoscaling.knative.dev/panic-threshold-percentage" = "110.0",  # default 200.0. how aggressively to go into panic mode and start scaling heavily
              "autoscaling.knative.dev/window"                     = "10s",    # default 60s. window over which to average metrics to make scaling decisions
          }
        }
        spec {
          container_concurrency = 4
          containers {
            image = "<container image created above>"
            resources {
              limits = {
                  cpu = "2"
                  memory = "1Gi"
              }
            }
            env {
              name = "TEMPO_GCS_BUCKET_NAME"
              value = "<gcs bucket where tempo data is stored>"
            }
            env {
              name = "TEMPO_BACKEND"
              value = "gcs"
            }
            env {
              name = "TEMPO_GCS_HEDGE_REQUESTS_AT"
              value = "400ms"
            }
            env {
              name = "TEMPO_GCS_HEDGE_REQUESTS_UP_TO"
              value = "2"
            }
            env {
              name = "GOGC"
              value = "400"
            }
          }
        }
      }
    
      traffic {
        percent         = 100
        latest_revision = true
      }
    }
  4. 在查询器配置中将新创建的 Cloud Run 服务添加为外部端点。端点可以从 Google Cloud Run 的详细信息选项卡中获取。

    querier:
      search:
        external_endpoints:
        - <trigger url from console>