forked from thanos-io/thanos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsecure_grpcurl_series.sh
executable file
·61 lines (50 loc) · 1.84 KB
/
insecure_grpcurl_series.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/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)"
cd $DIR/../pkg/ || exit
grpcurl \
-import-path="${GOGOPROTO_ROOT}" \
-import-path=. \
-proto=store/storepb/rpc.proto \
-plaintext \
-d="${SERIES_REQUEST}" "${STORE_API_HOSTPORT}" thanos.Store/Series