Skip to content

Instantly share code, notes, and snippets.

@welch
Created April 17, 2015 19:45
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 welch/b18d75bba184c441253c to your computer and use it in GitHub Desktop.
Save welch/b18d75bba184c441253c to your computer and use it in GitHub Desktop.
juttle demo sources
// simulated sources for demos and tests
//
// Exported subs:
// bumpy_cpu: a 10-minute cpu metric with daily variation
// ripple_cpu: a 10-second cpu metric with minute-variation
//
// Exported functions:
//
// Exported reducers:
//
////////////////////////////////////////////////////////////////////////
//
// bumpy_cpu:
// a 10-minute cpu metric with noise and daily periodicity but no trend
//
export sub bumpy_cpu(from, to) {
read -demo 'cdn' -nhosts 4 -dos .3 -dos_dur :15s: -daily 3
-from from -to to -every :10m: (host ~ 'sjc*' AND name = 'cpu')
| put cpu=*"value"
| keep cpu, time
}
//
// ripple_cpu:
// a 10-second cpu metric with noise and daily periodicity but no trend
//
export sub ripple_cpu(from, to) {
read -demo 'cdn' -nhosts 4
-ripple .5 -ripple_dur 60 -ripple_levels[-0.25, -0.25, 0, 0, 0, 0, 0.5]
-daily 0
-from from -to to -every :10s: (host ~ 'sjc*' AND name = 'cpu')
| put cpu=*"value"
| keep cpu, time
}
// example:
const start = :2014-01-01: ;
const dur = :1h: ;
bumpy_cpu -from :-2d: -to :now: | @timechart -title "2-day cpu variation"
;
ripple_cpu -from start -to start+dur
| @timechart -title "hourly cpu variation" -display.dataDensity 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment