From 9f7763ee9f3ac68a65d659a2150496b1d5662f16 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 15 Jul 2014 16:20:11 -0400 Subject: [PATCH] Add options information and linkage for dashboard views --- .../api/dashboard_inventory_graph_view.md | 40 +++++++++++++++++++ .../api/dashboard_jobs_graph_view.md | 35 ++++++++++++++++ awx/api/templates/api/dashboard_view.md | 1 + awx/api/views.py | 6 ++- 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 awx/api/templates/api/dashboard_inventory_graph_view.md create mode 100644 awx/api/templates/api/dashboard_jobs_graph_view.md create mode 100644 awx/api/templates/api/dashboard_view.md diff --git a/awx/api/templates/api/dashboard_inventory_graph_view.md b/awx/api/templates/api/dashboard_inventory_graph_view.md new file mode 100644 index 0000000000..7353bf5006 --- /dev/null +++ b/awx/api/templates/api/dashboard_inventory_graph_view.md @@ -0,0 +1,40 @@ +Make a GET request to this resource to retrieve aggregate statistics about inventory suitable for graphing. + +Including fetching the number of total hosts tracked by Tower over an amount of time and the current success or +failed status of hosts which have run jobs within an Inventory. + +## Parmeters and Filtering + +The `period` of the data can be adjusted with: + + ?period=month + +Where `month` can be replaced with `week`, or `day`. `month` is the default. + +## Results + +Data about the number of hosts will be returned in the following format: + + "hosts": [ + [ + 1402808400.0, + 86743 + ], ...] + +Each element contains an epoch timestamp represented in seconds and a numerical value indicating +the number of hosts that exist at a given moment + +Data about failed and successfull hosts by inventory will be given as: + + { + "sources": [ + { + "successful": 21, + "source": "ec2", + "name": "aws (Test Inventory)", + "failed": 0 + } + ], + "id": 2, + "name": "Test Inventory" + }, diff --git a/awx/api/templates/api/dashboard_jobs_graph_view.md b/awx/api/templates/api/dashboard_jobs_graph_view.md new file mode 100644 index 0000000000..378508d1f5 --- /dev/null +++ b/awx/api/templates/api/dashboard_jobs_graph_view.md @@ -0,0 +1,35 @@ +Make a GET request to this resource to retrieve aggregate statistics about job runs suitable for graphing. + +## Parmeters and Filtering + +The `period` of the data can be adjusted with: + + ?period=month + +Where `month` can be replaced with `week`, or `day`. `month` is the default. + +The type of job can be filtered with: + + ?job_type=all + +Where `all` can be replaced with `inv_sync`, `playbook_run` or `scm_update`. `all` is the default. + +## Results + +Data will be returned in the following format: + + "jobs": { + "successful": [ + [ + 1402808400.0, + 9 + ], ... ], + "failed": [ + [ + 1402808400.0, + 3 + ], ... ] + } + +Each element contains an epoch timestamp represented in seconds and a numerical value indicating +the number of events during that time period diff --git a/awx/api/templates/api/dashboard_view.md b/awx/api/templates/api/dashboard_view.md new file mode 100644 index 0000000000..af9cb8ad5c --- /dev/null +++ b/awx/api/templates/api/dashboard_view.md @@ -0,0 +1 @@ +Make a GET request to this resource to retrieve aggregate statistics for Tower \ No newline at end of file diff --git a/awx/api/views.py b/awx/api/views.py index 50ca093cd0..1dfbc7ce9c 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -152,6 +152,8 @@ class DashboardView(APIView): def get(self, request, format=None): ''' Show Dashboard Details ''' data = SortedDict() + data['related'] = {'jobs_graph': reverse('api:dashboard_jobs_graph_view'), + 'inventory_graph': reverse('api:dashboard_inventory_graph_view')} user_inventory = get_user_queryset(request.user, Inventory) inventory_with_failed_hosts = user_inventory.filter(hosts_with_active_failures__gt=0) user_inventory_external = user_inventory.filter(has_inventory_sources=True) @@ -251,7 +253,7 @@ class DashboardView(APIView): class DashboardJobsGraphView(APIView): view_name = "Dashboard Jobs Graphs" - new_in_20 = True + new_in_200 = True def get(self, request, format=None): period = request.QUERY_PARAMS.get('period', 'month') @@ -300,7 +302,7 @@ class DashboardJobsGraphView(APIView): class DashboardInventoryGraphView(APIView): view_name = "Dashboard Inventory Graphs" - new_in_20 = True + new_in_200 = True def get(self, request, format=None): period = request.QUERY_PARAMS.get('period', 'month')