Search code examples
regexgraphite

graphite storage-schemas match a pattern with two wildcard segments


I am creating metrics which have the following pattern:

MyApp.<environment>.<hostname>.DB.some_metric

The metric must start with "MyApp" and the third segment should be "DB". How do I specify a pattern with two wildcarded segments?

I've tried

MyApp\.*\.*\.DB\.

and

MyApp\.*\.DB\.

but neither are matching. The creates log is showing that new metrics are being matched to the default schema.

I have other applications with different retention policies that also have a "DB" segment so a pattern like \.DB\. would not be specific enough.


Solution

  • I was able to get this to work with the following pattern:

    pattern = ^MyApp\..*\.DB\.
    

    The extra period helped match any string between the two segments of known values.