Alibaba Cloud Observability MCP Server

sls_execute_query

Execute SLS log queries to retrieve and analyze log data within specified time ranges in Alibaba Cloud Log Service projects and log stores.

Instructions

执行SLS日志查询。

## 功能概述 该工具用于在指定的SLS项目和日志库上执行查询语句,并返回查询结果。查询将在指定的时间范围内执行。 ## 使用场景 - 当需要根据特定条件查询日志数据时 - 当需要分析特定时间范围内的日志信息时 - 当需要检索日志中的特定事件或错误时 - 当需要统计日志数据的聚合信息时 ## 查询语法 查询必须使用SLS有效的查询语法,而非自然语言。如果不了解日志库的结构,可以先使用sls_describe_logstore工具获取索引信息。 ## 时间范围 查询必须指定时间范围: - from_timestamp: 开始时间戳(秒) - to_timestamp: 结束时间戳(秒) ## 查询示例 - "帮我查询下 XXX 的日志信息" - "查找最近一小时内的错误日志" ## 错误处理 - Column xxx can not be resolved 如果是 sls_translate_natural_language_to_query 工具生成的查询语句 可能存在查询列未开启统计,可以提示用户增加相对应的信息,或者调用 sls_describe_logstore 工具获取索引信息之后,要用户选择正确的字段或者提示用户对列开启统计。当确定列开启统计之后,可以再次调用sls_translate_natural_language_to_query 工具生成查询语句 Args: ctx: MCP上下文,用于访问SLS客户端 project: SLS项目名称 log_store: SLS日志库名称 query: SLS查询语句 from_timestamp: 查询开始时间戳(秒) to_timestamp: 查询结束时间戳(秒) limit: 返回结果的最大数量,范围1-100,默认10 region_id: 阿里云区域ID Returns: 查询结果列表,每个元素为一条日志记录

Input Schema

NameRequiredDescriptionDefault
from_timestampYesfrom timestamp,unit is second
limitNolimit,max is 100
log_storeYessls log store name
projectYessls project name
queryYesquery
region_idYesaliyun region id,region id format like 'xx-xxx',like 'cn-hangzhou'
to_timestampYesto timestamp,unit is second

Input Schema (JSON Schema)

{ "properties": { "from_timestamp": { "description": "from timestamp,unit is second", "title": "From Timestamp", "type": "integer" }, "limit": { "default": 10, "description": "limit,max is 100", "maximum": 100, "minimum": 1, "title": "Limit", "type": "integer" }, "log_store": { "description": "sls log store name", "title": "Log Store", "type": "string" }, "project": { "description": "sls project name", "title": "Project", "type": "string" }, "query": { "description": "query", "title": "Query", "type": "string" }, "region_id": { "description": "aliyun region id,region id format like 'xx-xxx',like 'cn-hangzhou'", "title": "Region Id", "type": "string" }, "to_timestamp": { "description": "to timestamp,unit is second", "title": "To Timestamp", "type": "integer" } }, "required": [ "project", "log_store", "query", "from_timestamp", "to_timestamp", "region_id" ], "title": "sls_execute_queryArguments", "type": "object" }

You must be authenticated.

Other Tools from Alibaba Cloud Observability MCP Server

Related Tools

ID: 3ls5g1x8rn