Queries

Queries

This page describes Open-AudIT version 7. Content for earlier versions is kept further down the page, under Pre version 7.

Queries

What is it?

A query is a saved report: a question against the database, kept, named and rerunnable. Which machines are missing a patch, which certificates expire soon, what was discovered this week. Open-AudIT ships with a large set covering the questions everybody asks, and when yours isn't among them, you write it once and it joins the menu.

You'll find them at menu > Settings > Queries, and the queries themselves appear under the Report menu, sorted into their categories.

What does it do?

It runs your question and shows the answer. A query is SQL against the Open-AudIT database, with results shown in the standard sortable, filterable table and exportable in the usual formats. Each query has a menu category, which decides where under the Report menu it appears, and the categories are extendable through Attributes.

The shipped set is the head start. Dozens of queries come ready to run, covering devices, software, changes, certificates, and more. The stock set is listed at menu > Settings > Queries > Default Queries, and stock queries are also the best templates when writing your own.

Custom queries follow two conventions. The columns you select should be fully qualified, devices.name rather than name, and the WHERE clause must contain WHERE @filter, which is where Open-AudIT applies org permissions, so a query never shows a user devices they aren't allowed to see. A query without it is rejected at creation. The FAQ page Creating a Query at menu > Help > FAQ walks through it properly.

Queries can arrive by email. Schedule one with a task, type Query, and the result lands in a chosen inbox on the schedule you set, attached in your chosen format with an HTML copy in the body. The Tasks page has the details.

Why?

Ask once, answer forever. The effort of working out how to ask a question is spent once, and the answer stays a click away, current every time it's run.

The whole database is askable. Devices, components, changes, custom fields, anything audits collect can be queried, joined and filtered, which is a longer reach than any fixed report set.

Reports find their audience. A scheduled query emailed to the right person monthly means the certificate expiry list, the new device list, the unseen machines list all arrive without anyone logging in.

How?

Run the shipped ones first. Browse the Report menu, run what's relevant, and check the question isn't already answered before writing anything.

Create your own at menu > Settings > Queries > Create Queries. Start from the SQL of the nearest default query, keep WHERE @filter, qualify your columns, name it plainly and pick its menu category. Test it from the list page and refine. There's also an import at menu > Settings > Queries > Import Queries for loading several at once.

The Create Queries form in version 7

The Create Queries form in version 7.

Schedule what people should see. For each query with a natural audience, create a task that emails it to them, having first set up email under menu > Admin > Configuration > Email Configuration.


Pre version 7. Everything below this line describes Open-AudIT before version 7. Menus, screens and behaviour may differ.

Pre version 7

Introduction

Open-AudIT comes with many queries inbuilt. If you require a specific query and none of the pre-packaged queries fit your needs, it's quite easy to create a new one and load it into Open-AudIT for running.

Join Mark Henry as he discusses how to create your own custom queries.

 

View Query Details

Go to menu:  Manage -> Queries -> List Queries.

You will see a list of queries. You can view the details of a query by clicking on the blue view button.

You can execute a query by clicking the green Execute button, the results will be displayed immediately.

You can also edit or delete any query. You delete the query by clicking the red trash can icon under the delete column as displayed in previous screen shots.

Creating a Query Entry

A query can be created using the web interface if a user has a role that contains the queries::create permission. Go to menu: Manage -> Queries -> Create Queries. There is also a "+" button on the List Queries page.

Details for creating custom queries can be found HERE: Creating a Query, If you need to create a Query that includes a custom Field you should look HERE: Create a Query containing Custom Fields  

Database Schema

The database schema can be found in the application is the user has database::read permission by going to menu: Admin -> Database -> List Tables, then clicking on the details button for the table.

 

API / Web Access

You can access the collection using the normal Open-AudIT JSON based API. Just like any other collection. Please see The Open-AudIT API documentation for further details.

 

 

Default Items

Shipped are a set of default items. These can be found by going to menu: Help → Defaults → Queries.