Berlin
Berlin

Reputation: 1464

Graphite and statsd - how to change graphe metric to 1 min

I have installed statsd with Graphite.

I wrote a sample that increases a counter (please see below).

I was expecting to see a line on 60 because I am increasing a counter every sec, however the line that I get is somewhat random, the range is between 14-29. below you can see a screenshot of the graph.

How can I change the Graph to show 60 per 1 min ?

contents of /etc/statsd/localConfig.js

{
  graphitePort: 2003
, graphiteHost: "localhost"
, port: 8125
, flushInterval: 60000
, graphite: {
    legacyNamespace: false
  }
}                             

contents of storage-schemas.conf

[statsd]
pattern = ^stats\.
retentions = 60s:90d

[carbon]
pattern = ^carbon\.
retentions = 60:90d

[default_1min_for_1day]
pattern = .*
retentions = 60s:14d 

contents of storage-aggregation.conf

[min]
pattern = \.min$
xFilesFactor = 0.1
aggregationMethod = min

[max]
pattern = \.max$
xFilesFactor = 0.1
aggregationMethod = max

[count]
pattern = \.count$
xFilesFactor = 0
aggregationMethod = sum

[lower]
pattern = \.lower(_\d+)?$
xFilesFactor = 0.1
aggregationMethod = min

[upper]
pattern = \.upper(_\d+)?$
xFilesFactor = 0.1
aggregationMethod = max

[sum]
pattern = \.sum$
xFilesFactor = 0
aggregationMethod = sum

[gauges]
pattern = ^.*\.gauges\..*
xFilesFactor = 0
aggregationMethod = last

[default_average]
pattern = .*
xFilesFactor = 0.5
aggregationMethod = average 

statsd send 60 metrics to graphite every minute.

require 'statsd-ruby'

$statsd = Statsd.new '23.23.82.106', 8125

loop do 
    $statsd.increment 'xxx'
    puts "sent at #{Time.now.strftime "%H:%M:%S"}"
    sleep 1
end

The Graph looks like this:

enter image description here

Upvotes: 2

Views: 2305

Answers (1)

dukebody
dukebody

Reputation: 7185

From statsd-graphite docs:

ensure your flush interval is at least as long as the highest-resolution retention

Otherwise Graphite will only record the last seen value. The default flush interval for statsd is 10 seconds, however in

[statsd]
pattern = ^stats\.
retentions = 60s:90d

You are setting the highest-resolution retention to 60 seconds. So your statsd flush interval is shorter than your Graphite highest- resolution retention.

To fix it simply use:

[statsd]
pattern = ^stats\.
retentions = 10s:60s:90d

You might have to resize your wsp files to match the new resolution configuration.

See this blog post (point 4) for a slightly longer explanation of the observed effect.

Upvotes: 1

Related Questions