Skip to content

Instantly share code, notes, and snippets.

@anekos
Last active April 9, 2023 10:17
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 anekos/2344693c443abdf26f2b96f8ba411d08 to your computer and use it in GitHub Desktop.
Save anekos/2344693c443abdf26f2b96f8ba411d08 to your computer and use it in GitHub Desktop.
telegraf → TimescaleDB を Grafana に表示する
SELECT
host,
MAX(usage_user),
time_bucket('10min', time) AS bucket
FROM
telegraf.cpu
WHERE
(
to_timestamp($__unixEpochFrom()) -
(NOW() - NOW() AT TIME ZONE 'UTC')
) < time
AND
time <
(
to_timestamp($__unixEpochTo()) -
(NOW() - NOW() AT TIME ZONE 'UTC')
)
GROUP BY
host, bucket
HAVING
host = 'example.com'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment