Skip to content

Instantly share code, notes, and snippets.

@pavdmyt
Created September 29, 2020 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavdmyt/1194ec73d9d63c7c52da7b71f40488c2 to your computer and use it in GitHub Desktop.
Save pavdmyt/1194ec73d9d63c7c52da7b71f40488c2 to your computer and use it in GitHub Desktop.
Print Prometheus block's minTime and maxTime
#!/bin/bash
# Given a Prometheus block name, prints timerange
# for the metrics stored inside.
#
# Usage example:
# for b in `cat block_names.txt`; do ./get_block_time.sh $b; done
TIMEZONE="EEST"
BLOCK_DIR="/srv/prometheus_data/$1"
min_time="$(cat ${BLOCK_DIR}/meta.json | jq '.minTime')"
max_time="$(cat ${BLOCK_DIR}/meta.json | jq '.maxTime')"
echo "--- $1 ---"
echo ";;; Min time:"
TZ=$TIMEZONE date -d @"${min_time%???}"
echo ";;; Max time:"
TZ=$TIMEZONE date -d @"${max_time%???}"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment