Combine alias functions

Alban Dericbourg picture Alban Dericbourg · Jul 25, 2016 · Viewed 7.7k times · Source

Using Graphite, I'm plotting some graph and the same with a time shift.

Eg:

aliasByNode(my.application.metric.$Continent.$DC.*, 4, 5, 3)
aliasByNode(timeShift(my.application.metric.$Continent.$DC.*, "7d"), 4, 5, 3)

But I'd like to be able to identify the graphs (they currently get the same name).

How to add a prefix or a suffix (or any marker) to a metric alias?

Eg:

-- EU.PAR.pokemonCaught
-- EU.PAR.pokemonCaught (last week)

Answer

kwarunek picture kwarunek · Jul 25, 2016

Use regex with aliasSub to grab whole ( (.*) ) metric and change it - add desired text ( \1 last week ). E.g.

aliasByNode(timeShift(my.application.metric.$Continent.$DC.*, "7d"), 4, 5, 3)

should look like

aliasSub(aliasByNode(timeShift(my.application.metric.$Continent.$DC.*, "7d"), 4, 5, 3), "(.*)", "\1 last week")