Skip to content

Instantly share code, notes, and snippets.

@kmuto
Created April 15, 2024 23:24
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 kmuto/8d8864fd8132314627aec2b9109befa2 to your computer and use it in GitHub Desktop.
Save kmuto/8d8864fd8132314627aec2b9109befa2 to your computer and use it in GitHub Desktop.
各サービスメトリック投稿の最終投稿日をまとめて調べる
#!/bin/bash
# Display of the last posting date of the service metric
# 2024 Kenshi Muto
services=$(mkr services -jq '.[]|.name')
echo "$services" | while read service; do
metrics=$(mkr metric-names -s $service -jq '.[]')
echo "$metrics" | while read metric; do
if [ -z "$metric" ]; then
continue
fi
epoch=$(mkr metrics -s $service -n $metric -jq 'last(.[])|.time')
if [ "$epoch" ]; then
if [ "$(uname)" = 'Darwin' ]; then
lastpostdate=$(date -r "$epoch" +'%Y-%m-%d')
else
lastpostdate=$(date --date "@$epoch" +'%Y-%m-%d')
fi
echo "$service : $metric : $lastpostdate"
else
echo "$service : $metric : NO METRIC FOUND!"
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment