Functions

These functions are used on the metrics passed in the &target= URL parameters to change the data being graphed in some way.

alias(requestContext, seriesList, newName)

Takes one metric or a wildcard seriesList and a string in quotes. Prints the string instead of the metric name in the legend.

&target=alias(Sales.widgets.largeBlue,"Large Blue Widgets")
aliasByNode(requestContext, seriesList, *nodes)

Takes a seriesList and applies an alias derived from one or more “node” portion/s of the target name. Node indices are 0 indexed.

&target=aliasByNode(ganglia.*.cpu.load5,1)
aliasSub(requestContext, seriesList, search, replace)

Runs series names through a regex search/replace.

&target=aliasSub(ip.*TCP*,"^.*TCP(\d+)","\1")
alpha(requestContext, seriesList, alpha)

Assigns the given alpha transparency setting to the series. Takes a float value between 0 and 1.

areaBetween(requestContext, seriesList)

Draws the area in between the two series in seriesList

asPercent(requestContext, seriesList, total=None)

Calculates a percentage of the total of a wildcard series. If total is specified, each series will be calculated as a percentage of that total. If total is not specified, the sum of all points in the wildcard series will be used instead.

The total parameter may be a single series or a numeric value.

Example:

&target=asPercent(Server01.connections.{failed,succeeded}, Server01.connections.attempted)
&target=asPercent(apache01.threads.busy,1500)
&target=asPercent(Server01.cpu.*.jiffies)
averageAbove(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics with an average value above N for the time period specified.

Example:

&target=averageAbove(server*.instance*.threads.busy,25)

Draws the servers with average values above 25.

averageBelow(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics with an average value below N for the time period specified.

Example:

&target=averageBelow(server*.instance*.threads.busy,25)

Draws the servers with average values below 25.

averageSeries(requestContext, *seriesLists)

Short Alias: avg()

Takes one metric or a wildcard seriesList. Draws the average value of all metrics passed at each time.

Example:

&target=averageSeries(company.server.*.threads.busy)
averageSeriesWithWildcards(requestContext, seriesList, *position)

Call averageSeries after inserting wildcards at the given position(s).

Example:

&target=averageSeriesWithWildcards(host.cpu-[0-7].cpu-{user,system}.value, 1)

This would be the equivalent of target=averageSeries(host.*.cpu-user.value)&target=averageSeries(host.*.cpu-system.value)

cactiStyle(requestContext, seriesList)

Takes a series list and modifies the aliases to provide column aligned output with Current, Max, and Min values in the style of cacti. NOTE: column alignment only works with monospace fonts such as terminus.

&target=cactiStyle(ganglia.*.net.bytes_out)
color(requestContext, seriesList, theColor)

Assigns the given color to the seriesList

Example:

&target=color(collectd.hostname.cpu.0.user, 'green')
&target=color(collectd.hostname.cpu.0.system, 'ff0000')
&target=color(collectd.hostname.cpu.0.idle, 'gray')
&target=color(collectd.hostname.cpu.0.idle, '6464ffaa')
constantLine(requestContext, value)

Takes a float F.

Draws a horizontal line at value F across the graph.

Example:

&target=constantLine(123.456)
cumulative(requestContext, seriesList)

Takes one metric or a wildcard seriesList.

By default, when a graph is drawn, and the width of the graph in pixels is smaller than the number of datapoints to be graphed, Graphite averages the value at each pixel. The cumulative() function changes the consolidation function to sum from average. This is especially useful in sales graphs, where fractional values make no sense (How can you have half of a sale?)

&target=cumulative(Sales.widgets.largeBlue)
currentAbove(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics whose value is above N at the end of the time period specified.

Example:

&target=highestAbove(server*.instance*.threads.busy,50)

Draws the servers with more than 50 busy threads.

currentBelow(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics whose value is below N at the end of the time period specified.

Example:

&target=currentBelow(server*.instance*.threads.busy,3)

Draws the servers with less than 3 busy threads.

dashed(requestContext, *seriesList)

Takes one metric or a wildcard seriesList, followed by a float F.

Draw the selected metrics with a dotted line with segments of length F If omitted, the default length of the segments is 5.0

Example:

&target=dashed(server01.instance01.memory.free,2.5)
derivative(requestContext, seriesList)

This is the opposite of the integral function. This is useful for taking a running total metric and showing how many requests per minute were handled.

Example:

&target=derivative(company.server.application01.ifconfig.TXPackets)

Each time you run ifconfig, the RX and TXPackets are higher (assuming there is network traffic.) By applying the derivative function, you can get an idea of the packets per minute sent or received, even though you’re only recording the total.

diffSeries(requestContext, *seriesLists)

Can take two or more metrics, or a single metric and a constant. Subtracts parameters 2 through n from parameter 1.

Example:

&target=diffSeries(service.connections.total,service.connections.failed)
&target=diffSeries(service.connections.total,5)
divideSeries(requestContext, dividendSeriesList, divisorSeriesList)

Takes a dividend metric and a divisor metric and draws the division result. A constant may not be passed. To divide by a constant, use the scale() function (which is essentially a multiplication operation) and use the inverse of the dividend. (Division by 8 = multiplication by 1/8 or 0.125)

Example:

&target=divideSeries(Series.dividends,Series.divisors)
drawAsInfinite(requestContext, seriesList)

Takes one metric or a wildcard seriesList. If the value is zero, draw the line at 0. If the value is above zero, draw the line at infinity. If the value is null or less than zero, do not draw the line.

Useful for displaying on/off metrics, such as exit codes. (0 = success, anything else = failure.)

Example:

drawAsInfinite(Testing.script.exitCode)
events(requestContext, *tags)

Returns the number of events at this point in time. Usable with drawAsInfinite.

Example:

&target=events("tag-one", "tag-two")
&target=events("*")

Returns all events tagged as “tag-one” and “tag-two” and the second one returns all events.

exclude(requestContext, seriesList, pattern)

Takes a metric or a wildcard seriesList, followed by a regular expression in double quotes. Excludes metrics that match the regular expression.

Example:

&target=exclude(servers*.instance*.threads.busy,"server02")
groupByNode(requestContext, seriesList, nodeNum, callback)

Takes a serieslist and maps a callback to subgroups within as defined by a common node

&target=groupByNode(ganglia.by-function.*.*.cpu.load5,2,"sumSeries")

Would return multiple series which are each the result of applying the "sumSeries" function
to groups joined on the second node (0 indexed) resulting in a list of targets like
sumSeries(ganglia.by-function.server1.*.cpu.load5),sumSeries(ganglia.by-function.server2.*.cpu.load5),...
highestAverage(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the top N metrics with the highest average value for the time period specified.

Example:

&target=highestAverage(server*.instance*.threads.busy,5)

Draws the top 5 servers with the highest average value.

highestCurrent(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the N metrics with the highest value at the end of the time period specified.

Example:

&target=highestCurrent(server*.instance*.threads.busy,5)

Draws the 5 servers with the highest busy threads.

highestMax(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N.

Out of all metrics passed, draws only the N metrics with the highest maximum value in the time period specified.

Example:

&target=highestCurrent(server*.instance*.threads.busy,5)

Draws the top 5 servers who have had the most busy threads during the time period specified.

hitcount(requestContext, seriesList, intervalString)

Estimate hit counts from a list of time series.

This function assumes the values in each time series represent hits per second. It calculates hits per some larger interval such as per day or per hour. This function is like summarize(), except that it compensates automatically for different time scales (so that a similar graph results from using either fine-grained or coarse-grained records) and handles rarely-occurring events gracefully.

holtWintersAberration(requestContext, seriesList, delta=3)

Performs a Holt-Winters forecast using the series as input data and plots the positive or negative deviation of the series data from the forecast.

holtWintersConfidenceBands(requestContext, seriesList, delta=3)

Performs a Holt-Winters forecast using the series as input data and plots upper and lower bands with the predicted forecast deviations.

holtWintersForecast(requestContext, seriesList)

Performs a Holt-Winters forecast using the series as input data. Data from one week previous to the series is used to bootstrap the initial forecast.

integral(requestContext, seriesList)

This will show the sum over time, sort of like a continuous addition function. Useful for finding totals or trends in metrics that are collected per minute.

Example:

&target=integral(company.sales.perMinute)

This would start at zero on the left side of the graph, adding the sales each minute, and show the total sales for the time period selected at the right side, (time now, or the time specified by ‘&until=’).

keepLastValue(requestContext, seriesList)

Takes one metric or a wildcard seriesList. Continues the line with the last received value when gaps (‘None’ values) appear in your data, rather than breaking your line.

Example:

&target=keepLastValue(Server01.connections.handled)
legendValue(requestContext, seriesList, valueType)

Takes one metric or a wildcard seriesList and a string in quotes. Appends a value to the metric name in the legend. Currently one of: last, avg, total, min, max.

&target=legendValue(Sales.widgets.largeBlue, ‘avg’)

limit(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N.

Only draw the first N metrics. Useful when testing a wildcard in a metric.

Example:

&target=limit(server*.instance*.memory.free,5)

Draws only the first 5 instance’s memory free.

lineWidth(requestContext, seriesList, width)

Takes one metric or a wildcard seriesList, followed by a float F.

Draw the selected metrics with a line width of F, overriding the default value of 1, or the &lineWidth=X.X parameter.

Useful for highlighting a single metric out of many, or having multiple line widths in one graph.

Example:

&target=lineWidth(server01.instance01.memory.free,5)
logarithm(requestContext, seriesList, base=10)

Takes one metric or a wildcard seriesList, a base, and draws the y-axis in logarithmic format. If base is omitted, the function defaults to base 10.

Example:

&target=log(carbon.agents.hostname.avgUpdateTime,2)
lowestAverage(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the bottom N metrics with the lowest average value for the time period specified.

Example:

&target=lowestAverage(server*.instance*.threads.busy,5)

Draws the bottom 5 servers with the lowest average value.

lowestCurrent(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the N metrics with the lowest value at the end of the time period specified.

Example:

&target=lowestCurrent(server*.instance*.threads.busy,5)

Draws the 5 servers with the least busy threads right now.

maxSeries(requestContext, *seriesLists)

Takes one metric or a wildcard seriesList. For each datapoint from each metric passed in, pick the maximum value and graph it.

Example:

&target=maxSeries(Server*.connections.total)
maximumAbove(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by a constant n. Draws only the metrics with a maximum value above n.

Example:

&target=maximumAbove(system.interface.eth*.packetsSent,1000)

This would only display interfaces which sent more than 1000 packets/min.

maximumBelow(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by a constant n. Draws only the metrics with a maximum value below n.

Example:

&target=maximumBelow(system.interface.eth*.packetsSent,1000)

This would only display interfaces which sent less than 1000 packets/min.

minSeries(requestContext, *seriesLists)

Takes one metric or a wildcard seriesList. For each datapoint from each metric passed in, pick the minimum value and graph it.

Example:

&target=minSeries(Server*.connections.total)
minimumAbove(requestContext, seriesList, n)

Takes one metric or a wildcard seriesList followed by a constant n. Draws only the metrics with a minimum value above n.

Example:

&target=minimumAbove(system.interface.eth*.packetsSent,1000)

This would only display interfaces which sent more than 1000 packets/min.

mostDeviant(requestContext, n, seriesList)

Takes an integer N followed by one metric or a wildcard seriesList. Draws the N most deviant metrics. To find the deviant, the average across all metrics passed is determined, and then the average of each metric is compared to the overall average.

Example:
&target=mostDeviant(5, server*.instance*.memory.free)

Draws the 5 instances furthest from the average memory free.

movingAverage(requestContext, seriesList, windowSize)

Takes one metric or a wildcard seriesList followed by a number N of datapoints and graphs the average of N previous datapoints. N-1 datapoints are set to None at the beginning of the graph.

&target=movingAverage(Server.instance01.threads.busy,10)
movingMedian(requestContext, seriesList, windowSize)

Takes one metric or a wildcard seriesList followed by a number N of datapoints and graphs the median of N previous datapoints. N-1 datapoints are set to None at the beginning of the graph.

&target=movingMedian(Server.instance01.threads.busy,10)
multiplySeries(requestContext, *seriesLists)

Takes two or more series and multiplies their points. A constant may not be used. To multiply by a constant, use the scale() function.

Example:

&target=multiplySeries(Series.dividends,Series.divisors)
nPercentile(requestContext, seriesList, n)

Returns n-percent of each series in the seriesList.

nonNegativeDerivative(requestContext, seriesList, maxValue=None)

Same as the derivative function above, but ignores datapoints that trend down. Useful for counters that increase for a long time, then wrap or reset. (Such as if a network interface is destroyed and recreated by unloading and re-loading a kernel module, common with USB / WiFi cards.

Example:

&target=derivative(company.server.application01.ifconfig.TXPackets)
offset(requestContext, seriesList, factor)

Takes one metric or a wildcard seriesList followed by a constant, and adds the constant to each datapoint.

Example:

&target=offset(Server.instance01.threads.busy,10)
randomWalkFunction(requestContext, name)

Short Alias: randomWalk()

Returns a random walk starting at 0. This is great for testing when there is no real data in whisper.

Example:

&target=randomWalk("The.time.series")

This would create a series named “The.time.series” that contains points where x(t) == x(t-1)+random()-0.5, and x(0) == 0.

rangeOfSeries(requestContext, *seriesLists)

Takes a wildcard seriesList. Distills down a set of inputs into the range of the series

Example:

&target=rangeOfSeries(Server*.connections.total)
removeAbovePercentile(requestContext, seriesList, n)

Removes data above the nth percentile from the series or list of series provided. Values below this percentile are assigned a value of None.

removeAboveValue(requestContext, seriesList, n)

Removes data above the given threshold from the series or list of series provided. Values below this threshole are assigned a value of None

removeBelowPercentile(requestContext, seriesList, n)

Removes data above the nth percentile from the series or list of series provided. Values below this percentile are assigned a value of None.

removeBelowValue(requestContext, seriesList, n)

Removes data above the given threshold from the series or list of series provided. Values below this threshole are assigned a value of None

scale(requestContext, seriesList, factor)

Takes one metric or a wildcard seriesList followed by a constant, and multiplies the datapoint by the constant provided at each point.

Example:

&target=scale(Server.instance01.threads.busy,10)
&target=scale(Server.instance*.threads.busy,10)
secondYAxis(requestContext, seriesList)

Graph the series on the secondary Y axis.

sinFunction(requestContext, name, amplitude=1)

Short Alias: sin()

Just returns the sine of the current time. The optional amplitude parameter changes the amplitude of the wave.

Example:

&target=sin("The.time.series", 2)

This would create a series named “The.time.series” that contains sin(x)*2.

smartSummarize(requestContext, seriesList, intervalString, func='sum', alignToFrom=False)

Smarter experimental version of summarize.

The alignToFrom parameter has been deprecated, it no longer has any effect. Alignment happens automatically for days, hours, and minutes.

sortByMaxima(requestContext, seriesList)

Takes one metric or a wildcard seriesList.

Sorts the list of metrics by the maximum value across the time period specified. Useful with the &areaMode=all parameter, to keep the lowest value lines visible.

Example:

&target=sortByMaxima(server*.instance*.memory.free)
sortByMinima(requestContext, seriesList)

Takes one metric or a wildcard seriesList.

Sorts the list of metrics by the lowest value across the time period specified.

Example:

&target=sortByMinima(server*.instance*.memory.free)
stacked(requestContext, seriesLists)

Takes one metric or a wildcard seriesList and change them so they are stacked. This is a way of stacking just a couple of metrics without having to use the stacked area mode (that stacks everything). By means of this a mixed stacked and non stacked graph can be made

Example:

&target=stacked(company.server.application01.ifconfig.TXPackets)
stdev(requestContext, seriesList, points, windowTolerance=0.1)

Takes one metric or a wildcard seriesList followed by an integer N. Draw the Standard Deviation of all metrics passed for the past N datapoints. If the ratio of null points in the window is greater than windowTolerance, skip the calculation. The default for windowTolerance is 0.1 (up to 10% of points in the window can be missing). Note that if this is set to 0.0, it will cause large gaps in the output anywhere a single point is missing.

Example:

&target=stdev(server*.instance*.threads.busy,30)
&target=stdev(server*.instance*.cpu.system,30,0.0)
substr(requestContext, seriesList, start=0, stop=0)

Takes one metric or a wildcard seriesList followed by 1 or 2 integers. Assume that the metric name is a list or array, with each element separated by dots. Prints n - length elements of the array (if only one integer n is passed) or n - m elements of the array (if two integers n and m are passed). The list starts with element 0 and ends with element (length - 1).

Example:

&target=substr(carbon.agents.hostname.avgUpdateTime,2,4)

The label would be printed as “hostname.avgUpdateTime”.

sumSeries(requestContext, *seriesLists)

Short form: sum()

This will add metrics together and return the sum at each datapoint. (See integral for a sum over time)

Example:

&target=sum(company.server.application*.requestsHandled)

This would show the sum of all requests handled per minute (provided requestsHandled are collected once a minute). If metrics with different retention rates are combined, the coarsest metric is graphed, and the sum of the other metrics is averaged for the metrics with finer retention rates.

sumSeriesWithWildcards(requestContext, seriesList, *position)

Call sumSeries after inserting wildcards at the given position(s).

Example:

&target=sumSeriesWithWildcards(host.cpu-[0-7].cpu-{user,system}.value, 1)

This would be the equivalent of target=sumSeries(host.*.cpu-user.value)&target=sumSeries(host.*.cpu-system.value)

summarize(requestContext, seriesList, intervalString, func='sum', alignToFrom=False)

Summarize the data into interval buckets of a certain size.

By default, the contents of each interval bucket are summed together. This is useful for counters where each increment represents a discrete event and retrieving a “per X” value requires summing all the events in that interval.

Specifying ‘avg’ instead will return the mean for each bucket, which can be more useful when the value is a gauge that represents a certain value in time.

‘max’, ‘min’ or ‘last’ can also be specified.

By default, buckets are caculated by rounding to the nearest interval. This works well for intervals smaller than a day. For example, 22:32 will end up in the bucket 22:00-23:00 when the interval=1hour.

Passing alignToFrom=true will instead create buckets starting at the from time. In this case, the bucket for 22:32 depends on the from time. If from=6:30 then the 1hour bucket for 22:32 is 22:30-23:30.

Example:

&target=summarize(counter.errors, "1hour") # total errors per hour
&target=summarize(nonNegativeDerivative(gauge.num_users), "1week") # new users per week
&target=summarize(queue.size, "1hour", "avg") # average queue size per hour
&target=summarize(queue.size, "1hour", "max") # maximum queue size during each hour
&target=summarize(metric, "13week", "avg", true)&from=midnight+20100101 # 2010 Q1-4
threshold(requestContext, value, label=None, color=None)

Takes a float F, followed by a label (in double quotes) and a color. (See URL API for valid color names & formats.)

Draws a horizontal line at value F across the graph.

Example:

&target=threshold(123.456, "omgwtfbbq", red)
timeFunction(requestContext, name)

Short Alias: time()

Just returns the timestamp for each X value. T

Example:

&target=time("The.time.series")

This would create a series named “The.time.series” that contains in Y the same value (in seconds) as X.

timeShift(requestContext, seriesList, timeShift)

Takes one metric or a wildcard seriesList, followed by a length of time, surrounded by double quotes. (See the URL API for examples of time formats.)

Draw the selected metrics shifted back in time.

Useful for comparing a metric against itself.

Example:

&target=timeShift(Sales.widgets.largeBlue,"7d")

Project Versions

Previous topic

The URL API

Next topic

The Dashboard UI

This Page