LogRecord Operations

BLS

  • Function Release Records
  • Product Description
    • Usage restrictions
    • Product Introduction
  • Product pricing
  • Quick Start
    • Introduction
    • Install agent
    • Create LogStore
    • Create Transmission Task
    • Log Analysis and Alerting
    • Create Delivery Task
  • Operation guide
    • Baidu Intelligent Cloud Environment Preparation
    • Overview
    • Identity and access management
    • Logset Management
    • Agent
      • Install Agent on Host
      • Install Agent in K8s Environment
      • Agent Management
      • Agent Release Version
      • Set Agent Startup Parameters
    • Log Collection
      • Transmission Task Collection
        • Create Transmission Task
        • Manage Transmission Task
      • Uploading Logs Using Kafka Protocol
    • Query analysis
      • Log query
      • SQL Syntax
      • Search Syntax
    • Dashboard
      • Overview
      • Management Dashboard
      • Management Dashboard Charts
    • Alarm management
      • Alert Overview
      • Alarm strategy
        • Management alarm strategy
        • Trigger conditions
      • Alarm history
      • Alert execution statistics
      • Alarm notification
        • Alarm Notification Template
        • Alarm callback
    • Data processing
      • Log Delivery
        • Log Delivery Overview
        • Create Delivery Task
        • Manage Delivery Task
      • Scheduled SQL Analysis
        • Manage Scheduled SQL Analysis Task
        • Create Scheduled SQL Analysis Task
      • Real-Time Consumption
      • Data processing
        • Data processing
          • Overview of data processing functions
          • Process control function
          • Mapping enrichment functions
          • Event operation functions
          • Field operation functions
          • Field value extraction functions
    • Log Applications
      • Intelligent Diagnostics
  • Best Practices
    • Use Year-Over-Year and Month-Over-Month as Alert Trigger Conditions
    • BLS Integration with Kibana
    • Use BLS via Grafana
  • Development Guide
    • API Reference
      • API function release records
      • API Overview
      • Interface Overview
      • General Description
      • Service domain
      • Common error codes
      • Terminology
      • Project Related APIs
        • Create Project
        • Update Project
        • Describe Project
        • Delete Project
        • List Project
      • LogStore Related APIs
        • Create LogStore
        • Update LogStore
        • Delete LogStore
        • Describe LogStore
        • Batch Get LogStore
        • List LogStore
      • LogStream Related APIs
        • List LogStream
      • LogRecord Related APIs
        • Push log PushLogRecord
        • Obtain logrecord PullLogRecord
        • Search analysis log QueryLogRecord
        • Histogram API QueryLogHistogram
      • Fast Query FastQuery Related Interfaces
        • Create Fast Query CreateFastQuery
        • Update Fast Query UpdateFastQuery
        • Delete Fast Query DeleteFastQuery
        • Get Fast Query Details DescribeFastQuery
        • Get Fast Query List ListFastQuery
      • Index Related APIs
        • Create Index
        • Update Index
        • Delete Index
        • Describe Index
      • Log Shipper LogShipper Related Interfaces
        • Create Log Shipper
        • Update Log Shipper
        • Set Single Log Shipper Status
        • Delete Single Log Shipper
        • Bulk Delete Log Shipper
        • List Log Shipper Records
        • List Log Shipper
        • Bulk Set Log Shipper Status
        • Get Log Shipper
      • Alarm-Related Interfaces
        • CreateAlarmPolicy
        • UpdateAlarmPolicy
        • DeleteAlarmPolicy
        • ValidateAlarmCondition
        • ValidateAlarmPolicySQL
        • EnableAlarmPolicy
        • DescribeAlarmRecord
        • DisableAlarmPolicy
        • DescribeAlarmPolicy
        • ListAlarmPolicy
        • ListAlarmRecord
        • ListAlarmExecutionStats
        • ListAlarmExecutions
      • LogStore Template-Related Interfaces
        • CreateLogStoreTemplate
        • UpdateLogStoreTemplate
        • DeleteLogStoreTemplates
        • DescribeLogStoreTemplates
        • DescribeLogStoreTemplate
      • Download Log Download Related Interfaces
        • Create Download Task CreateDownloadTask
        • Get Download Task List ListDownloadTask
        • Delete Download Task DeleteDownloadTask
        • Get Download Task Address GetDownloadTaskLink
        • Get Download Task Details DescribeDownloadTask
      • LogAlarm Related Interfaces
        • SetLogAlarmStatus
        • deleteLogAlarm
        • createLogAlarm
        • listLogAlarm
        • updateLogAlarm
        • BulkDeleteLogAlarm
        • PreviewAlarmLogRecord
        • getLogAlarm
        • BulkSetLogAlarmStatus
      • Transmission Task Related Interfaces
        • Create Task CreateTask
        • UpdateTask
      • Interfaces Compatible with Elasticsearch
        • ResolveIndex
        • FieldCaps
        • TermsEnum
        • AsyncSearch
    • SDK Reference
      • Go SDK
        • Overview
        • Initialization
        • Version Release Records
        • Project Operations
        • LogStore Operations
        • Install the SDK Package
        • LogStream Operations
        • LogRecord Operations
        • FastQuery Operations
        • LogShipper Operations
        • Index Operations
        • Download Task Operations
      • Java SDK
        • Overview
        • Install the SDK Package
        • LogRecord Operations
      • iOS SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android & iOS SDK Download
      • SDK Privacy Policy
      • SDK Developer Personal Information Protection Compliance Guide
    • Importing SLS Collection Configuration
  • FAQs
    • Common Questions Overview
    • Fault-related questions
    • Configuration-related questions
  • Log Service Level Agreement SLA
