0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Splunk:期間指定(earliest / latest)チートシート 全期間・24時間・7日・今日・昨日・任意日付|新人エンジニア向け

0
Posted at

Splunk の 期間指定(earliest / latest) は、
新人エンジニアが最初につまずくポイントのひとつです。
「全期間」「24時間」「7日」「1時間」「今日だけ」など、
よく使う期間指定を全部まとめて、コピペできるチートシートとして整理します。

SPL 文法の意味と“ふりがな(読み下し)”も付けて、
実務でそのまま使える形にしています。



🧭 基本ルール(最重要)

Splunk の期間指定は earliest(開始)latest(終了) の 2 つで決まる。

  • earliest=0 → 全期間
  • earliest=-24h → 24時間前から
  • earliest=-7d → 7日前から
  • latest=now → 現在まで
  • "YYYY-MM-DD" → 日付指定

ふりがな:earliest は「いつから」、latest は「いつまで」


📌 よく使う期間指定まとめ(コピペOK)


⏳ 全期間(最もよく使う)

index=hogehoge earliest=0

ふりがな:ぜんぶの期間を対象にする


⏳ 直近 24 時間

index=hogehoge earliest=-24h

ふりがな:24じかんまえから今まで


⏳ 直近 7 日間

index=hogehoge earliest=-7d

ふりがな:7にちまえから今まで


⏳ 直近 30 日間

index=hogehoge earliest=-30d

ふりがな:30にちまえから今まで


⏳ 今日(0:00 〜 今)

index=hogehoge earliest=@d

ふりがな:今日の0じから今まで


⏳ 昨日(0:00 〜 23:59)

index=hogehoge earliest=@d-1d latest=@d

ふりがな:きのうの0じからきのうの23:59まで


⏳ 今週(週の始まり〜今)

index=hogehoge earliest=@w

ふりがな:今週の月曜日から今まで


⏳ 今月(1日〜今)

index=hogehoge earliest=@mon

ふりがな:今月の1にちから今まで


⏳ 任意の日付範囲(例:2024/01/01〜2024/01/31)

index=hogehoge earliest="2024-01-01" latest="2024-01-31"

ふりがな:2024ねん1がつ1にちから1がつ31にちまで


⏳ 任意の日時(例:2024/01/01 10:00〜12:00)

index=hogehoge earliest="2024-01-01 10:00:00" latest="2024-01-01 12:00:00"

ふりがな:2024ねん1がつ1にち10じから12じまで


📌 期間指定+件数確認(実務でよく使う)


直近 24 時間の件数

index=hogehoge earliest=-24h | stats count

ふりがな:24じかんぶんのデータの件数を数える


昨日のデータ件数

index=hogehoge earliest=@d-1d latest=@d | stats count

ふりがな:きのうのデータの件数を数える


今月の product 別件数

index=hogehoge earliest=@mon | stats count by product

ふりがな:今月の product ごとの件数を数える


📌 期間指定+重複チェック(実務で必須)


直近 7 日間の timestamp 重複

index=hogehoge earliest=-7d
| stats count by _time
| where count > 1

ふりがな:7にちぶんの timestamp が重複していないか確認


直近 24 時間の完全重複(_raw)

index=hogehoge earliest=-24h
| stats count by _raw
| where count > 1

ふりがな:24じかんぶんのレコードが重複していないか確認


📌 期間指定+フィールド確認(実務でよく使う)


直近 24 時間のユニーク product

index=hogehoge earliest=-24h | dedup product

ふりがな:24じかんぶんの product の種類だけ確認


直近 7 日間のトップ10 product

index=hogehoge earliest=-7d | top limit=10 product

ふりがな:7にちぶんの product のトップ10


📌 期間指定の“文法まとめ”

記述 意味
earliest=0 全期間
earliest=-24h 24時間前から
earliest=-7d 7日前から
earliest=@d 今日の0時
earliest=@d-1d 昨日の0時
earliest=@w 今週の月曜
earliest=@mon 今月の1日
"YYYY-MM-DD" 日付指定
"YYYY-MM-DD HH:MM:SS" 日時指定

🧭 まとめ(新人向け)

  • earliest=いつから
  • latest=いつまで
  • @d / @w / @mon は“日付の切り上げ”
  • -24h / -7d は“相対時間”
  • 実務では 24h / 7d / 今月 / 全期間 をよく使う
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?