This is in response to sparse / irregular time series on the mailing list.

Question is: How is OpenTSDB aggregating time series?

Here's what the underlying data looks like:
underlying data

Let's zoom in on the first few data points:
underlying data, first few data points

Now let's look at what aggregation by average would produce:
aggregation by average

As we can see, the aggregated time series has one data point for each data
point of the underlying time series.  The algorithm can be summarized as
follows (Python-style pseudo code):

  def combine(sequence_of_timeseries_iterators):
    # returns an iterator that returns data points from all iterators passed
    # in argument, sorted by time.

  timeseries = combine([iter(ts1), iter(ts2), ..., iter(tsN)])
  for datapoint in timeseries:
    values = [datapoint.value()]  # This is the value to aggregate
    for ts in [ts1, ts2, ..., tsN]:  # Loop on other time series
      if datapoint is not ts.current():
        values.append(ts.current())  # Current value obtained by LERP
    yield aggregation_function(values)


Raw data used in the example graphs above:

$ ./build/tsdb scan --import 2012/01/01 sum duration_seconds
duration_seconds 1325578226 761 content_guid=ab1ced2f-4bfb-4005-b8c5-1313a409d5b9
duration_seconds 1325584390 46 content_guid=11187bfe-f237-4ecc-880b-9945d4157aee
duration_seconds 1325587679 351 content_guid=ab1ced2f-4bfb-4005-b8c5-1313a409d5b9
duration_seconds 1325586186 665 content_guid=9a21610c-c678-4959-b9e0-5254f8843955
duration_seconds 1325587690 672 content_guid=b2929ceb-173e-4a8c-b838-6923cc40e56a
duration_seconds 1325589289 759 content_guid=9a21610c-c678-4959-b9e0-5254f8843955
duration_seconds 1325590314 0 content_guid=9a21610c-c678-4959-b9e0-5254f8843955
duration_seconds 1325591723 651 content_guid=efdf7592-a719-4324-a607-08c228b8c535
duration_seconds 1325595312 642 content_guid=11187bfe-f237-4ecc-880b-9945d4157aee
duration_seconds 1325596812 661 content_guid=9a21610c-c678-4959-b9e0-5254f8843955
duration_seconds 1325596621 789 content_guid=efdf7592-a719-4324-a607-08c228b8c535
duration_seconds 1325596948 532 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325601053 825 content_guid=9a21610c-c678-4959-b9e0-5254f8843955
duration_seconds 1325601173 726 content_guid=44c24bc0-fa22-4917-b75d-d6769b93c8d1
duration_seconds 1325602382 768 content_guid=44c24bc0-fa22-4917-b75d-d6769b93c8d1
duration_seconds 1325604949 89 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325607358 640 content_guid=2ba2e130-f42d-4b32-981f-45c17ef05b8e
duration_seconds 1325624028 710 content_guid=9a21610c-c678-4959-b9e0-5254f8843955
duration_seconds 1325623864 1357 content_guid=668047de-cc2c-4a29-b96c-3b0bd32ab0a0
duration_seconds 1325637469 3356 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325643104 637 content_guid=9a21610c-c678-4959-b9e0-5254f8843955
duration_seconds 1325656784 657 content_guid=b2929ceb-173e-4a8c-b838-6923cc40e56a
duration_seconds 1325653558 652 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325661977 665 content_guid=11187bfe-f237-4ecc-880b-9945d4157aee
duration_seconds 1325672318 1024 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325671995 773 content_guid=44c24bc0-fa22-4917-b75d-d6769b93c8d1
duration_seconds 1325674297 762 content_guid=44c24bc0-fa22-4917-b75d-d6769b93c8d1
duration_seconds 1325675073 642 content_guid=b2929ceb-173e-4a8c-b838-6923cc40e56a
duration_seconds 1325677123 670 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325678892 663 content_guid=b2929ceb-173e-4a8c-b838-6923cc40e56a
duration_seconds 1325679777 1739 content_guid=b2929ceb-173e-4a8c-b838-6923cc40e56a
duration_seconds 1325679497 784 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325679696 728 content_guid=44c24bc0-fa22-4917-b75d-d6769b93c8d1
duration_seconds 1325682451 793 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325684242 695 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325687055 705 content_guid=ab1ced2f-4bfb-4005-b8c5-1313a409d5b9
duration_seconds 1325686502 666 content_guid=11187bfe-f237-4ecc-880b-9945d4157aee
duration_seconds 1325686433 664 content_guid=9a21610c-c678-4959-b9e0-5254f8843955
duration_seconds 1325686749 1081 content_guid=9a21610c-c678-4959-b9e0-5254f8843955
duration_seconds 1325685731 727 content_guid=44c24bc0-fa22-4917-b75d-d6769b93c8d1
duration_seconds 1325688959 739 content_guid=44c24bc0-fa22-4917-b75d-d6769b93c8d1
duration_seconds 1325689173 746 content_guid=44c24bc0-fa22-4917-b75d-d6769b93c8d1
duration_seconds 1325691424 681 content_guid=efdf7592-a719-4324-a607-08c228b8c535
duration_seconds 1325692886 276 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325740648 711 content_guid=11187bfe-f237-4ecc-880b-9945d4157aee
duration_seconds 1325775274 711 content_guid=11187bfe-f237-4ecc-880b-9945d4157aee
duration_seconds 1325773976 708 content_guid=efdf7592-a719-4324-a607-08c228b8c535
duration_seconds 1325774982 707 content_guid=44c24bc0-fa22-4917-b75d-d6769b93c8d1
duration_seconds 1325828919 662 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325834940 651 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2
duration_seconds 1325835346 690 content_guid=0f7d255e-9302-40a6-8fae-503acf0959d2