Search code examples
wildcardmetricsgraphitestatsd

Metrics filter in Graphite - ignore hierarchy (dots)


Is there any way to filter metrics in Graphite while ignoring the hierarchy?

For example: Say I have the following metrics:

stats_count.A.B.TestMetric 
stats_count.A.TestMetric
stats.A.B.TestMetric
stats.A.B.TestMetric

How can I sum TestMetric under stats_count only?

I tried the followings with no success:

stats_counts.*.*.TestMetric - obviously this won't work...
sumSeriesWithWildcards(stats_counts.[A-Z\.]*[A-Z]*.TestMetric,1)
sumSeriesWithWildcards(stats_counts.[A-Z]*[.]*[A-Z]*.TestMetric,1)

Any ideas? Is it possible at all?


Solution

  • I have a graphite installation (version 0.9.9) where I create metrics on a lot of small systems

    For example, I have 2 installations of a postgresql database (postgresql-1 and postgresql-2) where the second is a slave replication of the first. The first database is used for day to day use while the second is a hot standby used mostly by reporting systems and debugging queries

    I think the following example is somewhat what you want to do. The image is the amount of connections on both databases. The blue line is on the first, the green line is on the second while the red line is the sum of both series, giving the total amount of connections

    database.postgresql-1.connection.ALL.value              # blue line
    database.postgresql-2.connection.ALL.value              # green line
    sumSeries(database.postgresql-*.connection.ALL.value)   # red line
    

    amount of connections

    Your problem is that your series have different path levels (I tried to avoid that on my series names as indeed it causes problems). I dont see any other option than writing something like this:

    given

    stats_count.A.B.TestMetric 
    stats_count.A.TestMetric
    stats.A.B.TestMetric
    stats.A.B.TestMetric
    

    sum stats_count.**.TestMetric metrics using

    sumSeries(stats_count.*.TestMetric, stats_count.*.*.TestMetric)
    

    Graphite still needs a lot of improvement and unfortunately the development is going quite slowly (for instance version 0.9.10 is the latest release, has problems to install and is from 1 year ago). I am indeed considering forking/contributing to this project