Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-3867

Subscription_measurements missing data from contract_metrics

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • swatch-contracts
    • None
    • Swatch2 Sprint 1
    • Critical

      Some of the subscription_measurements are missing that are present in contract_metrics. This card is to figure out why they aren't showing up. Some of the metric_ids are incorrect in contract_metrics so is that the reason or some other reason.

      Query to see the mismatch:

      SELECT                                          
            cm.metric_id
        FROM contracts c
        JOIN contract_metrics cm
            ON c.uuid = cm.contract_uuid
        JOIN subscription s
            ON c.subscription_number = s.subscription_number
            AND c.start_date = s.start_date
        LEFT JOIN subscription_measurements sm
            ON s.subscription_id = sm.subscription_id
            AND s.start_date = sm.start_date
            AND (
                (sm.metric_id = 'Managed-nodes'       AND cm.metric_id = 'managed_node') OR
                (sm.metric_id = 'Instance-hours'      AND cm.metric_id = 'infrastructure') OR
                (sm.metric_id = 'Instance-hours'      AND cm.metric_id = 'control_plane') OR
                (sm.metric_id = 'Instance-hours'      AND cm.metric_id = 'cluster_hour') OR
                (sm.metric_id = 'vCPUs'               AND cm.metric_id = 'vcpu_hourly') OR
                (sm.metric_id = 'vCPUs'               AND cm.metric_id = 'vCPU_hours') OR
                (sm.metric_id = 'vCPUs'               AND cm.metric_id = 'acm_vcpu_hours') OR
                (sm.metric_id = 'Cores'               AND cm.metric_id = 'four_vcpu_hour') OR
                (sm.metric_id = 'Cores'               AND cm.metric_id = 'cluster_cpu_hour') OR
                (sm.metric_id = 'Cores'               AND cm.metric_id = 'vCPU_Hour') OR
                (sm.metric_id = 'Transfer-gibibytes'  AND cm.metric_id = 'transfer_gb') OR
                (sm.metric_id = cm.metric_id)
            )
        WHERE sm.subscription_id IS NULL group by cm.metric_id;
       

      Production Data analysis

      Checking Contracts and Subscriptions

      Contracts Total Contracts WITH EXISTING subscription Contracts WITHOUT EXISTING subscription
      10324 8936 1388

      Query:

      select count(*)
      from (
      select distinct subscription_number, start_date, product_id, vendor_product_code
      from contracts
      ) a
      left join subscription s on a.subscription_number = s.subscription_number and a.start_date = s.start_date 
      where s.subscription_id  is null;
      
      • Why there are so many contracts without an existing subscription?

      Checking Contract Metrics and Subscription Measurements

      Using all the contract metrics regardless whether the contract is using an existing subscription or not

      Contract Metric Contract Metrics WITH matching subscription measurement Contract Metrics WITHOUT matching subscription measurement
      1030 424 606

      Using only the contract metrics using an existing subscription

      Contract Metric Contract Metrics WITH matching subscription measurement Contract Metrics WITHOUT matching subscription measurement
      531 424 107

      The 107 metrics that do not match with any subscription measurements are:

      Metric product_id count
      Crisps unset 1
      Fromage_Francais unset 1
      managed_node unset 3
      MCT2735 unset 2
      MCT2735 rhel-for-x86-els-payg 1
      MCT2736 unset 1
      MCT2736 rhel-for-x86-els-payg 1
      MCT3822 rhel-for-x86-els-payg 1
      MCT3823 rhel-for-x86-els-payg 1
      MCT4135 unset 2
      MCT4136 unset 1
      MCT4545 unset 21
      MCT4545 rhel-for-x86-els-payg 1
      MW00584MO unset 14
      MW00585MO unset 7
      MW00586MO unset 5
      MW00587MO unset 1
      MW00588MO unset 9
      MW01621 rhel-for-x86-els-payg 1
      MW01622 rhel-for-x86-els-payg 1
      MW01659 unset 2
      MW02000 unset 1
      MW02000 rhel-for-x86-els-payg 1
      MW02006 unset 2
      MW02893 unset 1
      MW02894 unset 1
      premium_support rosa 9
      RH00003 rhel-for-x86-els-payg 1
      RH00004 unset 2
      RH00004 rhel-for-x86-els-payg 1
      RH00006 unset 2
      RH00007 unset 2
      RH00008 rhel-for-x86-els-payg 1
      RH00271 unset 2
      RH00763 rhel-for-x86-els-payg 1
      RH02986 unset 2
      rhaapservice_1000 unset 1
      • Why there are so many invalid/unsupported metrics?

      Reach out to @jcarvaja if you want to know more about the SQL queries I used to run this analysis.

      Acceptance Criteria

      • Investigate why there are so many invalid/unsupported metrics? - Done
      • Discuss next actions with the team plus technical lead. For example: create a JIRA ticket to write a migration script to get rid of all this wrong data?

              karshah@redhat.com Kartik Shah
              karshah@redhat.com Kartik Shah
              Eric Thompson Eric Thompson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: