— gcp, stackdriver, gcloud, logging, jq — 1 min read
You can easily get log lines from Stackdriver with the gcloud
CLI. Tack on jq
to count the lines for a quick way to get a sense of log volume.
In this example, we're counting lines ingested from a Kubernetes cluster, but you can query whatever types of lines you like, but watch out for the timestamp
! If you have a large volume of logs, this operation could take a long time.
1gcloud logging read 'resource.type=container AND2 resource.labels.cluster_name=my-cluster AND3 resource.labels.namespace_id=default AND4 logName=projects/my-project/logs/my-log-group AND5 textPayload:"your operation failed" AND6 timestamp>="2020-07-01T00:00:00Z"' --format=json | jq '. | length'