All documents
menu
No results found, please re-enter

BLS

  • Function Release Records
  • Product Description
    • Usage restrictions
    • Product Introduction
  • Product pricing
  • Quick Start
    • Introduction
    • Install agent
    • Create LogStore
    • Create Transmission Task
    • Log Analysis and Alerting
    • Create Delivery Task
  • Operation guide
    • Baidu Intelligent Cloud Environment Preparation
    • Overview
    • Identity and access management
    • Logset Management
    • Agent
      • Install Agent on Host
      • Install Agent in K8s Environment
      • Agent Management
      • Agent Release Version
      • Set Agent Startup Parameters
    • Log Collection
      • Transmission Task Collection
        • Create Transmission Task
        • Manage Transmission Task
      • Uploading Logs Using Kafka Protocol
    • Query analysis
      • Log query
      • SQL Syntax
      • Search Syntax
    • Dashboard
      • Overview
      • Management Dashboard
      • Management Dashboard Charts
    • Alarm management
      • Alert Overview
      • Alarm strategy
        • Management alarm strategy
        • Trigger conditions
      • Alarm history
      • Alert execution statistics
      • Alarm notification
        • Alarm Notification Template
        • Alarm callback
    • Data processing
      • Log Delivery
        • Log Delivery Overview
        • Create Delivery Task
        • Manage Delivery Task
      • Scheduled SQL Analysis
        • Manage Scheduled SQL Analysis Task
        • Create Scheduled SQL Analysis Task
      • Real-Time Consumption
      • Data processing
        • Data processing
          • Overview of data processing functions
          • Process control function
          • Mapping enrichment functions
          • Event operation functions
          • Field operation functions
          • Field value extraction functions
    • Log Applications
      • Intelligent Diagnostics
  • Best Practices
    • Use Year-Over-Year and Month-Over-Month as Alert Trigger Conditions
    • BLS Integration with Kibana
    • Use BLS via Grafana
  • Development Guide
    • API Reference
      • API function release records
      • API Overview
      • Interface Overview
      • General Description
      • Service domain
      • Common error codes
      • Terminology
      • Project Related APIs
        • Create Project
        • Update Project
        • Describe Project
        • Delete Project
        • List Project
      • LogStore Related APIs
        • Create LogStore
        • Update LogStore
        • Delete LogStore
        • Describe LogStore
        • Batch Get LogStore
        • List LogStore
      • LogStream Related APIs
        • List LogStream
      • LogRecord Related APIs
        • Push log PushLogRecord
        • Obtain logrecord PullLogRecord
        • Search analysis log QueryLogRecord
        • Histogram API QueryLogHistogram
      • Fast Query FastQuery Related Interfaces
        • Create Fast Query CreateFastQuery
        • Update Fast Query UpdateFastQuery
        • Delete Fast Query DeleteFastQuery
        • Get Fast Query Details DescribeFastQuery
        • Get Fast Query List ListFastQuery
      • Index Related APIs
        • Create Index
        • Update Index
        • Delete Index
        • Describe Index
      • Log Shipper LogShipper Related Interfaces
        • Create Log Shipper
        • Update Log Shipper
        • Set Single Log Shipper Status
        • Delete Single Log Shipper
        • Bulk Delete Log Shipper
        • List Log Shipper Records
        • List Log Shipper
        • Bulk Set Log Shipper Status
        • Get Log Shipper
      • Alarm-Related Interfaces
        • CreateAlarmPolicy
        • UpdateAlarmPolicy
        • DeleteAlarmPolicy
        • ValidateAlarmCondition
        • ValidateAlarmPolicySQL
        • EnableAlarmPolicy
        • DescribeAlarmRecord
        • DisableAlarmPolicy
        • DescribeAlarmPolicy
        • ListAlarmPolicy
        • ListAlarmRecord
        • ListAlarmExecutionStats
        • ListAlarmExecutions
      • LogStore Template-Related Interfaces
        • CreateLogStoreTemplate
        • UpdateLogStoreTemplate
        • DeleteLogStoreTemplates
        • DescribeLogStoreTemplates
        • DescribeLogStoreTemplate
      • Download Log Download Related Interfaces
        • Create Download Task CreateDownloadTask
        • Get Download Task List ListDownloadTask
        • Delete Download Task DeleteDownloadTask
        • Get Download Task Address GetDownloadTaskLink
        • Get Download Task Details DescribeDownloadTask
      • LogAlarm Related Interfaces
        • SetLogAlarmStatus
        • deleteLogAlarm
        • createLogAlarm
        • listLogAlarm
        • updateLogAlarm
        • BulkDeleteLogAlarm
        • PreviewAlarmLogRecord
        • getLogAlarm
        • BulkSetLogAlarmStatus
      • Transmission Task Related Interfaces
        • Create Task CreateTask
        • UpdateTask
      • Interfaces Compatible with Elasticsearch
        • ResolveIndex
        • FieldCaps
        • TermsEnum
        • AsyncSearch
    • SDK Reference
      • Go SDK
        • Overview
        • Initialization
        • Version Release Records
        • Project Operations
        • LogStore Operations
        • Install the SDK Package
        • LogStream Operations
        • LogRecord Operations
        • FastQuery Operations
        • LogShipper Operations
        • Index Operations
        • Download Task Operations
      • Java SDK
        • Overview
        • Install the SDK Package
        • LogRecord Operations
      • iOS SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android & iOS SDK Download
      • SDK Privacy Policy
      • SDK Developer Personal Information Protection Compliance Guide
    • Importing SLS Collection Configuration
  • FAQs
    • Common Questions Overview
    • Fault-related questions
    • Configuration-related questions
  • Log Service Level Agreement SLA
  • Document center
  • arrow
  • BLS
  • arrow
  • Development Guide
  • arrow
  • SDK Reference
  • arrow
  • Java SDK
  • arrow
  • LogRecord Operations
Table of contents on this page
  • Push log PushLogRecord
  • Obtain logrecord PullLogRecord
  • Search analysis log QueryLogRecord
  • Histogram API QueryLogHistogram

LogRecord Operations

Updated at:2025-11-03

Push log PushLogRecord

Support bulk pushing of log records to the BLS platform. The log record format can be either TEXT or JSON. For TEXT log records, logs remain unprocessed; for JSON log records, JSON fields are automatically identified (only first-level fields are currently supported, nested fields are not yet supported).

To upload both specific fields extracted from processing and the raw log text, you can use JSON format, including the raw log text as part of JSON (@raw as the key and the raw log text as the value). When processing @raw, BLS will interpret its content as the raw log text.

Use the following code to bulk push JSON log records to the specified log stream within the specified LogStore.

Java
1import com.baidubce.auth.DefaultBceCredentials;
2import com.baidubce.services.bls.BlsClient;
3import com.baidubce.services.bls.BlsClientConfiguration;
4import com.baidubce.services.bls.model.logrecord.LogRecord;
5import com.baidubce.services.bls.model.logrecord.LogType;
6import com.baidubce.services.bls.model.logrecord.PushLogRecordRequest;
7import java.util.ArrayList;
8import java.util.List;
9public class ExamplePushLogRecord {
10    public static void main(String[] args) {
11        String ak = "Your Ak";
12        String sk = "Your Sk";
13        String endpoint = "bls-log.bj.baidubce.com";
14        BlsClientConfiguration config = new BlsClientConfiguration();
15        config.setEndpoint(endpoint);
16        config.setCredentials(new DefaultBceCredentials(ak, sk));
17 // Create BLS client
18        BlsClient client = new BlsClient(config);
19        PushLogRecordRequest request = new PushLogRecordRequest();
20        List<LogRecord> logRecords = new ArrayList<>();
21        logRecords.add(new LogRecord(1742281309000L, "{\"key1\":\"value\", \"key2\": \"value2\" }"));
22 // Set target project group name
23        request.setProject("default");
24 // Set target logstore name
25        request.setLogStoreName("logstorename");
26 // Set log format to JSON
27        request.setType(LogType.JSON);
28 // Set log
29        request.setLogRecords(logRecords);
30 // Execute log pushing
31        client.PushLogRecord(request);
32    }
33}

