百度智能云

All Product Document

          Log Service

          Obtain logrecord PullLogRecord

          Description

          View log records in a specified logstream, and retrieve recent log contents or filter by a specific time range.

          Request

          • Request syntax
          GET /v1/logstore/{logStoreName}/logrecord?project={project} HTTP/1.1
          Host: <Endpoint>
          Authorization: <Authorization String>
          • Request headers

          No additional headers are required beyond the standard request headers.

          • Request parameters
          Parameter name Types Required or not Parameter location Description
          project String No Query Project name
          logStoreName String Yes Path Logstore name
          logStreamName String Yes Query Logstream name
          startDateTime DateTime Yes Query Start datetime, including start time
          endDateTime DateTime Yes Query End datetime, excluding end time
          limit Int No Query Specify the maximum number of items to return; default: 100; maximum: 1000
          marker String No Query Specify the position token to view

          Notes:

          1. Both startDateTime and endDateTime here refer to the timestamp of logrecord
          2. All datetimes are in UTC ISO8601 format, for example: 2020-01-10T13:23:34Z

          Response

          • Response headers

          No additional headers are required beyond the standard response headers.

          • Response parameters
          Parameter name Types Description
          result List<LogRecord> A set of logrecords
          marker String Returned position token
          isTruncated Boolean true: indicate more data is available; false: indicate this is the last page
          nextMarker String The starting position for subsequent query, included in the request as a marker in the request to view the next page.

          The element structure of each logrecord in the result array in the above table is as follows:

          Field name Types Description
          message String Logrecord content; if the users uploads a TEXT log, it is the raw text content; otherwise, it is the json string composed of k-v pairs in the log
          timestamp Int Logrecord timestamp, accurate to millisecond

          Error code

          Apart from standard error codes, the following codes may be returned:

          Error code Error message Description HTTP status code
          InvalidParameter Request param invalid: [param] param invalid 400
          LogStoreStopped LogStore stopped LogStore write operations blocked due to debt 403
          LogStoreNotFound LogStore not found LogStore not found 404

          Example

          • Request example
          GET /v1/logstore/demo/logrecord?project=default&logStreamName=my-stream&marker=JpJYBIUoFqHA4wxXzeRGREbUVg&limit=500&startDateTime=2019-09-01T22:00:00Z&endDateTime=2019-09-10T22:00:00Z 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
          • Response example
          HTTP/1.1 200 OK
          Content-Type: application/json; charset=utf-8
          
          {
            "marker": "JpJYBIUoFqHA4wxXzeRGREbUVg",
            "isTruncated": true,
            "nextMarker": "dGhpcyBpcyBhbiBleGFtcGxl"
            "result": [
              {
                "message": "this is a raw message",
                "timestamp": 1542156107000
              }
            ]
          }
          Previous
          Push log PushLogRecord
          Next
          Histogram API QueryLogHistogram