Created
April 15, 2024 23:24
-
-
Save kmuto/8d8864fd8132314627aec2b9109befa2 to your computer and use it in GitHub Desktop.
各サービスメトリック投稿の最終投稿日をまとめて調べる
This file contains hidden or 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
#!/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
MACKEREL_APIKEY=〜 ./last-service-post.sh
のように実行すると、そのオーガニゼーションのサービスメトリック投稿最終日がわかる