Obtain logrecord PullLogRecord

With following codes, view the logrecords in the specified logstream, and obtain the recent logrecord contents or the time range of use for filtering.

Java
1package com.baidubce.examples.bls;
2import com.baidubce.auth.DefaultBceCredentials;
3import com.baidubce.services.bls.BlsClient;
4import com.baidubce.services.bls.BlsClientConfiguration;
5import com.baidubce.services.bls.model.logrecord.*;
6public class ExamplePullLogRecord {
7    public static void main(String[] args) {
8        String ak = "Your Ak";
9        String sk = "Your Sk";
10        String endpoint = "bls-log.bj.baidubce.com";
11        BlsClientConfiguration config = new BlsClientConfiguration();
12        config.setEndpoint(endpoint);
13        config.setCredentials(new DefaultBceCredentials(ak, sk));
14 // Create BLS client
15        BlsClient client = new BlsClient(config);
16        PullLogRecordRequest request = new PullLogRecordRequest();
17 // Set target project group name
18        request.setProject("default");
19 // Set target logstore name
20        request.setLogStoreName("logstorename");
21 // Set start time of log query
22        request.setStartDateTime("2025-03-17T02:04:05Z");
23 // Set end time of log query
24        request.setEndDateTime("2025-03-17T15:04:05Z");
25 // Set maximum number of returned items
26        request.setLimit(10);
27 // Execute log query
28        PullLogRecordResponse resp = client.pullLogRecord(request);
29        System.out.println(resp);
30    }
31}

Search analysis log QueryLogRecord

Users can search or analyze data in a specified logstore by submitting a query. Only one logstore can be queried at a time.

Query statements support three formats, such as:

  • match search statement: it is required to enable the full-text index or field-level index and search the log contents according to the conditions, for example:match method:GET and status >= 400
  • SQL statement: execute SQL statements, for example: select * limit 10
  • match search statement| SQL statement: it is required to enable the full-text index or field-level index and execute SQL statements on the result set that meets the search conditions, with the search statement separated from the SQL statement by a vertical line, for example: match method:GET and status >= 400 | select host, count(*) group by host

