graphite-project / carbon

Carbon is one of the components of Graphite, and is responsible for receiving metrics over the network and writing them down to disk using a storage backend.
http://graphite.readthedocs.org/
Apache License 2.0
1.5k stars 490 forks source link

Sum does not work in carbon #838

Closed Mahabharata871 closed 5 years ago

Mahabharata871 commented 5 years ago

storage-aggregation.conf

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

storage-schemas.conf [test1] pattern = ^test1* retentions = 10s:10m,1m:1h,10m:1d

I send to carbon ten (10) events with metric equal to one (1), in a row: echo "test1.nginx.TEST.sum. 1date +%s" |nc -q0 127.0.0.1 2003;

,but in graphite I see only 1 metric equal to one: screenshot from 2019-02-01 10-58-44

What am I doing wrong?

P.S. The counting method does not give results either.

piotr1212 commented 5 years ago

have you sent the metrics with a 10s interval?

Mahabharata871 commented 5 years ago

No, I send the same metrics, in the amount of 10 pieces in a row, within 1-2 seconds and I want to see in the graph, at the same time, how many events I sent in total.

piotr1212 commented 5 years ago

Graphite is a fixed interval timeseries database. You configured your smallest interval to 10s, then you have to send a metric every 10 seconds, sending more often just overwrites the values. If you want to send events in with a flexible interval you will need to use some aggregator, for example statsd.

The storage aggregation specifies how to aqgregate between retentions, that is from your 10s:10m interval to your 1m:1h interval and from the 1m:1h interval to your 10m:1d interval.

Mahabharata871 commented 5 years ago

In this case, how should the sum, counting, etc. functions work?

piotr1212 commented 5 years ago

I'm not sure if I understand your question.

piotr1212 commented 5 years ago

Also note that regexes are case sensitive: pattern = ^test1* will not match test1.nginx.TEST.sum. I'm not really sure how the trailing . in your metricname will be processed, just remove it to not be ambiguous.

Mahabharata871 commented 5 years ago

Graphite is a fixed interval timeseries database. You configured your smallest interval to 10s, then you have to send a metric every 10 seconds, sending more often just overwrites the values. If you want to send events in with a flexible interval you will need to use some aggregator, for example statsd.

Then I am absolutely confused. I set up a working bundle of riemann + carbon + graphite and sent a stream of metrics there, similar to those I quoted above - one at a time. And the graph is drawn: screenshot from 2019-02-01 14-21-24

deniszh commented 5 years ago

@Mahabharata871 : if you sending metrics with less interval then your schema, then all these metrics will be treated as belong to same bucket, i.e. previous will be overwritten by later. If you need one-second resolution - create 1s archive in your schema. But if you will send metrics more othen then 1 per second - they will be ignored too.

piotr1212 commented 5 years ago

Which part of my comment confuses you? What are you trying to achieve? Will you be sending aggregated metrics in fixed intervals or will you be sending "events" with a variable interval? Maybe the docs can explain it more clear than I can, see https://graphite.readthedocs.io/en/latest/feeding-carbon.html#step-2-configure-your-data-retention and https://graphite.readthedocs.io/en/latest/whisper.html

Mahabharata871 commented 5 years ago

I apologize, I do not speak English, so I translate online and because of this, the meaning of what is written may be lost :(

Let me explain: I have a high-loaded server - a balancer nginx. With it, I send statistics on requests through Riemann to graphite and I need to see how many requests each minute arrive at the server. I thought that if I sent metrics with a unit to graphite, I would be able to aggregate them with the means of graphite or carbon.

Thank you for your patience.

piotr1212 commented 5 years ago

Ok, I'll try again.

Graphite expects to receive metrics on fixed intervals, that means you have to submit a metric exactly ever x seconds. In your example config you have to send exactly one metric every 10 seconds.

So instead of: 12:01:01 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003; 12:01:01 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003; 12:01:03 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003; 12:01:04 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003; 12:01:06 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003; 12:01:06 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003; 12:01:06 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003; 12:01:12 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003; 12:01:18 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003; 12:01:20 > echo "test1.nginx.TEST.sum 1 date +%s" |nc -q0 127.0.0.1 2003;

you have to send: 12:01:10 > echo "test1.nginx.TEST.sum 7 date +%s" |nc -q0 127.0.0.1 2003; 12:01:20 > echo "test1.nginx.TEST.sum 3 date +%s" |nc -q0 127.0.0.1 2003;

You will have to configure Riemann to sends an aggregated value (that means sum, of all values in a specific timeperiod) once every 10 seconds. I don't know how to do this, I'm not experienced with Riemann.

I hope this makes things clear.

Mahabharata871 commented 5 years ago

But this is stupid. It turns out that I have to read the events on the server side, from which they are sent, instead of just making the function of counting metrics :)

Mahabharata871 commented 5 years ago

Anyway, thank you so much!

deniszh commented 5 years ago

But this is stupid. It turns out that I have to read the events on the server side, from which they are sent, instead of just making the function of counting metrics :)

No, you don't. Just configure your collector to send metric every 10 seconds, all graphite collectors can to that. Riemann can do that too.

DanCech commented 5 years ago

The issue here is that carbon aggregator is designed to aggregate metrics across multiple series, not to aggregate multiple readings within the same interval for a given series.

The use-case where you want to receive multiple values for a single series within the same interval and sum them together is best served by statsd, which is designed to be able to take multiple inputs at random intervals and turn them into a fixed-interval stream for graphite.