21

I want to filter metrics on tag value with a regex. I can do it in Prometheus but I could not find an equivalent way in Datadog.

For example, to select the following metric whose status tag value starts with 2, I can use the query http.server.requests.count{status=~"^2..$"}

I have the same metric with the same tags in Datadog too, but couldn't find a way to have the same query.

Muatik
  • 4,011
  • 10
  • 39
  • 72
  • At the moment, this does not seem supported. The best workaround would be to use the advanced query and set something like: `http.server.requests.count{status=200}+http.server.requests.count{status=201}+...` – XYZ123 Dec 03 '19 at 17:37
  • 1
    I think it is not a good option to list all possible combinations. since there isn't a good solution for it, I added another dimension to group HttpStatus like 2xx, 5xx on the application level. – Muatik Dec 03 '19 at 19:59
  • Does `status:[200 TO 299]` work? – Christopher Will Feb 12 '20 at 13:29
  • 1
    could you please point to any documentation about the [x To y] syntax? – Muatik Feb 13 '20 at 09:30
  • `status:[200 TO 299]` would only work in the APM and Log explorer but not for metrics – XYZ123 Sep 09 '20 at 10:04
  • @Muatik there it is: https://docs.datadoghq.com/logs/search_syntax/#numerical-values – Jezor Sep 29 '20 at 12:03

1 Answers1

4

Metrics queries now support wildcards.

Example 1: Getting all the requests with a status tag starting with 2: http.server.requests.count{status:2*}

Example 1: Getting all the requests with a service tag ending with mongo: http.server.requests.count{service:*mongo}

Example 3 (advanced): Getting all the requests with a service tag starting with blob and ending with postgres: http.server.requests.count{service:blob*,service:*postgres} (this will match service:blob-foo-postgres and service:blob_bar_postgres but not service:my_name_postgres)

XYZ123
  • 436
  • 2
  • 10
  • 6
    Best I can tell, there is still no way to filter on text in the middle. Its either a begins with or ends with filter ☹️ – Ryan Jul 08 '21 at 22:26