Query related restrictions are as follows:

  • The maximum number of query concurrency supported by each account is 15
  • Limit the size of the returned result set to a maximum of 1 MB or 1,000 records.

For search syntax, please refer to Search Syntax

SQL statements may not contain from clauses, and syntax details may refer to SQL Syntax

Use the following code to query log records that satisfy specified conditions within the desired LogStore.

Java
1import com.baidubce.auth.DefaultBceCredentials;
2import com.baidubce.services.bls.BlsClient;
3import com.baidubce.services.bls.BlsClientConfiguration;
4import com.baidubce.services.bls.model.logrecord.QueryLogRecordRequest;
5import com.baidubce.services.bls.model.logrecord.QueryLogRecordResponse;
6public class ExampleQueryLogRecord {
7    public static void main(String[] args) {
8        String ak = "Your Ak";
9        String sk = "Your Sk";
10        String endpoint = "bls-log.bj.baidubce.com";
11        BlsClientConfiguration config = new BlsClientConfiguration();
12        config.setEndpoint(endpoint);
13        config.setCredentials(new DefaultBceCredentials(ak, sk));
14 // Create BLS client
15        BlsClient client = new BlsClient(config);
16        QueryLogRecordRequest request = new QueryLogRecordRequest();
17 // Set target project group name
18        request.setProject("default");
19 // Set target logstore name
20        request.setLogStoreName("logstorename");
21 // Set start time of log query
22        request.setStartDateTime("2025-03-17T02:04:05Z");
23 // Set end time of log query
24        request.setEndDateTime("2025-03-17T15:04:05Z");
25 // Set search statement
26        request.setQuery("match level:info");
27 // Execute log search
28        QueryLogRecordResponse response = client.queryLogRecord(request);
29        System.out.println(response);
30    }
31}

Histogram API QueryLogHistogram

Users can analyze data using statistical histograms by submitting query search statements. Note that only one logstore can be queried at a time.

Query statements support three formats, such as:

  • match search statement: return the log histogram statistics that meets search conditions
  • SQL statement: return the histogram statistics of all logs
  • match search statement | SQL statement: according to search conditions, return the following restrictions for log histogram statistics query that meet search conditions:

    • Index must be enabled on the logstore; otherwise, the histogram query will return an error
    • The maximum query time is 60 seconds; an error is returned if no statistic result is obtained over 60 seconds.

For search syntax, please refer to Search Syntax

Use the following code to query logs that meet the specified conditions within the intended LogStore.

Java
1import com.baidubce.auth.DefaultBceCredentials;
2import com.baidubce.services.bls.BlsClient;
3import com.baidubce.services.bls.BlsClientConfiguration;
4import com.baidubce.services.bls.model.logrecord.QueryLogHistogramRequest;
5import com.baidubce.services.bls.model.logrecord.QueryLogHistogramResponse;
6public class ExampleQueryLogHistogram {
7    public static void main(String[] args) {
8        String ak = "Your Ak";
9        String sk = "Your Sk";
10        String endpoint = "bls-log.bj.baidubce.com";
11        BlsClientConfiguration config = new BlsClientConfiguration();
12        config.setEndpoint(endpoint);
13        config.setCredentials(new DefaultBceCredentials(ak, sk));
14 // Create BLS client
15        BlsClient client = new BlsClient(config);
16        QueryLogHistogramRequest request = new QueryLogHistogramRequest();
17 // Set target project group name
18        request.setProject("default");
19 // Set target logstore name
20        request.setLogStoreName("logstorename");
21 // Set start time of log query
22        request.setStartDateTime("2025-03-17T02:04:05Z");
23 // Set end time of log query
24        request.setEndDateTime("2025-03-17T15:04:05Z");
25 // Set search statement
26        request.setQuery("match level:info");
27 // Execute log histogram analysis
28        QueryLogHistogramResponse response = client.queryLogHistogram(request);
29        System.out.println(response);
30    }
31}

Previous
Install the SDK Package
Next
iOS SDK