Skip to main content
Easily integrate your app with or . Use your favorite programming language to connect to your , create and manage hypertables, then ingest and query data.
  • Ruby
  • Python
  • Node.js
  • Go
  • Java

Prerequisites

To follow the steps on this page:
  • Create a target with time-series and analytics enabled.

    You need your connection details. This procedure also works for .

Connect a Rails app to your service

Every is a 100% database hosted in with extensions such as . You connect to your from a standard Rails app configured for .

Optimize time-series data in hypertables

Hypertables are tables designed to simplify and accelerate data analysis. Anything you can do with regular tables, you can do with hypertables - but much faster and more conveniently.In this section, you use the helpers in the gem to create and manage a hypertable.

Insert data your service

The gem provides efficient ways to insert data into hypertables. This section shows you how to ingest test data into your hypertable.

Reference

This section lists the most common tasks you might perform with the gem.

Query scopes

The gem provides several convenient scopes for querying your time-series data.
  • Built-in time-based scopes:
    PageLoad.last_hour.count
    PageLoad.today.count
    PageLoad.this_week.count
    PageLoad.this_month.count
    
  • Browser-specific scopes:
    # Count requests by browser
    PageLoad.chrome_users.last_hour.count
    PageLoad.firefox_users.last_hour.count
    PageLoad.safari_users.last_hour.count
    
    # Performance analysis
    PageLoad.slow_requests.last_hour.count
    PageLoad.fast_requests.last_hour.count
    
  • Query continuous aggregates: This query fetches the average and standard deviation from the performance stats for the /products path over the last day.
    # Access aggregated performance stats through generated classes
    PageLoad::PerformanceStatsPerMinute.last_hour
    PageLoad::PerformanceStatsPerHour.last_day
    PageLoad::PerformanceStatsPerDay.last_month
    
    # Get statistics for a specific path
    stats = PageLoad::PerformanceStatsPerHour.last_day.where(path: '/products').select("average(stats_agg) as average, stddev(stats_agg) as stddev").first
    puts "Average: #{stats.average}"
    puts "Standard Deviation: #{stats.stddev}"
    

features

The gem provides utility methods to access hypertable and chunk information. Every model that uses the acts_as_hypertable method has access to these methods.

Access hypertable and chunk information

  • View chunk or hypertable information:
    PageLoad.chunks.count
    PageLoad.hypertable.detailed_size
    
  • Compress/Decompress chunks:
    PageLoad.chunks.uncompressed.first.compress!  # Compress the first uncompressed chunk
    PageLoad.chunks.compressed.first.decompress!  # Decompress the oldest chunk
    PageLoad.hypertable.compression_stats # View compression stats
    
    

Access hypertable stats

You collect hypertable stats using methods that provide insights into your hypertable’s structure, size, and compression status:
  • Get basic hypertable information:
    hypertable = PageLoad.hypertable
    hypertable.hypertable_name  # The name of your hypertable
    hypertable.schema_name      # The schema where the hypertable is located
    
  • Get detailed size information:
    hypertable.detailed_size # Get detailed size information for the hypertable
    hypertable.compression_stats # Get compression statistics
    hypertable.chunks_detailed_size # Get chunk information
    hypertable.approximate_row_count # Get approximate row count
    hypertable.dimensions.map(&:column_name) # Get dimension information
    hypertable.continuous_aggregates.map(&:view_name) # Get continuous aggregate view names
    

Continuous aggregates

The continuous_aggregates method generates a class for each continuous aggregate.
  • Get all the continuous aggregate classes:
    PageLoad.descendants # Get all continuous aggregate classes
    
  • Manually refresh a continuous aggregate:
    PageLoad.refresh_aggregates
    
  • Create or drop a continuous aggregate: Create or drop all the continuous aggregates in the proper order to build them hierarchically. See more about how it works in this blog post.
    PageLoad.create_continuous_aggregates
    PageLoad.drop_continuous_aggregates
    

Next steps

Now that you have integrated the ruby gem into your app:
You are not limited to these languages. is based on , you can interface with and using any client driver.