Install with:
go get -u github.com/MacroPower/prometheus_video_renderer/cmd/prometheus_jukebox
Note that this requires several labels that describe playback behavior, and you need to make sure that the record and playback name
and start-time
are aligned (technically you could start playback anywhere in the track).
- Obtain a WAV file, e.g.
cantina.wav
- Mix to mono. (Stereo should be possible but I've not implemented it yet.)
- Downsample as needed, it should always work due to metadata in the labels.
- Run
prometheus_jukebox record
to generate metrics. (See below for usage.) - Loop over generated metrics and send them to
promtool tsdb create-blocks-from openmetrics
- Helper script here
- Run
docker compose up
- Proceed to playback if you so choose.
$ prometheus_jukebox record --help
Usage of record:
-file string
WAV file to source
-name string
Name of the track
-scrape-interval int
Frequency in seconds at which samples are written (default 1)
-start-time int
The starting timestamp (Unix MS) of the track
You can stream recorded audio directly from Prometheus. Samples are broken into small chunks that are queried consecutively. Playback is stopped when the metric is absent or when you manually stop the program.
$ prometheus_jukebox playback --help
Usage of playback:
-chunk-size duration
Amount of time to query at once (default 2h0m0s)
-name string
Name of the track
-prometheus-url string
Prometheus URL
-start-time int
The starting timestamp (Unix MS) of the track
You can also visualize the playback in Grafana, by using grafana-image-renderer-cli sequencer to create a timelapse of the waveform in Prometheus that matches with playback. You'll need to use a few specific arguments:
Where
space = total duration of the metric inside Prometheus in seconds
...
interval
isspace / ( (length of track in seconds) * (desired fps) )
.start-padding
should be a negative duration equal to the desired view size.end-padding
should beinterval * -1
.end-frame
isspace / interval
OR( space + (start padding in seconds) ) / interval
.
Example with 60s track, 30fps, start: 1420070400000, end: 1421393445495, 24h view:
$ grafana-image-renderer-cli sequence \
--api-url=http://localhost:3000 \
--api-key-or-basic-auth=admin:admin \
--dashboard=ZpUQVIg7k \
--start-time=1420070400000 \
--frame-interval=735s \
--start-padding=-24h \
--end-padding=-735s \
--frames=1-1800