Search code examples
stackdriver

Is there an API to limit the line of logs in stackdriver?


I need to get recent 100 lines from a stack driver log. Is there any API which can be used to implement this scenario in stackdriver? currently I'm using Google cloud Java client to implement the scenario.


Solution

  • You can use the CLI gcloud command and "limit" for this:

    gcloud logging read "resource.type=gce_instance AND logName=projects/my-gcp-project-id/logs/syslog AND textPayload:SyncAddress" --limit 10 --format json

    https://cloud.google.com/logging/docs/reference/tools/gcloud-logging#reading_log_entries