Regex patterns in Grafana datasource
Introduction
With Regex patterns, you can efficiently retrieve data across multiple measurements simultaneously, enhancing the flexibility and ease of data retrieval within Grafana.
Example Regex patterns
regex101 can be used for trying out Regex patterns.
Note
Enter the pattern on its own, without wrapping it in /. The datasource adds those delimiters itself. Matching is unanchored, so a bare pattern such as motor_speed already matches any name that contains it. Adding .* at the start or the end is optional; use ^ or $ when you do want to anchor.
- .*motor_speed : Will return data points of measurements where the measurement name contains “motor_speed” in its name.
- ^motor_speed : Will return data points of measurements where the measurement name begins with “motor_speed”.
- motor_speed$ : Will return data points of measurements where the measurement name ends with “motor_speed”.
- ^first_.*_motor_speed$ : Will return data points of measurements where the measurement name starts with “first_” and ends with “_motor_speed”. .* is used for matching anything between the start and the end of the measurement name.
- Example: Captured measurement names can be:
- first_01_a_motor_speed
- first_02_b_motor_speed
- first_03_c_motor_speed
- ^sensor_\d+_temperature$ : Will return data points of measurements where the measurement name starts with “sensor_” followed by one or more numbers and ends with “_temperature”.
- Example: Captured measurement names can be:
- sensor_1_temperature
- sensor_25_temperature
- sensor_100_temperature
- .*device_\w+_status$ : Will return data points of measurements where “device_” is found, followed by word characters and ends with “_status”.
- Example: Captured measurement names can be:
- device_sensorA_status
- device_controller_status
- device_thermometer_status