百度智能云

All Product Document

          Log Service

          PushLogRecord

          Description

          It supports batch push of log records to the BLS platform. The format of log records can be TEXT or JSON format. If it is TEXT, the log will not be parsed; if it is in JSON format, JSON fields can be automatically discovered (only the first-level field discovery is supported, and the automatic discovery of nested type fields is not currently supported).

          Request

          • Request syntax
          POST /v1/logstore/{logStoreName}/logrecord HTTP/1.1 
          Host: <Endpoint> 
          Authorization: <Authorization String> 
          Content-Type: application/json; charset=utf-8 
           
          { 
            "logStreamName": <logStreamName>, 
            "type": <type>, 
            "logRecords": [ 
              { 
                "message": <message>, 
                "timestamp": <timestamp> 
              } 
            ] 
          } 
          • Request header

          Except for the public request header, there are no other special headers.

          • Request parameter
          Parameter name Type Required or not Parameter location Description
          logStoreName String Yes Path Log set name
          logStreamName String Yes RequestBody Name of the log stream. The length cannot exceed 128 characters. The characters included are limited to: a-z, A-Z, 0-9, '_', '-', '.'
          type String No RequestBody Data type, JSON/TEXT, default is TEXT
          logRecords List<LogRecord> Yes RequestBody Log records

          The structure of each LogRecord element in the logRecords array in the above table is as follows:

          Field name Type Description
          message String What the log records
          timestamp Int Timestamp of the log record, accurate to the millisecond

          Response

          • Response header

          Except for the public response header, there are no other special headers.

          • Response parameter

          None

          Error Code

          In addition to general error codes, the following error codes may also appear.

          Error code Error message Description HTTP status code
          LogStoreNotFound LogStore [logStoreName] not exists LogStore does not exist 404
          TooNewLogRecord Check out the logRecord that occurred in the future time at position [offset] A new LogRecord existed in the requested batch 400

          Note: The [offset] part of the error message will be replaced with a specific location.

          Example

          • Request example
          POST /v1/logstore/demo/logrecord HTTP/1.1 
          Host: bls-log.bj.baidubce.com 
          Authorization: bce-auth-v1/18717522d39411e9b721df098b0b908c/2019-09-10T07:00:20Z/1800/content-type;host;x-bce-date;x-bce-request-id/6a7cb6c9ac7ec156c805e55e7d0bcfc443b47feee97cf099c1c0d93a0b4c8304 
          Content-Type: application/json; charset=utf-8 
           
          { 
            "logStreamName": "my-stream", 
            "type": "TEXT", 
            "logRecords": [ 
              { 
                "message": "this is a log record", 
                "timestamp": 1453209131020 
              } 
            ] 
          } 
          • Response example
          HTTP/1.1 200
          Content-Type: application/json; charset=utf-8 
          X-Bce-Request-Id: 2eeba101-4cc7-4cfe-b5ac-a3be8d060e33
          Date: Fri, 10 Apr 2020 04:42:37 GMT 
          Previous
          LogStream Related Interface
          Next
          PullLogRecord