spanner-query-stats-collector
Google Cloud Spanner's query stats collector.
Usage
See releases that can be easy to use collect your query stats.
Or you can use go get
command.
go get github.com/sters/spanner-query-stats-collector
This application is cmd/collector/main.go use envconfig for stats writer. Default as 1 miniute query stats to stdout with JSON format.
{"level":"info","ts":1581839172.210752,"caller":"stats/writer.go:22","msg":"","IntervalEnd":1581839100,"Text":"SELECT 1","TextTruncated":false,"TextFingerprint":0,"ExecutionCount":78,"AvgLatencySeconds":0.0005415128205128205,"AvgRows":1,"AvgBytes":8,"AvgRowsScanned":0,"AvgCPUSeconds":0.00002253846153846154}
With Docker
Simple example with your local credential.
Use this sters/spanner-query-stats-collector - Docker Hub
docker run \
--rm
-e PROJECT_ID="xxxxx" \
-e INSTANCE_ID="xxxxx" \
-e DATABASE_ID="xxxxx" \
-e CREDENTIAL_FILE="/etc/google/application_default_credentials.json" \
-v ~/.config/gcloud/:/etc/google/:ro \
sters/spanner-query-stats-collector:latest
Customize to your application
You can find example at cmd/collector/main.go.
This package support only SPANNER_SYS.QUERY_STATS_TOP_*
Tables, from This document.