AQL: the introduction

Aql is kind of a magic. It is a sort of SQL, but only for those, who are not afraid of challenges. Let me introduce you into this query language and spin your head a little.

We (and I say ‘we’ because it is nice to be a part of a group of genuinely talented and smart people for once) created AQL because exploration of data in asset maps is crucial for us. The query language, AQL, helps you find anything – does not matter if you are looking for a relationship or a presence of a specific asset – in the asset map. Also, the AQL will help you find what is hidden from you and you didn’t even know it existed.


And now a bit more on the technical part. AQL, Altworx query language, is defined in a step by step manner. The steps you take, or the moves you make throughout the asset map, can be either generators, which are included in the query results, or skips, which will skip them. Basically, if you are interested in the results, you use generator, if not (you only want to go ‘through’ the results, traverse them) you use skip. The results of a step is a starting point for a new step, only the very first step is unique because it defines the starting point from scratch.

“FROM ‘/assets/servers/*’” -> this is an example of the initial step. “FROM” is the keyword and it is followed by the ID mask, which contains the assets we want to return. If the ID mask contains “*” we want to return all the assets (in this case all servers). We can have there more than one ID mask, in that case they would be wrapped in “[ ]” brackets. Also, “SKIP” could have been used as a keyword (actually, not in this case, it does not make much sense because everything would be skipped and no results would be returned) and the results would have been used only as a starting point for the next query.

We can also choose what not to return using NOT. For example query “FROM NOT ‘/assets/users/*’” would never return any /assets/users/ as a result.

All the non initial steps can use other different keywords beside SKIP (FROM is used only for initial steps). “FROM ‘/assets/servers/*’ DIRECT FORWARD”. “DIRECT” here is the generating clause and “FORWARD” is the direction of the step – follows outgoing edges. “FROM ‘/assets/servers/*’ SKIP BACKWARD” where “SKIP” is the skipping clause step followed by direction of the step “BACKWARD”- follow edges back.

Shall we want to return attributes we need to use “SELECT” clause which lists all the attributes that are to be returned as a query result: “FROM ‘/assets/servers/*’ SELECT [“hardware”, “name”]”. “SELECT” is specific to every step hence it needs to be added to all the steps in the query for which we want to return and list the attributes. “SELECT” cannot be used with “SKIP” – it would not make sense, because a skip step does not produce any result.

There is so much more to AQL, for example we can filter assets according to their attributes using “WHERE” clause. With “WHERE” you can also use various operators such as =, <, >, <=, >=, !=, <>, IS, IS NOT and IN and some others. Also, you can filter results by relationship, specific point in time or time interval. But since this is just an introduction, we will tell you about those maybe next time.

Napsat komentář

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *

Tato stránka používá Akismet k omezení spamu. Podívejte se, jak vaše data z komentářů zpracováváme..