---
title: Regex patterns in Grafana datasource
slug: reference/regex-patterns-in-grafana-datasource
docTags: 
createdAt: 2025-09-09T09:49:45.148Z
---

## 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](https://regex101.com/r/GgKuCe/1) 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
