### Cluster Configuration Examples Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Examples of configuration files for cluster and standalone deployments. ```APIDOC ## Cluster Mode Configuration (cluster-config.json) ### Description Configuration file for XL-LightHouse in cluster mode, defining resource allocations for various components. ### Configuration Example ```json { "lighthouse": { "timezone": "Asia/Shanghai", "ice_xmx_memory": "600M", "ice_xms_memory": "600M", "tasks_driver_memory": "500M", "tasks_executor_memory": "800M", "tasks_direct_memory": "256M", "tasks_num_executors": 6, "tasks_executor_cores": 2, "insights_xmx_memory": "300M", "insights_xms_memory": "300M" }, "zookeeper": { "xmx_memory": "260M", "xms_memory": "260M" }, "hadoop": { "namenode_xmx_memory": "480M", "datanode_xmx_memory": "600M", "yarn.scheduler.maximum-allocation-mb": "160000", "yarn.nodemanager.resource.memory-mb": "168000" }, "hbase": { "master_xmx_memory": "480M", "regionserver_xmx_memory": "1300M" }, "kafka": { "xmx_memory": "300M" }, "redis": { "max_memory": "200M" }, "mysql": { "max_connections": "60", "innodb_buffer_pool_size": "500M" } } ``` ``` ```APIDOC ## Standalone Mode Configuration (standalone-config.json) ### Description Configuration file for XL-LightHouse in standalone mode, defining resource allocations. ### Configuration Example ```json { "lighthouse": { "timezone": "Asia/Shanghai", "standalone_xmx_memory": "500M", "standalone_xms_memory": "500M", "insights_xmx_memory": "256M", "insights_xms_memory": "256M" }, "redis": { "max_memory": "220M" }, "mysql": { "max_connections": "50", "innodb_buffer_pool_size": "600M" } } ``` ``` -------------------------------- ### Standalone Mode Configuration Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Example JSON configuration for XL-LightHouse in standalone mode, defining resource allocations for lighthouse, redis, and mysql. ```json { "lighthouse": { "timezone": "Asia/Shanghai", "standalone_xmx_memory": "500M", "standalone_xms_memory": "500M", "insights_xmx_memory": "256M", "insights_xms_memory": "256M" }, "redis": { "max_memory": "220M" }, "mysql": { "max_connections": "50", "innodb_buffer_pool_size": "600M" } } ``` -------------------------------- ### Cluster Mode Configuration Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Example JSON configuration for XL-LightHouse in cluster mode, defining resource allocations for various components like lighthouse, zookeeper, hadoop, hbase, kafka, redis, and mysql. ```json { "lighthouse": { "timezone": "Asia/Shanghai", "ice_xmx_memory": "600M", "ice_xms_memory": "600M", "tasks_driver_memory": "500M", "tasks_executor_memory": "800M", "tasks_direct_memory": "256M", "tasks_num_executors": 6, "tasks_executor_cores": 2, "insights_xmx_memory": "300M", "insights_xms_memory": "300M" }, "zookeeper": { "xmx_memory": "260M", "xms_memory": "260M" }, "hadoop": { "namenode_xmx_memory": "480M", "datanode_xmx_memory": "600M", "yarn.scheduler.maximum-allocation-mb": "160000", "yarn.nodemanager.resource.memory-mb": "168000" }, "hbase": { "master_xmx_memory": "480M", "regionserver_xmx_memory": "1300M" }, "kafka": { "xmx_memory": "300M" }, "redis": { "max_memory": "200M" }, "mysql": { "max_connections": "60", "innodb_buffer_pool_size": "500M" } } ``` -------------------------------- ### Get Caller Secret Key Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to retrieve the SecretKey for a specific caller ID. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/caller/getSecretKey" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{"id": 1}' ``` -------------------------------- ### LightHouse.dataDurationQuery - Querying Results by Time Range Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Queries statistical results for a single dimension based on a time range. The system automatically determines the relevant time batches within the specified range. Requires caller credentials, stat ID, dimension value, start time, and end time. ```APIDOC ## LightHouse.dataDurationQuery - Querying Results by Time Range dataDurationQuery方法用于按照时间范围查询单个维度的统计结果,无需手动构建批次时间列表,系统会自动根据时间范围返回对应的统计数据。 ### Query Example ```java import com.dtstep.lighthouse.client.LightHouse; import com.dtstep.lighthouse.common.entity.view.StatValue; import com.dtstep.lighthouse.common.util.DateUtil; import java.util.List; // 初始化客户端 (如果尚未初始化) // LightHouse.init("10.206.6.12:4061"); // 调用者凭证 String callerName = "caller:app_waimai_order"; String callerKey = "bK7dImv3HCzBBTQvS9pvlieSfXlVeyMDbWs8RNmj"; // 统计项ID和维度值 int statId = 1100607; String dimensValue = "山东省"; // 按当天时间范围查询 long startTime = DateUtil.getDayStartTime(System.currentTimeMillis()); long endTime = DateUtil.getDayEndTime(System.currentTimeMillis()); // 查询统计结果 List result = LightHouse.dataDurationQuery(callerName, callerKey, statId, dimensValue, startTime, endTime); for (StatValue value : result) { System.out.println("时间: " + DateUtil.formatTimeStamp(value.getBatchTime(), "yyyy-MM-dd HH:mm:ss") + ", 值: " + value.getValue()); } ``` ``` -------------------------------- ### Initialize Java SDK Client Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Connect to the LightHouse service using either basic or custom configuration properties. Use LightHouse.isInit() to verify the connection status. ```java import com.dtstep.lighthouse.client.LightHouse; import java.util.Properties; // 基础初始化 - 连接到LightHouse服务 LightHouse.init("10.206.6.12:4061"); // 带配置参数的初始化 Properties properties = new Properties(); properties.setProperty("lighthouse_process_frequency", "500"); // 处理频率(ms) properties.setProperty("lighthouse_process_batch", "100"); // 批处理大小 LightHouse.init("10.206.6.12:4061", properties); // 检查初始化状态 boolean isInitialized = LightHouse.isInit(); System.out.println("SDK初始化状态: " + isInitialized); ``` -------------------------------- ### Create Project Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Create a new project, which serves as a container for statistical groups and items. Requires an accessKey for authorization. ```bash # 创建项目 # POST /project/create curl -X POST "http://localhost:8080/project/create" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "title": "电商订单统计项目", "departmentId": 1, "privateType": "Public", "desc": "用于统计电商订单相关数据指标", "usersPermission": [{"userId": 1, "roleType": "PROJECT_MANAGE_PERMISSION"}], "departmentsPermission": [] }' ``` -------------------------------- ### Get Group Secret Key Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Retrieve the secret key for a specific statistical group using its ID. This key is used for data reporting. Requires an accessKey for authorization. ```bash # 获取统计组SecretKey # POST /group/getSecretKey curl -X POST "http://localhost:8080/group/getSecretKey" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{"id": 1}' ``` -------------------------------- ### Query Project List Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Retrieve a list of projects, with options for searching and pagination. Requires an accessKey for authorization. ```bash # 查询项目列表 # POST /project/list curl -X POST "http://localhost:8080/project/list" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "queryParams": {"search": "订单"}, "pagination": {"pageNum": 1, "pageSize": 10} }' ``` -------------------------------- ### Java SDK Client Initialization Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Initializes the LightHouse Java SDK client. Supports basic initialization with server address and advanced initialization with custom properties for processing frequency and batch size. Also includes a check for initialization status. ```APIDOC ## Java SDK Client Initialization LightHouse类是Java SDK的核心入口,用于初始化客户端连接、发送统计数据和查询统计结果。初始化时需要提供服务器地址(locators),支持集群模式和单机模式。 ### Basic Initialization ```java import com.dtstep.lighthouse.client.LightHouse; // 基础初始化 - 连接到LightHouse服务 LightHouse.init("10.206.6.12:4061"); ``` ### Initialization with Properties ```java import com.dtstep.lighthouse.client.LightHouse; import java.util.Properties; // 带配置参数的初始化 Properties properties = new Properties(); properties.setProperty("lighthouse_process_frequency", "500"); // 处理频率(ms) properties.setProperty("lighthouse_process_batch", "100"); // 批处理大小 LightHouse.init("10.206.6.12:4061", properties); ``` ### Check Initialization Status ```java import com.dtstep.lighthouse.client.LightHouse; // 检查初始化状态 boolean isInitialized = LightHouse.isInit(); System.out.println("SDK初始化状态: " + isInitialized); ``` ``` -------------------------------- ### Create Metric Set Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to create a new metric set with a title, description, and permission settings. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/metricset/create" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "title": "电商核心指标", "desc": "电商业务核心数据指标集合", "privateType": "Public", "initUsersPermission": [{"userId": 1}], "initDepartmentsPermission": [] }' ``` -------------------------------- ### Query Project by ID Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Fetch the details of a specific project using its ID. Requires an accessKey for authorization. ```bash # 根据ID查询项目详情 # POST /project/queryById curl -X POST "http://localhost:8080/project/queryById" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{"id": 1}' ``` -------------------------------- ### Create Caller Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to create a new caller with a name, description, and department ID. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/caller/create" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "name": "caller:app_waimai_order", "desc": "外卖订单App数据调用方", "departmentId": 1 }' ``` -------------------------------- ### Query Metric Set Bindings Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to query the list of statistics bound to a specific metric set, with pagination. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/metricset/bindlist" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "queryParams": {"id": 1}, "pagination": {"pageNum": 1, "pageSize": 20} }' ``` -------------------------------- ### Refresh Access Key Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint with a Refresh-Token to obtain a new access key. Ensure the provided token is valid. ```bash # 刷新AccessKey # POST /refreshKey curl -X POST "http://localhost:8080/refreshKey" \ -H "Refresh-Token: eyJhbGciOiJIUzUxMiJ9..." ``` -------------------------------- ### List Callers Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to query a list of callers with pagination. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/caller/list" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "queryParams": {}, "pagination": {"pageNum": 1, "pageSize": 10} }' ``` -------------------------------- ### Query TopN/LastN Statistics with Java Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use limitQuery to retrieve ranked statistics for a specific batch time. ```java import com.dtstep.lighthouse.client.LightHouse; import com.dtstep.lighthouse.common.entity.view.LimitValue; import com.dtstep.lighthouse.common.util.DateUtil; import java.util.List; import java.util.concurrent.TimeUnit; // 初始化客户端 LightHouse.init("10.206.6.12:4061"); // 调用者凭证 String callerName = "caller:app_waimai_order"; String callerKey = "bK7dImv3HCzBBTQvS9pvlieSfXlVeyMDbWs8RNmj"; // 统计项ID (TopN/LastN类型统计项) int statId = 1100617; // 批次时间(5分钟粒度) long batchTime = DateUtil.batchTime(5, TimeUnit.MINUTES, DateUtil.getMinuteBefore(System.currentTimeMillis(), 5)); // 查询TopN统计结果 List result = LightHouse.limitQuery(callerName, callerKey, statId, batchTime); for (LimitValue value : result) { System.out.println("维度: " + value.getDimensValue() + ", 排名: " + value.getRank() + ", 值: " + value.getValue()); } ``` -------------------------------- ### POST /api/rpc/v1/stat Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Reports a single data point to the LightHouse system. ```APIDOC ## POST /api/rpc/v1/stat ### Description Reports a single data point to the system. ### Method POST ### Endpoint /api/rpc/v1/stat ### Request Body - **token** (string) - Required - The unique identifier for the stat item. - **secretKey** (string) - Required - Authentication key. - **timestamp** (long) - Required - Event timestamp. - **params** (object) - Required - Data parameters. ### Request Example { "token": "N4C:order_stat", "secretKey": "YEWU3tGjNQL1AevvC9FjNj9SCuvzpYPmLY5akKYz", "timestamp": 1725498000000, "params": { "order_id": "ORD123456", "biz": "food", "user_id": "U789012", "amount": "156.50" } } ``` -------------------------------- ### Bind Statistics to Metric Set Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to bind a list of statistics IDs to an existing metric set. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/metricset/binded" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "id": 1, "statIds": [1100607, 1100608, 1100609] }' ``` -------------------------------- ### Create Stat Item Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Define a statistical item with its formula, time granularity, and dimensions. Supports various aggregation types. Requires an accessKey for authorization. ```bash # 创建统计项 # POST /stat/create curl -X POST "http://localhost:8080/stat/create" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "projectId": 1, "groupId": 1, "title": "每小时订单金额统计", "template": "stat-item(amount,sum)", "timeparam": "1-hour", "desc": "统计每小时的订单总金额" }' ``` -------------------------------- ### User Login API Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Authenticate users to obtain access and refresh keys for JWT authentication. Access keys are valid for 10 minutes, and refresh keys for 8 days. ```bash # 用户登录 # POST /user/login curl -X POST "http://localhost:8080/user/login" \ -H "Content-Type: application/json" \ -d '{ "username": "admin", "password": "your_password" }' ``` -------------------------------- ### Fetch Current User Info Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Retrieve the current user's information using an Authorization Bearer token. The token must be valid and properly formatted. ```bash # 获取当前用户信息 # POST /user/fetchUserInfo curl -X POST "http://localhost:8080/user/fetchUserInfo" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiJ9..." ``` -------------------------------- ### Query Group List Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Retrieve a list of statistical groups, filterable by projectId and with pagination. Requires an accessKey for authorization. ```bash # 查询统计组列表 # POST /group/list curl -X POST "http://localhost:8080/group/list" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "queryParams": {"projectId": 1}, "pagination": {"pageNum": 1, "pageSize": 10} }' ``` -------------------------------- ### Update Project by ID Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Modify the details of an existing project using its ID. Requires an accessKey for authorization. ```bash # 更新项目信息 # POST /project/updateById curl -X POST "http://localhost:8080/project/updateById" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "id": 1, "title": "电商订单统计项目-更新", "desc": "更新后的项目描述" }' ``` -------------------------------- ### Create Group Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Define a statistical group, including its token and column definitions for data reporting. Requires an accessKey for authorization. ```bash # 创建统计组 # POST /group/create curl -X POST "http://localhost:8080/group/create" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "projectId": 1, "token": "order_stat", "desc": "订单统计数据上报", "columns": [ {"name": "order_id", "type": "string", "comment": "订单ID"}, {"name": "user_id", "type": "string", "comment": "用户ID"}, {"name": "province", "type": "string", "comment": "省份"}, {"name": "amount", "type": "number", "comment": "订单金额"} ] }' ``` -------------------------------- ### Star Metric Set Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to mark a metric set as a favorite. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/metricset/starById" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{"id": 1}' ``` -------------------------------- ### LightHouse.dataQuery - Querying Results by Batch Time Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Queries statistical results for a single dimension based on a list of batch times. Requires caller credentials, stat ID, dimension value, and a list of time batches. ```APIDOC ## LightHouse.dataQuery - Querying Results by Batch Time dataQuery方法用于根据批次时间列表查询单个维度的统计结果。需要提供调用者凭证(callerName/callerKey)、统计项ID、维度值和时间批次列表。 ### Query Example ```java import com.dtstep.lighthouse.client.LightHouse; import com.dtstep.lighthouse.common.entity.view.StatValue; import com.dtstep.lighthouse.common.util.DateUtil; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; // 初始化客户端 (如果尚未初始化) // LightHouse.init("10.206.6.12:4061"); // 调用者凭证 String callerName = "caller:app_waimai_order"; String callerKey = "bK7dImv3HCzBBTQvS9pvlieSfXlVeyMDbWs8RNmj"; // 统计项ID和维度值 int statId = 1100607; String dimensValue = "山东省"; // 构建批次时间列表(按分钟粒度) List batchList = new ArrayList<>(); long currentBatch = DateUtil.batchTime(1, TimeUnit.MINUTES, System.currentTimeMillis()); batchList.add(currentBatch); batchList.add(DateUtil.getMinuteBefore(currentBatch, 1)); batchList.add(DateUtil.getMinuteBefore(currentBatch, 2)); // 查询统计结果 List result = LightHouse.dataQuery(callerName, callerKey, statId, dimensValue, batchList); for (StatValue value : result) { System.out.println("批次时间: " + value.getBatchTime() + ", 统计值: " + value.getValue()); } ``` ``` -------------------------------- ### User Authentication API Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt API for user login, authentication, and key management. ```APIDOC ## POST /user/login ### Description User login API returns accessKey and refreshKey for subsequent API calls' JWT authentication. accessKey is valid for 10 minutes, and refreshKey is valid for 8 days. ### Method POST ### Endpoint http://localhost:8080/user/login ### Request Body - **username** (string) - Required - The username for login. - **password** (string) - Required - The password for login. ### Request Example { "username": "admin", "password": "your_password" } ### Response #### Success Response (200) - **code** (string) - Response code. - **data** (object) - Contains accessKey and refreshKey. - **accessKey** (string) - The access key for authentication. - **refreshKey** (string) - The refresh key for obtaining new access keys. #### Response Example { "code": "0", "data": { "accessKey": "eyJhbGciOiJIUzUxMiJ9...", "refreshKey": "eyJhbGciOiJIUzUxMiJ9..." } } ``` ```APIDOC ## POST /refreshKey ### Description Refreshes the access key using the provided refresh token. ### Method POST ### Endpoint http://localhost:8080/refreshKey ### Headers - **Refresh-Token** (string) - Required - The refresh token obtained from login. ### Request Example (No request body, uses Refresh-Token header) ``` ```APIDOC ## POST /user/fetchUserInfo ### Description Fetches the current user's information. ### Method POST ### Endpoint http://localhost:8080/user/fetchUserInfo ### Headers - **Content-Type**: application/json - **Authorization**: Bearer {accessKey} ### Request Example (No request body, uses Authorization header) ``` -------------------------------- ### Query Multi-dimensional Statistics with Java Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use dataQueryWithDimensList to retrieve statistics for multiple dimensions across specific batch times. ```java import com.dtstep.lighthouse.client.LightHouse; import com.dtstep.lighthouse.common.entity.view.StatValue; import com.dtstep.lighthouse.common.util.DateUtil; import java.util.*; import java.util.concurrent.TimeUnit; // 初始化客户端 LightHouse.init("10.206.6.12:4061"); // 调用者凭证 String callerName = "caller:app_waimai_order"; String callerKey = "bK7dImv3HCzBBTQvS9pvlieSfXlVeyMDbWs8RNmj"; // 统计项ID int statId = 1100613; // 多个维度值列表 List dimensValueList = Arrays.asList("21", "72", "36"); // 构建批次时间列表 List batchList = new ArrayList<>(); batchList.add(DateUtil.parseDate("2024-09-05 09:00:00", "yyyy-MM-dd HH:mm:ss")); batchList.add(DateUtil.parseDate("2024-09-05 08:00:00", "yyyy-MM-dd HH:mm:ss")); batchList.add(DateUtil.parseDate("2024-09-05 07:00:00", "yyyy-MM-dd HH:mm:ss")); // 批量查询多维度统计结果 Map> resultMap = LightHouse.dataQueryWithDimensList( callerName, callerKey, statId, dimensValueList, batchList); // 遍历结果 for (Map.Entry> entry : resultMap.entrySet()) { System.out.println("维度: " + entry.getKey()); for (StatValue value : entry.getValue()) { System.out.println(" 时间: " + value.getBatchTime() + ", 值: " + value.getValue()); } } ``` -------------------------------- ### Delete Project by ID Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Remove a project using its ID. Requires an accessKey for authorization. ```bash # 删除项目 # POST /project/deleteById curl -X POST "http://localhost:8080/project/deleteById" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{"id": 1}' ``` -------------------------------- ### Send Statistical Data with LightHouse.stat Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Submit statistical data points to the service using a token and secret key. Supports single, repeated, and batch data submissions. ```java import com.dtstep.lighthouse.client.LightHouse; import com.dtstep.lighthouse.common.random.RandomID; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ThreadLocalRandom; // 初始化客户端 LightHouse.init("10.206.6.12:4061"); // 准备统计数据 String token = "test_scene_behavior_stat"; String secretKey = "7G13E6ssmGSGO7aFQgbE0VhqD2bizmkv09fIFxlj"; long timestamp = System.currentTimeMillis(); // 构建参数Map Map params = new HashMap<>(); params.put("uid", RandomID.id(6)); // 用户ID params.put("province", ThreadLocalRandom.current().nextInt(10)); // 省份 Double amount = ThreadLocalRandom.current().nextDouble(1000); params.put("stay_time", String.format("%.3f", amount)); // 停留时间 // 发送单条统计数据 LightHouse.stat(token, secretKey, params, timestamp); // 发送重复数据(repeat=5表示发送5次相同数据) LightHouse.stat(token, secretKey, params, 5, timestamp); // 批量发送示例 for (int i = 0; i < 100; i++) { Map map = new HashMap<>(); map.put("order_id", RandomID.id(6)); map.put("user_id", RandomID.id(6)); map.put("amount", String.format("%.3f", ThreadLocalRandom.current().nextDouble(1000))); LightHouse.stat(token, secretKey, map, timestamp); } ``` -------------------------------- ### Grant Caller Permissions Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to grant specific permissions to a caller. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/caller/grant" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "resourceId": 1, "roleType": "CALLER_MANAGER_PERMISSION", "usersPermissions": [{"userId": 2}] }' ``` -------------------------------- ### Query Stat Item List Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Retrieve a list of statistical items, filterable by group IDs and with pagination. Requires an accessKey for authorization. ```bash # 查询统计项列表 # POST /stat/list curl -X POST "http://localhost:8080/stat/list" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "queryParams": {"groupIds": [1]}, "pagination": {"pageNum": 1, "pageSize": 10} }' ``` -------------------------------- ### Query TopN Statistics Data Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to query TopN statistics data for specific batch times. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/data/limit" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "statId": 1100617, "batchTimeList": [1729415100000, 1729411500000] }' ``` -------------------------------- ### Query Statistics Data Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to query general statistics data within a specified time range and with optional dimension parameters. Requires Content-Type and Authorization headers. ```bash curl -X POST "http://localhost:8080/data/stat" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{ "statId": 1100607, "startTime": 1729353600000, "endTime": 1729439999999, "dimensParams": {"province": "山东省"} }' ``` -------------------------------- ### LightHouse.stat - Sending Statistical Data Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Sends statistical data to the LightHouse service. Requires a token, secretKey, a map of parameters, and a timestamp. Supports sending single data points, repeated data points, and batch data. ```APIDOC ## LightHouse.stat - Sending Statistical Data stat方法用于向LightHouse服务发送统计数据。需要提供统计组token、secretKey、参数Map和时间戳。支持repeat参数用于批量发送相同数据。 ### Single Data Point ```java import com.dtstep.lighthouse.client.LightHouse; import com.dtstep.lighthouse.common.random.RandomID; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ThreadLocalRandom; // 初始化客户端 (如果尚未初始化) // LightHouse.init("10.206.6.12:4061"); // 准备统计数据 String token = "test_scene_behavior_stat"; String secretKey = "7G13E6ssmGSGO7aFQgbE0VhqD2bizmkv09fIFxlj"; long timestamp = System.currentTimeMillis(); // 构建参数Map Map params = new HashMap<>(); params.put("uid", RandomID.id(6)); // 用户ID params.put("province", ThreadLocalRandom.current().nextInt(10)); // 省份 Double amount = ThreadLocalRandom.current().nextDouble(1000); params.put("stay_time", String.format("%.3f", amount)); // 停留时间 // 发送单条统计数据 LightHouse.stat(token, secretKey, params, timestamp); ``` ### Repeated Data Points ```java import com.dtstep.lighthouse.client.LightHouse; import java.util.Map; // 发送重复数据(repeat=5表示发送5次相同数据) // Assuming 'token', 'secretKey', 'params', 'timestamp' are already defined as above // LightHouse.stat(token, secretKey, params, 5, timestamp); ``` ### Batch Data ```java import com.dtstep.lighthouse.client.LightHouse; import com.dtstep.lighthouse.common.random.RandomID; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ThreadLocalRandom; // 初始化客户端 (如果尚未初始化) // LightHouse.init("10.206.6.12:4061"); // 批量发送示例 String token = "test_scene_behavior_stat"; String secretKey = "7G13E6ssmGSGO7aFQgbE0VhqD2bizmkv09fIFxlj"; long timestamp = System.currentTimeMillis(); for (int i = 0; i < 100; i++) { Map map = new HashMap<>(); map.put("order_id", RandomID.id(6)); map.put("user_id", RandomID.id(6)); map.put("amount", String.format("%.3f", ThreadLocalRandom.current().nextDouble(1000))); LightHouse.stat(token, secretKey, map, timestamp); } ``` ``` -------------------------------- ### Project Management API Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt APIs for managing projects, which serve as containers for statistical groups and items. ```APIDOC ## POST /project/create ### Description Creates a new project. ### Method POST ### Endpoint http://localhost:8080/project/create ### Headers - **Content-Type**: application/json - **Authorization**: Bearer {accessKey} ### Request Body - **title** (string) - Required - The title of the project. - **departmentId** (integer) - Required - The ID of the department. - **privateType** (string) - Required - The privacy type of the project (e.g., "Public"). - **desc** (string) - Optional - Description of the project. - **usersPermission** (array) - Optional - List of user permissions. - **userId** (integer) - Required - The user ID. - **roleType** (string) - Required - The role type (e.g., "PROJECT_MANAGE_PERMISSION"). - **departmentsPermission** (array) - Optional - List of department permissions. ### Request Example { "title": "电商订单统计项目", "departmentId": 1, "privateType": "Public", "desc": "用于统计电商订单相关数据指标", "usersPermission": [{"userId": 1, "roleType": "PROJECT_MANAGE_PERMISSION"}], "departmentsPermission": [] } ``` ```APIDOC ## POST /project/list ### Description Queries a list of projects with optional search parameters and pagination. ### Method POST ### Endpoint http://localhost:8080/project/list ### Headers - **Content-Type**: application/json - **Authorization**: Bearer {accessKey} ### Request Body - **queryParams** (object) - Optional - Query parameters for filtering. - **search** (string) - Optional - Search term for project titles. - **pagination** (object) - Optional - Pagination settings. - **pageNum** (integer) - Required - The page number. - **pageSize** (integer) - Required - The number of items per page. ### Request Example { "queryParams": {"search": "订单"}, "pagination": {"pageNum": 1, "pageSize": 10} } ``` ```APIDOC ## POST /project/queryById ### Description Queries project details by its ID. ### Method POST ### Endpoint http://localhost:8080/project/queryById ### Headers - **Content-Type**: application/json - **Authorization**: Bearer {accessKey} ### Request Body - **id** (integer) - Required - The ID of the project. ### Request Example {"id": 1} ``` ```APIDOC ## POST /project/updateById ### Description Updates project information by its ID. ### Method POST ### Endpoint http://localhost:8080/project/updateById ### Headers - **Content-Type**: application/json - **Authorization**: Bearer {accessKey} ### Request Body - **id** (integer) - Required - The ID of the project to update. - **title** (string) - Optional - The new title for the project. - **desc** (string) - Optional - The new description for the project. ### Request Example { "id": 1, "title": "电商订单统计项目-更新", "desc": "更新后的项目描述" } ``` ```APIDOC ## POST /project/deleteById ### Description Deletes a project by its ID. ### Method POST ### Endpoint http://localhost:8080/project/deleteById ### Headers - **Content-Type**: application/json - **Authorization**: Bearer {accessKey} ### Request Body - **id** (integer) - Required - The ID of the project to delete. ### Request Example {"id": 1} ``` -------------------------------- ### Query Stat Item by ID Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Fetch the details of a specific statistical item using its ID. Requires an accessKey for authorization. ```bash # 根据ID查询统计项详情 # POST /stat/queryById curl -X POST "http://localhost:8080/stat/queryById" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{"id": 1}' ``` -------------------------------- ### Query Data via HTTP API Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Retrieve statistics using various query endpoints, requiring Caller-Name and Caller-Key headers for authentication. ```bash # 按批次时间查询单维度统计结果 # POST /api/rpc/v1/dataQuery curl -X POST "http://10.206.6.31:18101/api/rpc/v1/dataQuery" \ -H "Content-Type: application/json" \ -H "Caller-Name: caller:app_waimai_order" \ -H "Caller-Key: bK7dImv3HCzBBTQvS9pvlieSfXlVeyMDbWs8RNmj" \ -d '{ "statId": "1100607", "dimensValue": "山东省", "batchList": [1725498000000, 1725494400000, 1725490800000] }' # 按时间范围查询单维度统计结果 # POST /api/rpc/v1/dataDurationQuery curl -X POST "http://10.206.6.31:18101/api/rpc/v1/dataDurationQuery" \ -H "Content-Type: application/json" \ -H "Caller-Name: caller:app_waimai_order" \ -H "Caller-Key: bK7dImv3HCzBBTQvS9pvlieSfXlVeyMDbWs8RNmj" \ -d '{ "statId": "1100607", "dimensValue": "山东省", "startTime": 1729353600000, "endTime": 1729439999999 }' # 批量查询多维度统计结果 # POST /api/rpc/v1/dataQueryWithDimensList curl -X POST "http://10.206.6.31:18101/api/rpc/v1/dataQueryWithDimensList" \ -H "Content-Type: application/json" \ -H "Caller-Name: caller:app_waimai_order" \ -H "Caller-Key: bK7dImv3HCzBBTQvS9pvlieSfXlVeyMDbWs8RNmj" \ -d '{ "statId": "1100613", "dimensValueList": ["21", "72", "36"], "batchList": [1725498000000, 1725494400000] }' ``` -------------------------------- ### Query Limit Data Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Use this endpoint to query limit data. Requires specific statId and batchTime. ```bash curl -X POST "http://10.206.6.31:18101/api/rpc/v1/limitQuery" \ -H "Content-Type: application/json" \ -H "Caller-Name: caller:app_waimai_order" \ -H "Caller-Key: bK7dImv3HCzBBTQvS9pvlieSfXlVeyMDbWs8RNmj" \ -d '{ "statId": "1100617", "batchTime": 1729415100000 }' ``` -------------------------------- ### Report Data via HTTP API Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Perform single or batch data reporting using JSON payloads via POST requests. ```bash # 单条数据上报 # POST /api/rpc/v1/stat curl -X POST "http://10.206.6.31:18101/api/rpc/v1/stat" \ -H "Content-Type: application/json" \ -d '{ "token": "N4C:order_stat", "secretKey": "YEWU3tGjNQL1AevvC9FjNj9SCuvzpYPmLY5akKYz", "timestamp": 1725498000000, "params": { "order_id": "ORD123456", "biz": "food", "user_id": "U789012", "amount": "156.50" } }' # 批量数据上报 # POST /api/rpc/v1/stats curl -X POST "http://10.206.6.31:18101/api/rpc/v1/stats" \ -H "Content-Type: application/json" \ -d '[ { "token": "N4C:order_stat", "secretKey": "YEWU3tGjNQL1AevvC9FjNj9SCuvzpYPmLY5akKYz", "timestamp": 1725498000000, "params": {"order_id": "ORD001", "biz": "food", "user_id": "U001", "amount": "100.00"} }, { "token": "N4C:order_stat", "secretKey": "YEWU3tGjNQL1AevvC9FjNj9SCuvzpYPmLY5akKYz", "timestamp": 1725498000000, "params": {"order_id": "ORD002", "biz": "drink", "user_id": "U002", "amount": "50.00"} } ]' ``` -------------------------------- ### Data Query API (Web) Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt APIs for querying statistical and TopN data for web visualization. ```APIDOC ## POST /data/stat ### Description Queries statistical data within a specified time range and dimensions. ### Method POST ### Endpoint /data/stat ### Request Body - **statId** (integer) - Required - The ID of the statistic to query. - **startTime** (long) - Required - The start timestamp (milliseconds). - **endTime** (long) - Required - The end timestamp (milliseconds). - **dimensParams** (object) - Optional - Dimension parameters for filtering (e.g., {"province": "山东省"}). ### Request Example ```json { "statId": 1100607, "startTime": 1729353600000, "endTime": 1729439999999, "dimensParams": {"province": "山东省"} } ``` ### Response (Success response details not provided in source) ``` ```APIDOC ## POST /data/limit ### Description Queries TopN statistical data for specified batch times. ### Method POST ### Endpoint /data/limit ### Request Body - **statId** (integer) - Required - The ID of the statistic to query. - **batchTimeList** (array) - Required - A list of batch timestamps (milliseconds). ### Request Example ```json { "statId": 1100617, "batchTimeList": [1729415100000, 1729411500000] } ``` ### Response (Success response details not provided in source) ``` -------------------------------- ### Query Group by ID Source: https://context7.com/xl-xueling/xl-lighthouse/llms.txt Fetch the details of a specific statistical group using its ID. Requires an accessKey for authorization. ```bash # 根据ID查询统计组 # POST /group/queryById curl -X POST "http://localhost:8080/group/queryById" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {accessKey}" \ -d '{"id": 1}' ```