SELECT COUNT(*) functionality

Asked by James Abley

I am evaluating graphite for use as storing our metrics data about the application and am also wondering about certain business metrics as well.

The business would like to ask questions of the form "how often did event x happen over interval y", or essentially

SELECT COUNT(*) from events where eventType = :x and CREATEDDATE BETWEEN :start and :end

Is it possible to:

a) store that sort of data in graphite?
b) ask that sort of question about the data?

Cheers,

James

Question information

Language:
English Edit question
Status:
Answered
For:
Graphite Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Nicholas Leskiw (nleskiw) said :
#1

There are integral, nonNegativeDerivative and summarize functions.

integral adds all previous data points to the value.

so if the my.metric.data is 5,6,7,5,4,2,1,1,1,4,5
integral(my.metric.data) would graph
5,11,18,23,27,29,30,31,32,36,41

derivative(my.metric.data) is the opposite, turns
5,11,18,23,27,29,30,31,32,36,41
back into
5,6,7,5,4,2,1,1,1,4,5

summarize(metric,timePeriod) groups the datapoints into buckets.

for example, 5,6,7,5,4,2,1,1,1,4,5 (assuming each was 1 minute / datapoint)
summarize(my.metric.data,"2min")
would graph
11,12,6,2,5,5

Hope this helps.

Revision history for this message
Nicholas Leskiw (nleskiw) said :
#2

Also, you can use the rawData or format parameters to get the numerical data back out of graphite through HTTP calls.

Revision history for this message
Nicholas Leskiw (nleskiw) said :
#3

A more detailed example:

You need to get the # of sales per hour for the past 7 days and report it to business.

The metric is called "Acme.Clothing.Boots.RocketPowered"

Using a web browser, wget or curl, pull the following URL:

http://graphite.walgreens.com/render/?&target=summarize(Acme.Clothing.Boots.RocketPowered,"1h")&from=00%3A00_20110929&until=23%3A59_20110929&rawData=true

You'll get the following response:
summarize(Acme.Clothing.Boots.RocketPowered, "1h"),1317272400,1317362400,3600|19.0,12.0,13.0,17.0,19.0,12.0,13.0,17.0,19.0,12.0,13.0,17.0,19.0,12.0,13.0,17.0,19.0,12.0,13.0,17.0,19.0,12.0,13.0,17.0

Use your favorite CSV parser to get your data out.

Split on the pipe, and you

Can you help with this problem?

Provide an answer of your own, or ask James Abley for more information if necessary.

To post a message you must log in.