-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts: Added grpcurl script useful for Thanos debugging. (#2403)
Signed-off-by: Bartlomiej Plotka <[email protected]>
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
HELP=' | ||
insecure_grpcurl_series.sh allows you to use call StoreAPI.Series gRPC method and receive streamed series in JSON format. | ||
Usage: | ||
# Start some example Thanos component that exposes gRPC or use existing one. To start example one run: `thanos query &` | ||
bash scripts/insecure_grpcurl_series.sh localhost:10901 '"'"'[{"type": 0, "name": "__name__", "value":"go_goroutines"}]'"'"' 0 10 | ||
' | ||
|
||
STORE_API_HOSTPORT=$1 | ||
if [ -z "${STORE_API_HOSTPORT}" ]; then | ||
echo "\$1 is missing (STORE_API_HOSTPORT). Expected host:port string for the target StoreAPI to grpcurl against, e.g. localhost:10901" | ||
echo "${HELP}" | ||
exit 1 | ||
fi | ||
|
||
REQUESTED_MATCHERS=$2 | ||
if [ -z "${REQUESTED_MATCHERS}" ]; then | ||
echo '$2 is missing (REQUESTED_MATCHERS). Expected matchers in form of JSON matchers: e.g [{"type": 0, "name": "__name__", "value":"go_goroutines"}]' | ||
echo "${HELP}" | ||
exit 1 | ||
fi | ||
|
||
REQUESTED_MIN_TIME=$3 | ||
if [ -z "${REQUESTED_MIN_TIME}" ]; then | ||
echo '$3 is missing (REQUESTED_MIN_TIME). Expected min time in unix_timestamp.' | ||
echo "${HELP}" | ||
exit 1 | ||
fi | ||
|
||
REQUESTED_MAX_TIME=$4 | ||
if [ -z "${REQUESTED_MAX_TIME}" ]; then | ||
echo '$4 is missing (REQUESTED_MAX_TIME). Expected max time in unix_timestamp.' | ||
echo "${HELP}" | ||
exit 1 | ||
fi | ||
|
||
go install github.com/fullstorydev/grpcurl/cmd/grpcurl | ||
|
||
SERIES_REQUEST='{ | ||
"min_time": '${REQUESTED_MIN_TIME}', | ||
"max_time": '${REQUESTED_MAX_TIME}', | ||
"matchers": '${REQUESTED_MATCHERS}', | ||
"max_resolution_window": 0, | ||
"aggregates": [], | ||
"partial_response_strategy": 0, | ||
"skip_chunks": false | ||
}' | ||
|
||
GOGOPROTO_ROOT="$(GO111MODULE=on go list -f '{{ .Dir }}' -m github.com/gogo/protobuf)" | ||
|
||
pushd ${DIR}/../pkg/store/storepb/ | ||
grpcurl \ | ||
-import-path="${GOGOPROTO_ROOT}" \ | ||
-import-path=. \ | ||
-proto=rpc.proto \ | ||
-plaintext \ | ||
-d="${SERIES_REQUEST}" "${STORE_API_HOSTPORT}" thanos.Store/Series | ||
popd |