github.com/thanos-io/thanos@v0.32.5/scripts/insecure_grpcurl_series.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
     4  
     5  HELP='
     6  insecure_grpcurl_series.sh allows you to use call StoreAPI.Series gRPC method and receive streamed series in JSON format.
     7  
     8  Usage:
     9    # Start some example Thanos component that exposes gRPC or use existing one. To start example one run: `thanos query &`
    10    bash scripts/insecure_grpcurl_series.sh localhost:10901 '"'"'[{"type": 0, "name": "__name__", "value":"go_goroutines"}]'"'"' 0 10
    11  '
    12  
    13  STORE_API_HOSTPORT=$1
    14  if [ -z "${STORE_API_HOSTPORT}" ]; then
    15    echo '$1 is missing (STORE_API_HOSTPORT). Expected host:port string for the target StoreAPI to grpcurl against, e.g. localhost:10901'
    16    echo "${HELP}"
    17    exit 1
    18  fi
    19  
    20  REQUESTED_MATCHERS=$2
    21  if [ -z "${REQUESTED_MATCHERS}" ]; then
    22    echo '$2 is missing (REQUESTED_MATCHERS). Expected matchers in form of JSON matchers: e.g [{"type": 0, "name": "__name__", "value":"go_goroutines"}]'
    23    echo "${HELP}"
    24    exit 1
    25  fi
    26  
    27  REQUESTED_MIN_TIME=$3
    28  if [ -z "${REQUESTED_MIN_TIME}" ]; then
    29    echo '$3 is missing (REQUESTED_MIN_TIME). Expected min time in unix_timestamp.'
    30    echo "${HELP}"
    31    exit 1
    32  fi
    33  
    34  REQUESTED_MAX_TIME=$4
    35  if [ -z "${REQUESTED_MAX_TIME}" ]; then
    36    echo '$4 is missing (REQUESTED_MAX_TIME). Expected max time in unix_timestamp.'
    37    echo "${HELP}"
    38    exit 1
    39  fi
    40  
    41  go install github.com/fullstorydev/grpcurl/cmd/grpcurl@v1.8.2
    42  
    43  SERIES_REQUEST='{
    44    "min_time": '${REQUESTED_MIN_TIME}',
    45    "max_time": '${REQUESTED_MAX_TIME}',
    46    "matchers": '${REQUESTED_MATCHERS}',
    47    "max_resolution_window": 0,
    48    "aggregates": [],
    49    "partial_response_strategy": 0,
    50    "skip_chunks": false
    51  }'
    52  
    53  GOGOPROTO_ROOT="$(GO111MODULE=on go list -f '{{ .Dir }}' -m github.com/gogo/protobuf)"
    54  
    55  cd $DIR/../pkg/ || exit
    56  grpcurl \
    57    -import-path="${GOGOPROTO_ROOT}" \
    58    -import-path=. \
    59    -proto=store/storepb/rpc.proto \
    60    -plaintext \
    61    -d="${SERIES_REQUEST}" "${STORE_API_HOSTPORT}" thanos.Store/Series