Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.

Process Usage Reports

Hristo Iliev edited this page Aug 20, 2018 · 9 revisions

After you have obtained a Usage Summary Report, it is time to parse it.

This is a sample of a Usage Report:

{
  "organization_id": "d0b88119-c0c4-4e0c-a3f8-b32aeac83ec1",  
  "account_id": "1234",
  "start": 1526514540000,
  "end": 1526514599999,
  "processed": 1526514560785,
  "resources": [
  ],
  "spaces": [
  ]
}

The parameters have the following meanings:

  • start/end - range of the report
  • processed - time at which it was requested
  • organization_id- org id for which the report was requested
  • account_id - account id owning the organization
  • resources - resources breakdown
  • spaces - spaces breakdown

resources contains breakdown of all resources used in the organization and the plans for these resources.

Next step is to extract a specific metric. For example the "memory_in_16_gb_blocks" metric can be referred as follows:

  1. From resources find resource with resource_id = c118eae1-92ca-43f7-93a1-eaca74f898bf
  2. In plans find plan_id = standard/c118eae1-92ca-43f7-93a1-eaca74f898bf-c118eae1-92ca-43f7-93a1-eaca74f898bf/c118eae1-92ca-43f7-93a1-eaca74f898bf-c118eae1-92ca-43f7-93a1-eaca74f898bf/c118eae1-92ca-43f7-93a1-eaca74f898bf-c118eae1-92ca-43f7-93a1-eaca74f898bf
  3. Access aggregated_usage metric = memory_in_16_gb_blocks
  4. Open windows[4][0] – current month. Check time windows page for more info.
{
  "resource_id": "c118eae1-92ca-43f7-93a1-eaca74f898bf",
  "plans": [
    {
      "plan_id": "standard/c118eae1-92ca-43f7-93a1-eaca74f898bf-c118eae1-92ca-43f7-93a1-eaca74f898bf/c118eae1-92ca-43f7-93a1-eaca74f898bf-c118eae1-92ca-43f7-93a1-eaca74f898bf/c118eae1-92ca-43f7-93a1-eaca74f898bf-c118eae1-92ca-43f7-93a1-eaca74f898bf",
      "aggregated_usage": [
        {
          "metric": "memory_in_16_gb_blocks",
          "windows": <time-window structure>
        }
      ],
      "metering_plan_id": "c118eae1-92ca-43f7-93a1-eaca74f898bf-c118eae1-92ca-43f7-93a1-eaca74f898bf",
      "rating_plan_id": "c118eae1-92ca-43f7-93a1-eaca74f898bf-c118eae1-92ca-43f7-93a1-eaca74f898bf",
      "pricing_plan_id": "c118eae1-92ca-43f7-93a1-eaca74f898bf-c118eae1-92ca-43f7-93a1-eaca74f898bf",
      "windows": <time-window structure>
    }
  ],
  "aggregated_usage": [
    {
      "metric": "memory_in_16_gb_blocks",
      "windows": <time-window structure>
    }
  ],
  "windows": <time-window structure>
},
{
  "resource_id": "78eeb24c-610c-4585-b0c4-b18893e1972d",
  "plans": [
    {
      "plan_id": "standard/78eeb24c-610c-4585-b0c4-b18893e1972d-78eeb24c-610c-4585-b0c4-b18893e1972d/78eeb24c-610c-4585-b0c4-b18893e1972d-78eeb24c-610c-4585-b0c4-b18893e1972d/78eeb24c-610c-4585-b0c4-b18893e1972d-78eeb24c-610c-4585-b0c4-b18893e1972d",
      "aggregated_usage": [
        {
          "metric": "storage_gb",
          "windows": <time-window structure>

        }
      ],
      "metering_plan_id": "78eeb24c-610c-4585-b0c4-b18893e1972d-78eeb24c-610c-4585-b0c4-b18893e1972d",
      "rating_plan_id": "78eeb24c-610c-4585-b0c4-b18893e1972d-78eeb24c-610c-4585-b0c4-b18893e1972d",
      "pricing_plan_id": "78eeb24c-610c-4585-b0c4-b18893e1972d-78eeb24c-610c-4585-b0c4-b18893e1972d",
      "windows": <time-window structure>
    }
  ],
  "aggregated_usage": [
    {
      "metric": "storage_gb",
      "windows": <time-window structure>
    }
  ],
  "windows": <time-window structure>
}

❕ Using indexes to access resources or plans is not a good idea if you have multiple plans as adding or removing plans/metrics/usage might change the order.

Doing spaces breakdown is pretty similar:

"spaces": [
  {
    "space_id": "c8744fa5-e5c1-4341-8327-ef8dd79c5ecc",
    "resources": [
      {
        "resource_id": "413acde1-3d1f-47fc-8584-6e47a380c2d7",
        "plans": [
          {
            "plan_id": "standard/413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7/413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7/413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7",
            "aggregated_usage": [
              {
                "metric": "bandwidth_gb",
                "windows": <time-window structure>
              }
            ],
            "metering_plan_id": "413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7",
            "rating_plan_id": "413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7",
            "pricing_plan_id": "413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7",
            "windows": <time-window structure>
          }
        ],
        "aggregated_usage": [
          {
            "metric": "bandwidth_gb",
            "windows": <time-window structure>
          }
        ],
        "windows": <time-window structure>
      }
    ],
    "consumers": [
      {
        "consumer_id": "service:1234567a-5010-1234-abcd-567efg890hij",
        "resources": [
          {
            "resource_id": "413acde1-3d1f-47fc-8584-6e47a380c2d7",
            "plans": [
              {
                "plan_id": "standard/413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7/413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7/413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7",
                "aggregated_usage": [
                  {
                    "metric": "bandwidth_gb",
                    "windows": <time-window structure>
                  }
                ],
                "resource_instances": [
                  {
                    "id": "413acde1-3d1f-47fc-8584-6e47a380c2d7",
                    "t": "0001526511600000",
                    "p": 1526514556133
                  }
                ],
                "metering_plan_id": "413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7",
                "rating_plan_id": "413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7",
                "pricing_plan_id": "413acde1-3d1f-47fc-8584-6e47a380c2d7-413acde1-3d1f-47fc-8584-6e47a380c2d7",
                "windows": <time-window structure>
              }
            ],
            "aggregated_usage": [
              {
                "metric": "bandwidth_gb",
                "windows": <time-window structure>
              }
            ],
            "windows": <time-window structure>
          }
        ],
        "windows": <time-window structure>
      }
    ],
    "windows": <time-window structure>
  }
],

Note the resource_instances references under consumers:

"resource_instances": [
  {
    "id": "413acde1-3d1f-47fc-8584-6e47a380c2d7",
    "t": "0001526511600000",
    "p": 1526514556133
  }
],

The metadata inside can be used to call the resource instance report API.

<< Generate Usage Reports Deal With Network Issues >>

Clone this wiki locally