이 Helm repository는 LangSmith UI가 현재 직접 지원하지 않는 출력을 생성하는 쿼리를 포함하고 있습니다 (예: 단일 쿼리로 여러 organization의 trace 수 가져오기).
이 명령은 이름과 비밀번호가 포함된 postgres connection string을 받아 (secrets manager 호출에서 전달될 수 있음) 입력 파일의 쿼리를 실행합니다. 아래 예시에서는 support_queries/postgres 디렉토리의 pg_get_trace_counts_daily.sql 입력 파일을 사용하고 있습니다.
Prerequisites
다음 도구/항목이 준비되어 있는지 확인하세요.
-
kubectl
-
PostgreSQL client
-
PostgreSQL database connection:
- Host
- Port
- Username
- 번들 버전을 사용하는 경우
postgres입니다
- Password
- 번들 버전을 사용하는 경우
postgres입니다
- Database name
- 번들 버전을 사용하는 경우
postgres입니다
-
migration script를 실행할 머신에서 PostgreSQL database로의 연결.
- 번들 버전을 사용하는 경우 postgresql service를 로컬 머신으로 port forward해야 할 수 있습니다.
kubectl port-forward svc/langsmith-postgres 5432:5432를 실행하여 postgresql service를 로컬 머신으로 port forward하세요.
-
지원 쿼리를 실행하는 script
- 여기에서 script를 다운로드할 수 있습니다
쿼리 script 실행
원하는 쿼리를 실행하려면 다음 명령을 실행하세요:
sh run_support_query_pg.sh <postgres_url> --input path/to/query.sql
예를 들어, port-forwarding과 함께 번들 버전을 사용하는 경우 명령은 다음과 같을 수 있습니다:
sh run_support_query_pg.sh "postgres://postgres:postgres@localhost:5432/postgres" --input support_queries/pg_get_trace_counts_daily.sql
이는 workspace ID와 organization ID별 일일 trace 수를 출력합니다. 이를 파일로 추출하려면 --output path/to/file.csv 플래그를 추가하세요
사용량 데이터 내보내기
사용량 데이터 내보내기는 Helm chart 버전 0.11.4 이상을 실행해야 합니다.
고객 정보 가져오기
내보내기 script를 실행하기 전에 LangSmith API에서 고객 정보를 가져와야 합니다. 이 정보는 내보내기 script의 입력으로 필요합니다.
curl https://<langsmith_url>/api/v1/info
# if configured with a subdomain / path prefix:
curl http://<langsmith_url/prefix/api/v1/info
이는 고객 정보가 포함된 JSON 응답을 반환합니다:
{
"version": "0.11.4",
"license_expiration_time": "2026-08-18T19:14:34Z",
"customer_info": {
"customer_id": "<id>",
"customer_name": "<name>"
}
}
이 응답에서 customer_id와 customer_name을 추출하여 내보내기 script의 입력으로 사용하세요.
jq로 API 응답 처리
jq를 사용하여 JSON 응답을 파싱하고 script에서 사용할 bash 변수를 설정할 수 있습니다:
# Get the API response and extract customer information
export LANGSMITH_URL="<your_langsmith_url>"
response=$(curl -s $LANGSMITH_URL/api/v1/info)
# Extract customer_id and customer_name using jq
export CUSTOMER_ID=$(echo "$response" | jq -r '.customer_info.customer_id')
export CUSTOMER_NAME=$(echo "$response" | jq -r '.customer_info.customer_name')
# Verify the variables are set
echo "Customer ID: $CUSTOMER_ID"
echo "Customer Name: $CUSTOMER_NAME"
그런 다음 내보내기 script나 다른 명령에서 이러한 환경 변수를 사용할 수 있습니다.
jq가 없는 경우 curl 출력을 기반으로 환경 변수를 설정하려면 다음 명령을 실행하세요:
curl -s $LANGSMITH_URL/api/v1/info
export CUSTOMER_ID="<id>"
export CUSTOMER_NAME="<name>"
초기 내보내기
이 script들은 LangChain에 보고하기 위해 사용량 데이터를 CSV로 내보냅니다. 또한 backfill ID와 timestamp를 할당하여 내보내기를 추적합니다.
LangSmith trace 사용량을 내보내려면:
# Get customer information from the API
export LANGSMITH_URL="<your_langsmith_url>"
export response=$(curl -s $LANGSMITH_URL/api/v1/info)
export CUSTOMER_ID=$(echo "$response" | jq -r '.customer_info.customer_id') && echo "Customer ID: $CUSTOMER_ID"
export CUSTOMER_NAME=$(echo "$response" | jq -r '.customer_info.customer_name') && echo "Customer name: $CUSTOMER_NAME"
# Run the export script with customer information as variables
sh run_support_query_pg.sh <postgres_url> \
--input support_queries/postgres/pg_usage_traces_backfill_export.sql \
--output ls_export.csv \
-v customer_id=$CUSTOMER_ID \
-v customer_name=$CUSTOMER_NAME
LangSmith 사용량을 내보내려면:
sh run_support_query_pg.sh <postgres_url> \
--input support_queries/postgres/pg_usage_nodes_backfill_export.sql \
--output lgp_export.csv \
-v customer_id=$CUSTOMER_ID \
-v customer_name=$CUSTOMER_NAME
상태 업데이트
이 script들은 설치의 사용량 이벤트 상태를 업데이트하여 이벤트가 LangChain에 의해 성공적으로 처리되었음을 반영합니다.
script는 해당 backfill_id를 전달해야 하며, 이는 LangChain 담당자가 확인해 줄 것입니다.
LangSmith trace 사용량을 업데이트하려면:
sh run_support_query_pg.sh <postgres_url> --input support_queries/postgres/pg_usage_traces_backfill_update.sql --output export.csv -v backfill_id=<backfill_id>
LangSmith 사용량을 업데이트하려면:
sh run_support_query_pg.sh <postgres_url> --input support_queries/postgres/pg_usage_nodes_backfill_update.sql --output export.csv -v backfill_id=<backfill_id>