8

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)
Alban Dericbourg
  • 1,616
  • 2
  • 16
  • 39

2 Answers2

22

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")
kwarunek
  • 12,141
  • 4
  • 43
  • 48
-1

You could just use alias() to rename it however you like.

obfuscurity
  • 150
  • 9
  • I cannot, because I have several series (multiple $Continent and multiple $DC). So using a hard-coded alias would hide the Continent and the DC. – Alban Dericbourg Jul 25 '16 at 13:28
  • 1
    Sorry, brain fart on my part. I was initially going to suggest `aliasSub` but I thought that was overkill lol. – obfuscurity Jul 26 '16 at 13:29