Inserting records for nth percentile calculations

This example procedure inserts records into the reporting database and is for demonstration purposes only. For this example, assume that two data centers are already defined, Austin and Bangalore. The metrics on which to filter are called analytics_test1 and analytics_test2.
  1. Log in to the Analytics reporting database as the root user or a user with administrative permissions.
    mysql -u root reporting
  2. Enter the following command at the prompt, substituting values that apply to your company's situation:
    insert into nth_percentile_config
       (name, description, percentile, period)
    values
       ('percentile_test_1', 'first percentile test', 90, 10),
       ('percentile_test_2', 'second percentile test', 80, 20);
    
    insert into nth_percentile_business_hours_assoc
       (nth_percentile_config_id, business_hours_config_id)
    values
       (
          (select id from nth_percentile_config where percentile = 90 and period = 10),
          (select id from business_hours_config where name='austin')
       ),
       (
          (select id from nth_percentile_config where percentile = 80 and period = 20),
          (select id from business_hours_config where name='bangalore')
       );
    
    insert into nth_percentile_group_assoc
       (nth_percentile_config_id, group_filter_id)
    values
       (
          (select id from nth_percentile_config where percentile = 90 and period = 10),
          (select id from group_filter where name='austin')
       ),
       (
          (select id from nth_percentile_config where percentile = 80 and period = 20),
          (select id from group_filter where name='bangalore')
       );
    
    insert into nth_percentile_metric_assoc
       (nth_percentile_config_id, metric_key)
    values
       (
          (select id from nth_percentile_config where percentile = 90 and period = 10),
          (select metric_key from meta_metric where metric_name='analytics_test1')
       ),
       (
          (select id from nth_percentile_config where percentile = 90 and period = 10),
          (select metric_key from meta_metric where metric_name='analytics_test2')
       ),
       (
          (select id from nth_percentile_config where percentile = 80 and period = 20),
          (select metric_key from meta_metric where metric_name='analytics_test1')
       ),
       (
          (select id from nth_percentile_config where percentile = 80 and period = 20),
          (select metric_key from meta_metric where metric_name='analytics_test2')
       );