A Prometheus exporter that captures MIDI events from electronic drum kits and exports hit velocity metrics to Prometheus Pushgateway for monitoring and analysis.
- Real-time MIDI event capture from electronic drum kits
- Prometheus histogram metrics for hit velocities
- Configurable drum element mapping (snare, hi-hat, toms, cymbals, etc.)
- Support for drum variations (rim shots, edge hits, bell hits, etc.)
- Interactive configuration generator
- Periodic metric push to Prometheus Pushgateway
- Go 1.19 or higher
- A MIDI-compatible electronic drum kit
- Prometheus Pushgateway instance
- MIDI driver support (rtmidi)
macOS:
brew install pkg-configLinux:
# Debian/Ubuntu
sudo apt-get install libasound2-dev
# Fedora/RHEL
sudo dnf install alsa-lib-develgo install github.com/hpdobrica/edrums-exporter@latestOr build from source:
git clone https://github.com/hpdobrica/edrums-prometheus-exporter
cd edrums-prometheus-exporter
go build -o edrums-exporter ./cmdRun the configuration generator to create your config.yaml:
./edrums-exporter configureThe configuration wizard will guide you through:
- MIDI Port Selection: Choose from available MIDI input ports
- Prometheus Settings: Configure Pushgateway URL and push interval
- Drum Mapping: Hit each drum element to map MIDI notes to drum components
The generated config.yaml has the following structure:
prometheus:
push_gateway_url: http://localhost:9091
push_interval_sec: 5
midi_port: "Your MIDI Device Name"
drum_map:
C2:
- Bass
- Regular
D2:
- Snare
- Regular
D#2:
- Snare
- Rim Shot
# ... additional mappingsEach MIDI note maps to a drum element and variation:
Supported Elements:
- Bass
- Snare
- Hi-hat
- Tom 1/2/3
- Ride
- Crash 1/2
Supported Variations:
- Regular
- Rim Click
- Rim Shot
- Edge
- Bell
- Top
- Foot (hi-hat)
./edrums-exporterThe exporter will:
- Connect to the configured MIDI port
- Start listening for MIDI note events
- Push metrics to Prometheus Pushgateway at the configured interval
To update your configuration:
./edrums-exporter configureThe wizard will load existing settings as defaults, allowing you to keep or change each value.
A histogram metric tracking the distribution of hit velocities (0-127) for each drum element.
Labels:
note: MIDI note name (e.g., "C2", "D2")element: Drum component (e.g., "Snare", "Hi-hat")variation: Hit type (e.g., "Regular", "Rim Shot")channel: MIDI channel number
Example:
edrum_hit_velocity{note="D2",element="Snare",variation="Regular",channel="0"} 85
edrum_hit_velocity{note="D#2",element="Snare",variation="Rim Shot",channel="0"} 102
docker run -d -p 9091:9091 prom/pushgatewayAdd to your prometheus.yml:
scrape_configs:
- job_name: 'pushgateway'
honor_labels: true
static_configs:
- targets: ['localhost:9091']In adition to below queries, you can check out the grafana dashboard stored in grafana-dashboard.yaml.
avg by (element) (edrum_hit_velocity)
sum by (element, variation) (edrum_hit_velocity_count)
histogram_quantile(0.95, sum by (le, element) (edrum_hit_velocity_bucket))
Check available MIDI devices:
# macOS
ls /dev/cu.*
# Linux
aconnect -lEnsure your drum kit is powered on and connected before running the exporter.
Verify Pushgateway is running:
curl http://localhost:9091/metricsCheck the push_gateway_url in your config.yaml.
If a drum hit isn't detected during configuration:
- Check that the drum module is in the correct MIDI mode
- Verify MIDI channel settings match your configuration
.
├── cmd/
│ └── main.go # Main application entry point
├── pkg/
│ ├── config/
│ │ └── main.go # Configuration loading
│ └── configmaker/
│ ├── generator.go # Interactive config generator
│ └── portfinder.go # MIDI port detection
└── config.yaml # Generated configuration file
go build -o edrums-exporter ./cmdgithub.com/prometheus/client_golang- Prometheus client librarygitlab.com/gomidi/midi/v2- MIDI handlinggithub.com/cqroot/prompt- Interactive CLI promptsgopkg.in/yaml.v3- YAML configuration
MIT