Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active November 17, 2016 06:04
Show Gist options
  • Save tkuchiki/f19d9af126cb5061f4f7cc4185cd2eab to your computer and use it in GitHub Desktop.
Save tkuchiki/f19d9af126cb5061f4f7cc4185cd2eab to your computer and use it in GitHub Desktop.
json を mackerel plugin の出力形式に変換
$ cat /tmp/test.json
{
  "foo": 0,
  "bar": 100
}

$ cat /tmp/test.json | jq -r '. | to_entries | map("\(.key)\t\(.value)") | join("\n")'
foo     0
bar     100

$ cat /tmp/test.json | jq --arg epoch $(date +%s) -r '. | to_entries | map("\(.key)\t\(.value)\t\($epoch)") | join("\n")'
foo     0       1479362640
bar     100     1479362640
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment