Agent-lens is an agent observability feature of ApsaraDB for ClickHouse Enterprise Edition, built on ClickHouse and Langfuse. Through end-to-end tracing, prompt management, and automated evaluation, it makes agent behavior traceable, costs quantifiable, and performance measurable, solving common production challenges for agents like unpredictable outputs, hidden costs, and uncertain risks. This topic describes how to enable the Agent-lens service and send your first observability data.
For more information about the features and use cases of Agent-lens, see What is Agent-lens.
Prerequisites
Python 3.9 or later is installed.
You have created an ApsaraDB for ClickHouse Enterprise Edition instance to store LLM observability data for Langfuse. For more information, see Create a cluster.
The Agent-lens service is currently in an invitation-only public preview. To enable the service, fill out the form. For more information, see [Invitation-only Preview] Announcing the Agent-lens feature for ApsaraDB for ClickHouse Enterprise Edition.
Quick start
Step 1: Enable Agent-lens service
Log on to the ApsaraDB for ClickHouse console.
On the Clusters page, select Enterprise Edition Clusters, find your target instance, and click its ID to open the instance details page.
In the left-side navigation pane of the instance details page, click Agent Observability Suite.
In the dialog box, click OK to enable the Agent-lens service.
The service takes about 10 to 20 minutes to enable. After it is enabled, you can view the service details on the Agent Observability Suite page, including the Cluster Version, VPC Endpoint, Public Address, and Whitelist Settings.
The service creates a new database table and user in your ApsaraDB for ClickHouse Enterprise Edition instance to store observability data. It also adds the service's IP addresses to the instance's IP address whitelist.
Step 2: Configure IP whitelist
The first time you access the Langfuse service page, you must add your local IP address to the Langfuse service's IP address whitelist.
When the Instance Status changes to Running, check the IP address displayed in the dialog box. If it is your local IP address, click OK. If not, you must add your IP address to the IP address whitelist manually.
Step 3: Create user
Click the Public Address to go to the Langfuse service page.
The first time you access the page, click Sign up. Enter your name, email address, and password to create a Langfuse user.
Step 4: Create organization and project
You can select an existing organization at the top of the page or follow these steps to create a new one.
Click New Organization.
Enter an organization name and click Create.
Click Next.
Enter a project name and click Create.
Step 5: Create API key
You use a Langfuse API key to send observability data to Langfuse.
To create a new API key, click Create new API key.
The secret key is displayed only once. Make sure to copy and save the API key and secret key in a secure location. If you lose the secret key, you must create a new API key.
You can manage your API keys by clicking Settings in the lower-left corner of the page.
Step 6: Send observability data
Langfuse seamlessly integrates with model providers such as Model Studio, OpenAI, and Anthropic. The following example uses Model Studio to demonstrate how to send your first observability data.
Install the Langfuse SDK.
pip install langfuseSet environment variables.
Set the Langfuse API key and service endpoint as environment variables to direct the SDK's output to your Langfuse project. Set the Model Studio API key as an environment variable to allow the application to call the Model Studio model service.
NoteBefore you send data, make sure the IP address of the SDK host is in the Langfuse service's IP address whitelist.
export LANGFUSE_SECRET_KEY="sk-lf-..." export LANGFUSE_PUBLIC_KEY="pk-lf-..." export LANGFUSE_BASE_URL="http://{your_langfuse_endpoint}:3000" export DASHSCOPE_API_KEY="sk-..."Create a file named
quick_start.pyand add the following code.import os from langfuse.openai import OpenAI try: client = OpenAI( api_key=os.getenv("DASHSCOPE_API_KEY"), base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", ) completion = client.chat.completions.create( model="qwen-plus", messages=[ {'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': 'Who are you?'} ] ) print(completion.choices[0].message.content) except Exception as e: print(f"Error: {e}") print("For more information, see the documentation: https://www.alibabacloud.com/help/en/model-studio/latest/error-codes")Run the
quick_start.pyfile to send the observability data to the Langfuse service.python quick_start.pyExample response:
Hello! I am Qwen, a large language model from Alibaba Group. I can answer questions, create text such as stories, official documents, emails, and scripts, perform logical reasoning, write code, express opinions, and play games. If you have any questions or need help, feel free to ask me anything!You can view the observability data you sent on the Langfuse service page:
