### Clone Repository and Install Dependencies Source: https://ekuiper-manager.superdocs.cloud/p/quick-start-14e88cdb This snippet shows how to clone the ekuiper-manager repository from GitHub and install its Node.js dependencies using npm. ```bash git clone https://github.com/ankur-paan/ekuiper-manager.git cd ekuiper-manager npm install ``` -------------------------------- ### Build and Start ekuiper-manager for Production Source: https://ekuiper-manager.superdocs.cloud/p/quick-start-14e88cdb Commands to create an optimized production build of the ekuiper-manager application and then start the production server. ```bash npm run build npm run start ``` -------------------------------- ### Run ekuiper-manager in Development Mode Source: https://ekuiper-manager.superdocs.cloud/p/quick-start-14e88cdb Command to start the ekuiper-manager application in development mode, enabling hot-reloading for a streamlined development experience. The application will be accessible at http://localhost:3000. ```bash npm run dev ``` -------------------------------- ### Create Stream with Protobuf Schema Example Source: https://ekuiper-manager.superdocs.cloud/p/schema-management-f7e238f6 This SQL example demonstrates how to create a stream in eKuiper and associate it with a registered Protobuf schema. It specifies the data format as 'protobuf' and provides the Schema ID for the Protobuf message. This ensures that incoming data conforms to the defined Protobuf structure. ```sql CREATE STREAM sensor_stream () WITH ( FORMAT = "protobuf", SCHEMAID = "sensors.TemperatureReading", TYPE = "mqtt", DATASOURCE = "factory/sensor/+" ); ``` -------------------------------- ### Configure Environment Variables for AI Features Source: https://ekuiper-manager.superdocs.cloud/p/quick-start-14e88cdb Demonstrates how to create a .env.local file to configure environment variables, specifically for setting the OpenRouter API key required for AI Assistant features. ```bash OPENROUTER_API_KEY=your_api_key_here ``` -------------------------------- ### Register Protobuf Schema Example Source: https://ekuiper-manager.superdocs.cloud/p/schema-management-f7e238f6 This snippet shows an example of a Protobuf schema definition for a temperature reading. Protobuf schemas are used to define data structures for efficient, low-bandwidth communication, commonly in IoT scenarios. Registering these schemas in eKuiper Manager allows for validation and mapping of binary data. ```protobuf syntax = "proto3"; package sensors; message TemperatureReading { string sensorId = 1; float value = 2; int64 timestamp = 3; } ``` -------------------------------- ### Verify eKuiper Connection using getInfo (TypeScript) Source: https://ekuiper-manager.superdocs.cloud/p/api-proxy-swagger-5727b37b Provides an example of using the `EKuiperClient` to verify a connection to an eKuiper instance by calling the `getInfo()` method. This method retrieves system information and the eKuiper version. Error handling is included for connection failures. ```typescript import { EKuiperClient } from "@/lib/ekuiper/client"; async function checkServerConnection(client: EKuiperClient) { try { const info = await client.getInfo(); console.log(`Successfully connected to eKuiper version: ${info.version}`); return true; } catch (error) { console.error("Failed to connect to eKuiper:", error); return false; } } // Assuming 'client' is an initialized EKuiperClient instance // Example usage: // const isConnected = await checkServerConnection(client); ``` -------------------------------- ### Example Rule Configuration JSON Source: https://ekuiper-manager.superdocs.cloud/p/rule-orchestration-be4efe36 Defines a rule with an ID, SQL processing logic, and a list of actions (sinks) to send processed data. This configuration is used to create or update a rule in eKuiper Manager. ```json { "id": "rule_thermal_monitor", "sql": "SELECT temp, humidity FROM sensor_stream WHERE temp > 50", "actions": [ { "log": {} }, { "mqtt": { "server": "tcp://broker.local:1883", "topic": "alerts/high_temp" } } ] } ``` -------------------------------- ### Programmatically Capture Rule Trace Data with EKuiperClient Source: https://ekuiper-manager.superdocs.cloud/p/rule-tracing-debugging-05a4812e Demonstrates the programmatic flow for capturing rule trace data using the EKuiperClient. This involves starting the trace, waiting for data, stopping the trace, and fetching detailed span information. Ensure the EKuiperClient is initialized with the correct server URL. ```javascript const client = new EKuiperClient(SERVER_URL); // 1. Start the trace await client.startRuleTrace(ruleId, "always"); // 2. Wait for data to accumulate (e.g., 10 seconds) await new Promise(resolve => setTimeout(resolve, 10000)); // 3. Stop the trace and fetch IDs await client.stopRuleTrace(ruleId); const traceIds = await client.getRuleTraceIds(ruleId); // 4. Fetch detailed span data for the most recent traces const traceDetails = await Promise.all( traceIds.slice(-10).map(id => client.getTraceDetail(id)) ); ``` -------------------------------- ### List eKuiper Plugins using EKuiperClient Source: https://ekuiper-manager.superdocs.cloud/p/plugins-and-udfs-3253e6c0 Retrieves a list of installed function, source, and sink plugins from an eKuiper instance using the EKuiperClient. This requires an active connection to the eKuiper API. ```typescript import { EKuiperClient } from "@/lib/ekuiper/client"; const client = new EKuiperClient("http://your-ekuiper-url:9081", undefined, 5000, true); async function getPlugins() { const functionPlugins = await client.listPlugins("functions"); const sourcePlugins = await client.listPlugins("sources"); const sinkPlugins = await client.listPlugins("sinks"); console.log("Available Functions:", functionPlugins); } ``` -------------------------------- ### API Request for AI Execution Plan Explanation Source: https://ekuiper-manager.superdocs.cloud/p/execution-plan-explain-14c3c75b This snippet demonstrates how to use the /api/ai/explain-plan endpoint to get an AI-generated explanation of an eKuiper execution plan. It requires the SQL query and the raw execution plan JSON as input. The optional modelName parameter allows specifying the AI model. ```curl curl -X POST /api/ai/explain-plan \ -H "Content-Type: application/json" \ -d '{ "sql": "SELECT temp, COUNT(*) FROM sensor_stream WHERE temp > 20 GROUP BY TumblingWindow(ss, 10)", "plan": { ...raw eKuiper plan... } }' ``` -------------------------------- ### Test eKuiper Connection - TypeScript Source: https://ekuiper-manager.superdocs.cloud/p/server-connections-68ef62c5 Provides a TypeScript example using the EKuiperClient to programmatically test and verify a connection to an eKuiper server. This is useful for extending the manager or for custom script development. It initializes the client in direct mode for server-side usage. ```typescript import { EKuiperClient } from "@/lib/ekuiper/client"; // Initialize client in direct mode (for server-side/script usage) const client = new EKuiperClient("http://localhost:9081", undefined, 5000, true); async function checkHealth() { try { const info = await client.getInfo(); console.log(`Connected to eKuiper version: ${info.version}`); } catch (error) { console.error("Connection failed", error); } } checkHealth(); ``` -------------------------------- ### Proxy Request Example - JavaScript Source: https://ekuiper-manager.superdocs.cloud/p/server-connections-68ef62c5 Demonstrates how to access eKuiper resources (like rules) on a specific server connection through the eKuiper Manager's internal proxy. This bypasses CORS restrictions by routing requests through the manager's backend. ```javascript const response = await fetch('/api/connections/my-server-id/ekuiper/rules', { method: 'GET', headers: { 'Content-Type': 'application/json' } }); const rules = await response.json(); ``` -------------------------------- ### Generate Stream Definition via AI (OpenRouter) Source: https://ekuiper-manager.superdocs.cloud/p/service-integrations-6a43cfcf This example demonstrates how to generate a stream definition by sending a natural language prompt to an AI service. The service accepts a prompt and model name, returning a structured JSON object representing the stream configuration. This is useful for automating the creation of data streams based on requirements. ```json { "prompt": "Create a stream for a temperature sensor via MQTT on topic 'factory/sensor1'", "modelName": "google/gemini-flash-1.5" } ``` ```json { "name": "temp_sensor_stream", "sourceType": "mqtt", "datasource": "factory/sensor1", "format": "json", "fields": [ { "name": "temperature", "type": "float" }, { "name": "humidity", "type": "float" } ], "description": "Inbound telemetry for factory sensor 1" } ``` -------------------------------- ### Get Rule Definition Source: https://ekuiper-manager.superdocs.cloud/p/import-and-export-52a5cc25 Retrieves the definition of a specific rule from a connected eKuiper instance. ```APIDOC ## GET /api/connections/{id}/ekuiper/rules/{ruleId} ### Description Retrieves the definition of a specific rule from a connected eKuiper instance. ### Method GET ### Endpoint /api/connections/{id}/ekuiper/rules/{ruleId} ### Parameters #### Path Parameters - **id** (string) - Required - The Connection ID of the eKuiper server. - **ruleId** (string) - Required - The ID of the rule to retrieve. ### Response #### Success Response (200) - **ruleDefinition** (object) - The complete definition of the rule, including SQL and actions. #### Response Example ```json { "id": "high_temp_alert", "sql": "SELECT * FROM demo_stream WHERE temp > 30", "actions": [ { "mqtt": { "server": "tcp://broker.internal:1883", "topic": "alerts/high_temp" } } ] } ``` ``` -------------------------------- ### Manage eKuiper Plugins and UDFs (TypeScript) Source: https://ekuiper-manager.superdocs.cloud/p/service-integrations-6a43cfcf This TypeScript code snippet shows how to interact with the eKuiper Manager client to manage extensions. It demonstrates listing installed function plugins and registered User Defined Functions (UDFs). This is essential for extending eKuiper's capabilities with custom logic. ```typescript import { EKuiperClient } from "@/lib/ekuiper/client"; const client = new EKuiperClient("https://your-ekuiper-url"); // List all installed function plugins const plugins = await client.listPlugins("functions"); // List all registered UDFs (User Defined Functions) const udfs = await client.listUDFs(); ``` -------------------------------- ### Initialize EKuiperClient in Direct and Proxy Modes (TypeScript) Source: https://ekuiper-manager.superdocs.cloud/p/system-architecture-63a34712 Demonstrates how to initialize the EKuiperClient for direct communication with an eKuiper REST API or for routing requests through the eKuiper Manager's Next.js backend. It shows setting the base URL and timeout for direct mode, and configuring the proxy endpoint for proxy mode. ```typescript import { EKuiperClient } from '@/lib/ekuiper/client'; // Direct Mode: Communicates directly with the eKuiper REST API const directClient = new EKuiperClient("http://localhost:9081", undefined, 5000, true); // Proxy Mode: Routes through the manager's backend const proxyClient = new EKuiperClient(); proxyClient.setBaseUrl("/api/connections/default/ekuiper"); ``` -------------------------------- ### Initiate Smart Log Capture via API Source: https://ekuiper-manager.superdocs.cloud/p/smart-log-capture-344f682c This snippet demonstrates how to initiate a smart log capture session using the internal API. It requires specifying the rule IDs to capture, the desired duration level, and the eKuiper server URL. The response indicates the success of the capture and provides a summary message. ```json { "ruleIds": ["rule_1", "rule_2"], "durationLevel": 1, // 10 seconds "serverUrl": "http://ekuiper-server:9081" } ``` ```json { "captured": { "rule_1": [ { "traceId": "...", "spans": [ { "name": "operator_filter", "attributes": { "status": "success", "result": "{\"temp\": 25.5}" } } ] } ] }, "message": "Captured logs from 1 rules" } ``` -------------------------------- ### AI-Generated Stream Definition (JSON) Source: https://ekuiper-manager.superdocs.cloud/p/streams-and-tables-4ca3dc77 Example of a stream definition generated by the AI Assistant. It specifies the stream name, source type, data source, format, fields with their types, and a descriptive text. This JSON structure is used for creating new streams. ```json { "name": "temperature_sensor_stream", "sourceType": "mqtt", "datasource": "factory/sensor1", "format": "json", "fields": [ { "name": "temperature", "type": "float" }, { "name": "humidity", "type": "float" } ], "description": "Ingests environmental data from factory floor MQTT broker." } ``` -------------------------------- ### Initialize EKuiperClient in Direct Mode (TypeScript) Source: https://ekuiper-manager.superdocs.cloud/p/api-proxy-swagger-5727b37b Shows how to initialize the `EKuiperClient` in direct mode, typically used for server-side scripts or AI routes. This mode connects directly to the eKuiper instance without going through the manager's proxy. It requires the eKuiper server's address, an optional token, a timeout, and a boolean flag to enable direct mode. ```typescript import { EKuiperClient } from "@/lib/ekuiper/client"; // Direct Mode initialization (Server-side) const eKuiperServerAddress = "http://your-ekuiper-ip:9081"; const apiToken = undefined; // Or your API token if required const requestTimeout = 5000; // 5 seconds timeout const enableDirectMode = true; const client = new EKuiperClient( eKuiperServerAddress, apiToken, requestTimeout, enableDirectMode ); console.log('EKuiperClient initialized in direct mode.'); ``` -------------------------------- ### MQTT Sink Configuration for Rules Source: https://ekuiper-manager.superdocs.cloud/p/import-and-export-52a5cc25 This JSON array represents the configuration for MQTT sinks, specifying the broker address and topic for alerts. It's part of the 'Actions' section when importing rule definitions. ```json [ { "mqtt": { "server": "tcp://broker.internal:1883", "topic": "alerts/high_temp" } } ] ``` -------------------------------- ### Verify eKuiper Instance API Compatibility (CLI) Source: https://ekuiper-manager.superdocs.cloud/p/service-integrations-6a43cfcf This command-line script verifies the API compatibility of a remote eKuiper instance. It's a crucial step to ensure that the eKuiper Manager can successfully communicate with and manage the target edge node. This script helps in troubleshooting connection issues. ```bash npx ts-node scripts/verify-api.ts ``` -------------------------------- ### Create Rule Source: https://ekuiper-manager.superdocs.cloud/p/import-and-export-52a5cc25 Creates a new rule on a connected eKuiper instance. ```APIDOC ## POST /api/connections/{id}/ekuiper/rules ### Description Creates a new rule on a specified eKuiper instance. ### Method POST ### Endpoint /api/connections/{id}/ekuiper/rules ### Parameters #### Path Parameters - **id** (string) - Required - The Connection ID of the eKuiper server. #### Request Body - **id** (string) - Required - A unique identifier for the rule. - **sql** (string) - Required - The SQL transformation logic for the rule. - **actions** (array) - Required - A JSON array of sink configurations for the rule. ### Request Example ```json { "id": "new_rule_1", "sql": "SELECT temp FROM demo_stream WHERE temp < 10", "actions": [ { "log": {} } ] } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the rule was created successfully. #### Response Example ```json { "message": "Rule 'new_rule_1' created successfully." } ``` ``` -------------------------------- ### Create Stream SQL Definition Source: https://ekuiper-manager.superdocs.cloud/p/import-and-export-52a5cc25 This SQL statement defines a new stream named 'demo_stream' with specified fields and data source configurations. It's used when importing stream definitions into eKuiper Manager. ```sql CREATE STREAM demo_stream ( temp FLOAT, humidity BIGINT ) WITH (FORMAT="JSON", TYPE="mqtt", DATASOURCE="telemetry/data") ``` -------------------------------- ### Generate MQTT Stream Configuration (JSON) Source: https://ekuiper-manager.superdocs.cloud/p/ai-rule-stream-gen-00f284c7 Automates the creation of eKuiper Source definitions by inferring data types, formats, and protocols from user descriptions. Returns a structured JSON configuration for the eKuiper API. ```json { "name": "vibration_sensor_stream", "sourceType": "mqtt", "datasource": "factory/node1/vibe", "format": "json", "fields": [ { "name": "frequency", "type": "float" }, { "name": "amplitude", "type": "float" } ], "description": "Stream for monitoring industrial vibration telemetry." } ``` -------------------------------- ### Fetch Available AI Models Source: https://ekuiper-manager.superdocs.cloud/p/ai-model-selection-f30add4d Retrieve a list of AI models currently enabled and compatible with eKuiper's industrial domain requirements. ```APIDOC ## GET /api/ai/models ### Description Fetches a list of available AI models that are compatible with eKuiper's industrial domain. ### Method GET ### Endpoint /api/ai/models ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **id** (string) - The unique identifier for the AI model. - **name** (string) - The display name of the AI model. #### Response Example ```json [ { "id": "google/gemini-2.0-flash-exp", "name": "Google: Gemini 2.0 Flash Experimental" }, { "id": "meta-llama/llama-3.3-70b-instruct", "name": "Meta: Llama 3.3 70B Instruct" } ] ``` ``` -------------------------------- ### Exporting Rules via API Playground Source: https://ekuiper-manager.superdocs.cloud/p/import-and-export-52a5cc25 This endpoint allows you to retrieve the definition of a specific rule. It is useful for exporting rule configurations, including SQL logic and actions, for migration purposes. ```APIDOC ## GET /rules/{id} ### Description Retrieves the definition of a specific rule, including its SQL logic and associated actions (sinks). ### Method GET ### Endpoint /rules/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the rule to retrieve. ### Response #### Success Response (200) - **ruleDefinition** (object) - The complete configuration of the rule, including SQL and actions. #### Response Example ```json { "id": "high_temp_alert", "sql": "SELECT * FROM demo_stream WHERE temp > 30", "actions": [ { "mqtt": { "server": "tcp://broker.internal:1883", "topic": "alerts/high_temp" } } ] } ``` ``` -------------------------------- ### AI Logic & Topology Analysis Source: https://ekuiper-manager.superdocs.cloud/p/ai-rule-stream-gen-00f284c7 Analyzes existing eKuiper rules and execution plans to provide plain-English descriptions of topology nodes, identify performance bottlenecks, and offer optimization hints. ```APIDOC ## AI Logic & Topology Analysis ### Description Provides AI-powered analysis of existing eKuiper rules and their execution plans. It helps in understanding complex logic by mapping topology nodes and identifying potential performance issues. ### Topology Node Mapping Analyzes the Rule SQL and its execution topology to provide plain-English descriptions for each node in the graph: * **Source Nodes**: Explains the data entering the stream. * **Filter Nodes**: Describes the conditions applied (e.g., "Filters for values above 100"). * **Aggregator Nodes**: Explains calculations like rolling averages. * **Sink Nodes**: Details the final data destination. ### Execution Plan (Explain) Analysis Passes the eKuiper `EXPLAIN` plan (JSON) to the AI to identify: * Potential performance bottlenecks. * Optimization hints for complex operations like joins or windowing. * Data flow pathing. ### Usage Provide the rule SQL or the `EXPLAIN` plan JSON to the AI assistant for analysis. ``` -------------------------------- ### AI Stream Generation Source: https://ekuiper-manager.superdocs.cloud/p/ai-rule-stream-gen-00f284c7 Automates the creation of eKuiper Source definitions by inferring data types, formats, and protocols from user descriptions. Supports various protocols like mqtt, httppull, and data types including bigint, float, and string. ```APIDOC ## AI Stream Generation ### Description Automates the creation of eKuiper Source definitions based on natural language descriptions. It infers data types, formats, and protocols. ### Usage Provide a prompt describing the data source, e.g., "Create an MQTT stream for a vibration sensor on topic factory/node1/vibe with frequency and amplitude fields." ### Supported Protocols & Types * **Sources:** `mqtt`, `httppull`, `httppush`, `memory`, `neuron`, `edgex`, `file`, `redis`, `simulator`. * **Data Types:** `bigint`, `float`, `string`, `boolean`, `datetime`, `bytea`, `array`, `struct`. ### Example Request (Conceptual) ``` "Create an MQTT stream for a vibration sensor on topic factory/node1/vibe with frequency and amplitude fields." ``` ### Example Response (Generated Configuration) ```json { "name": "vibration_sensor_stream", "sourceType": "mqtt", "datasource": "factory/node1/vibe", "format": "json", "fields": [ { "name": "frequency", "type": "float" }, { "name": "amplitude", "type": "float" } ], "description": "Stream for monitoring industrial vibration telemetry." } ``` ``` -------------------------------- ### Programmatic Client (EKuiperClient) Source: https://ekuiper-manager.superdocs.cloud/p/api-proxy-swagger-5727b37b The project includes a TypeScript client, `EKuiperClient`, for both client-side and server-side interactions with eKuiper. It supports Proxy Mode and Direct Mode. ```APIDOC ## Programmatic Client (`EKuiperClient`) ### Description Use the `EKuiperClient` TypeScript library for programmatic interaction with eKuiper instances. It can operate in Proxy Mode (default for browser) or Direct Mode (for server-side applications). ### Initialization #### Direct Mode (Server-side) ##### Method Constructor ##### Parameters - **`baseUrl`** (string) - Required - The base URL of the eKuiper instance (e.g., `http://your-ekuiper-ip:9081`). - **`token`** (string) - Optional - Authentication token. - **`timeout`** (number) - Optional - Request timeout in milliseconds (default: 5000). - **`directMode`** (boolean) - Required - Set to `true` to enable Direct Mode. ##### Request Example ```typescript import { EKuiperClient } from "@/lib/ekuiper/client"; // Direct Mode initialization (Server-side) const client = new EKuiperClient( "http://your-ekuiper-ip:9081", undefined, 5000, true // Enables direct mode ); ``` ### Common Methods | Method | Description | |--------------------|-----------------------------------------------------------| | `getInfo()` | Returns eKuiper system information and version. | | `listStreams()` | Retrieves all defined streams. | | `createRule(rule)` | Deploys a new processing rule with SQL and actions. | | `getRuleStatus(id)`| Fetches real-time metrics (messages in/out, errors). | | `startRuleTrace(id)`| Enables real-time data flow tracing for debugging. | ### Example: Verifying Connection #### Method `getInfo()` #### Description Fetches system information to verify a successful connection to the eKuiper instance. #### Request Example ```typescript async function checkServer() { try { const info = await client.getInfo(); console.log(`Connected to eKuiper version: ${info.version}`); } catch (error) { console.error("Connection failed", error); } } ``` #### Success Response (200) - **version** (string) - The eKuiper system version. ``` -------------------------------- ### AI-Powered Plan Analysis API Source: https://ekuiper-manager.superdocs.cloud/p/execution-plan-explain-14c3c75b This API endpoint allows you to programmatically trigger an AI-powered analysis of an eKuiper execution plan. It takes the SQL query, the raw execution plan JSON, and an optional model name to generate a developer-friendly report with optimization suggestions. ```APIDOC ## POST /api/ai/explain-plan ### Description Triggers an AI-powered analysis of an eKuiper execution plan to provide optimization suggestions and a step-by-step walkthrough of the logical operators. ### Method POST ### Endpoint /api/ai/explain-plan ### Parameters #### Request Body - **sql** (string) - Required - The eKuiper SQL query being analyzed. - **plan** (object) - Required - The raw JSON execution plan returned by the eKuiper server. - **modelName** (string) - Optional - The OpenRouter model to use (defaults to `google/gemini-flash-1.5`). ### Request Example ```json { "sql": "SELECT temp, COUNT(*) FROM sensor_stream WHERE temp > 20 GROUP BY TumblingWindow(ss, 10)", "plan": { ...raw eKuiper plan... }, "modelName": "google/gemini-flash-1.5" } ``` ### Response #### Success Response (200) - **explanation** (string) - A Markdown-formatted string containing a step-by-step walkthrough of the logical operators, potential performance issues, and suggestions for SQL improvements. #### Response Example ```markdown ## Execution Plan Analysis ### Overview This plan analyzes the SQL query: `SELECT temp, COUNT(*) FROM sensor_stream WHERE temp > 20 GROUP BY TumblingWindow(ss, 10)`. ### Step-by-Step Walkthrough 1. **Scan**: Reads data from the `sensor_stream`. 2. **Filter (Where)**: Filters records where `temp > 20`. 3. **Window**: Groups data using a 10-second tumbling window. 4. **Aggregate**: Calculates the count of records within each window. 5. **Project (Select)**: Selects the `temp` and the calculated count. ### Potential Performance Issues - **High-cardinality grouping**: If `temp` has many distinct values, the `GROUP BY` operation might be resource-intensive. ### Suggestions for SQL Improvements - Consider optimizing the `WHERE` clause to filter data as early as possible if feasible. - If performance is critical, explore alternative windowing strategies or aggregation methods if applicable to your use case. ``` ``` -------------------------------- ### POST /api/ai/rule-gen - AI Rule Generation Source: https://ekuiper-manager.superdocs.cloud/p/ai-rule-stream-gen-00f284c7 Generates eKuiper rules using natural language, considering existing streams, connections, and sink configurations for context-aware rule creation. It returns the generated SQL, rule ID, and associated actions. ```APIDOC ## POST /api/ai/rule-gen ### Description Generates eKuiper rules based on natural language input, leveraging context from existing streams, connections, and sink metadata. This ensures generated rules are compatible with your current eKuiper environment. ### Method `POST` ### Endpoint `/api/ai/rule-gen` ### Parameters #### Request Body * **messages** (Array) - Required - The conversation history between the user and AI. * **context** (Object) - Required - Metadata including `streams`, `connections`, and `sinkMetadata`. * **modelName** (String) - Optional - The specific AI model to use. ### Request Example ```json { "messages": [ {"role": "user", "content": "Alert me if temperature exceeds 50 degrees for 5 minutes and send it to the main_db sink."} ], "context": { "streams": ["sensor_data"], "connections": ["main_db_connection"], "sinkMetadata": { "main_db": { "type": "sqldatabase", "connection": "main_db_connection" } } }, "modelName": "google/gemini-flash-1.5" } ``` ### Response #### Success Response (200) * **message** (string) - Explanation for the technician. * **ruleId** (string) - Suggested unique ID for the rule. * **sql** (string) - The generated eKuiper SQL query. * **actions** (Array) - Array of Sink configurations. * **options** (Object) - QoS, EventTime, and other rule options. #### Response Example ```json { "message": "Rule generated to alert when temperature exceeds 50 degrees for 5 minutes and send to main_db.", "ruleId": "temp_alert_rule_123", "sql": "SELECT * FROM sensor_data WHERE temperature > 50 AND tumbling_window(second, 300) GROUP BY key HAVING count(key) > 0", "actions": [ { "sink": "main_db", "data": "*", "sql": "INSERT INTO alerts (rule_id, timestamp, temperature) VALUES (:ruleId, NOW(), :temperature)" } ], "options": { "qos": 1, "enableEventTime": true } } ``` ``` -------------------------------- ### POST /api/ai/capture-logs Source: https://ekuiper-manager.superdocs.cloud/p/smart-log-capture-344f682c Initiates a smart log capture session for specified eKuiper rules. The capture runs for a predefined duration and the data is automatically analyzed by the AI Assistant. ```APIDOC ## POST /api/ai/capture-logs ### Description Initiates a smart log capture session for specified eKuiper rules. The capture runs for a predefined duration and the data is automatically analyzed by the AI Assistant. ### Method POST ### Endpoint /api/ai/capture-logs ### Parameters #### Request Body - **ruleIds** (array[string]) - Required - A list of rule IDs to capture logs from. - **durationLevel** (integer) - Optional - The duration level for the capture (0-4). Defaults to 1 (10 seconds). - 0: 5 Seconds - 1: 10 Seconds (Default) - 2: 20 Seconds - 3: 30 Seconds - 4: 60 Seconds - **serverUrl** (string) - Optional - The URL of the eKuiper server to capture logs from. Defaults to the current server. ### Request Example ```json { "ruleIds": ["rule_1", "rule_2"], "durationLevel": 1, "serverUrl": "http://ekuiper-server:9081" } ``` ### Response #### Success Response (200) - **captured** (object) - An object containing the captured logs for each rule. - **ruleId** (array[object]) - A list of capture sessions for a given rule. - **traceId** (string) - The unique identifier for the trace. - **spans** (array[object]) - A list of spans representing the execution path. - **name** (string) - The name of the operator or node. - **attributes** (object) - Key-value pairs of attributes associated with the span. - **message** (string) - A confirmation message indicating the number of rules captured. #### Response Example ```json { "captured": { "rule_1": [ { "traceId": "...", "spans": [ { "name": "operator_filter", "attributes": { "status": "success", "result": "{\"temp\": 25.5}" } } ] } ] }, "message": "Captured logs from 1 rules" } ``` ``` -------------------------------- ### Fetch Available AI Models (API) Source: https://ekuiper-manager.superdocs.cloud/p/ai-model-selection-f30add4d Retrieve a list of AI models currently enabled and compatible with eKuiper Manager via the internal API. The response includes model IDs and their human-readable names. ```http GET /api/ai/models ``` ```json [ { "id": "google/gemini-2.0-flash-exp", "name": "Google: Gemini 2.0 Flash Experimental" }, { "id": "meta-llama/llama-3.3-70b-instruct", "name": "Meta: Llama 3.3 70B Instruct" } ] ``` -------------------------------- ### Interactive API Playground (Swagger) Source: https://ekuiper-manager.superdocs.cloud/p/api-proxy-swagger-5727b37b The eKuiper Manager provides a built-in Swagger API Playground for exploring and testing the eKuiper REST API. It offers an interactive interface with OpenAPI 3.0 specifications and 'Try It Out' functionality. ```APIDOC ## Interactive API Playground (Swagger) ### Description Access the interactive API documentation and testing environment provided by the eKuiper Manager. ### Access - **Live Demo:** [Interactive API Docs](URL_TO_LIVE_DEMO) - **Local Access:** Navigate to the `/swagger` route on your running eKuiper Manager instance. ### Features - **OpenAPI 3.0 Specification:** Comprehensive schema for over 70 endpoints. - **"Try It Out" Functionality:** Execute API requests directly from the browser. - **Resource Coverage:** Documentation for Streams, Tables, Rules, Plugins, UDFs, and Configuration. ``` -------------------------------- ### List All Streams Source: https://ekuiper-manager.superdocs.cloud/p/import-and-export-52a5cc25 Retrieves a list of all streams managed by a specific eKuiper instance. ```APIDOC ## GET /api/connections/{id}/ekuiper/streams ### Description Lists all streams available on a connected eKuiper instance. ### Method GET ### Endpoint /api/connections/{id}/ekuiper/streams ### Parameters #### Path Parameters - **id** (string) - Required - The Connection ID of the eKuiper server. ### Response #### Success Response (200) - **streams** (array) - A list of stream objects. #### Response Example ```json [ { "id": "demo_stream", "schema": { "type": "JSON", "fields": [ {"name": "temp", "type": "float"}, {"name": "humidity", "type": "bigint"} ] }, "format": "JSON", "type": "mqtt", "datasource": "telemetry/data" } ] ``` ``` -------------------------------- ### Protobuf Schema Management API Source: https://ekuiper-manager.superdocs.cloud/p/schema-management-f7e238f6 Endpoints for managing Protobuf schemas, including listing, fetching, registering, and deleting schemas. ```APIDOC ## GET /schemas/protobuf ### Description Lists all registered Protobuf schemas on the eKuiper server. ### Method GET ### Endpoint /schemas/protobuf ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **schemas** (array) - An array of Protobuf schema objects. - **id** (string) - The unique identifier for the schema. - **content** (string) - The content of the .proto file. #### Response Example ```json { "schemas": [ { "id": "sensors.TemperatureReading", "content": "syntax = \"proto3\";\npackage sensors;\n\nmessage TemperatureReading {\n string sensorId = 1;\n float value = 2;\n int64 timestamp = 3;\n}\n" } ] } ``` ``` ```APIDOC ## GET /schemas/protobuf/{id} ### Description Fetches the details of a specific Protobuf schema identified by its ID. ### Method GET ### Endpoint /schemas/protobuf/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the Protobuf schema to fetch. ### Request Example None ### Response #### Success Response (200) - **id** (string) - The unique identifier for the schema. - **content** (string) - The content of the .proto file. #### Response Example ```json { "id": "sensors.TemperatureReading", "content": "syntax = \"proto3\";\npackage sensors;\n\nmessage TemperatureReading {\n string sensorId = 1;\n float value = 2;\n int64 timestamp = 3;\n}\n" } ``` ``` ```APIDOC ## POST /schemas/protobuf ### Description Registers a new Protobuf schema with the eKuiper server. ### Method POST ### Endpoint /schemas/protobuf ### Parameters #### Request Body - **id** (string) - Required - The desired unique identifier for the schema. - **content** (string) - Required - The content of the .proto file definition. ### Request Example ```json { "id": "sensors.TemperatureReading", "content": "syntax = \"proto3\";\npackage sensors;\n\nmessage TemperatureReading {\n string sensorId = 1;\n float value = 2;\n int64 timestamp = 3;\n}\n" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating successful registration. #### Response Example ```json { "message": "Schema 'sensors.TemperatureReading' registered successfully." } ``` ``` ```APIDOC ## DELETE /schemas/protobuf/{id} ### Description Removes a specific Protobuf schema from the eKuiper server. ### Method DELETE ### Endpoint /schemas/protobuf/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the Protobuf schema to delete. ### Request Example None ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating successful deletion. #### Response Example ```json { "message": "Schema 'sensors.TemperatureReading' deleted successfully." } ``` ```