New Features
Data Connections
A new
Data Connection
document type makes data held outside Stroom into one more kind of
data source
Data source
A Data Connection has one of five types:
- JDBC - a database, queried with SQL given in each query. Stroom ships the MySQL and PostgreSQL drivers, and an administrator can add others.
- Amazon Athena - Amazon Athena, queried with SQL through the AWS SDK, with a limit on the data a query may scan.
- LDAP - an LDAP directory, such as OpenLDAP or Active Directory, searched with a filter given in each query.
- CSV and Excel - small lookup tables and reference lists held in the document itself, queried with StroomQL’s own clauses.
The SQL or filter goes in a new sql clause, straight after from, as a triple-quoted string that can span lines and hold quotes without escaping:
from "Reports DB"
sql """
select name, team, joined
from staff
where joined >= :from and joined < :to
"""
where team = "Platform"
select name, joined
Named placeholders such as :team take query parameters, and :from and :to take the query’s time range, without ever changing the SQL or filter itself.
Data Connections connect with credentials held in the Credentials store, which gains an AWS Access Key type for Amazon Athena.
A user needs Use permission on both the Data Connection and its credential to query it.
No JDBC, Athena or LDAP connection is allowed until an administrator allows it with the new dataConnection properties, see Upgrade Notes.
An example import pack, stroom-data-connection/DataConnection-Examples.zip in the Stroom repository, has JDBC, LDAP, CSV and Excel Data Connections with example queries.
Shared Index Volumes
An index volume can now be marked as Shared, which means that it is one mount that every node can see. The Lucene index shards on a shared volume do not belong to a node:
- Any node can search them, so a search no longer depends on the node that wrote a shard being up.
- Any node can write to them. A node takes a timed lease on a shard to write to it and gives the lease up when it closes the shard.
- If a node dies, its shards are taken from it after a grace period and other nodes carry on writing to them.
Existing index volumes are Local and behave as they did before.
Stroom also now records which streams have documents in an index shard that are not yet committed. If an indexing task fails part way through a stream, a shard fails to commit, or the writer of a shard stops without a final commit, the documents of the affected streams are removed from the index and the streams are indexed again. A stream is no longer left part indexed with its task marked as complete. This applies to shards on both shared and local volumes, and is done by the new job Index Shard Stream Recovery.
See Also
StroomQL Joins
StroomQl
StroomQl
from:
from "Windows events"
left join "HR Users" as hr on UserId = hr.Username
select UserId, hr.Department
The joined source is searched first and held, and the first source’s rows are joined as they arrive, so results still appear as the search runs. Any data source can be joined to any other, such as an index to a Data Connection, and either can be a bracketed query, such as a grouped summary.
There are six kinds of join:
join(orinner join) - one row per match.left join(orleft outer join) - also keeps the rows with no match.right join(orright outer join) - also keeps the joined source’s rows with no match.full join(orfull outer join) - also keeps the rows of either source with no match.semi join(orleft semi join) - each row with a match, once, adding no fields.anti join(orleft anti join) - each row with no match.
where exists, where not exists, where ... in (from ...) and where ... not in (from ...) are also accepted, as the SQL ways of writing semi and anti joins.
A join can also match events to events within a time window, e.g. a logon followed by a file export by the same user within 10 minutes:
from "Windows events" as logon
join "File events" as export
on logon.UserId = export.UserId
within 10m after logon.EventTime
select logon.UserId, logon.EventTime, export.FileName
Joins can be used in queries, in Embedded Query panels on dashboards, and in scheduled analytic rules and reports. A joined source can hold up to 1,000,000 rows or 256 MB, which administrators can change, see Upgrade Notes.
The Data Connection example pack has ten example join queries.
See Also
StroomQL Time Windows
The window clause of
StroomQl
StroomQl
from "File events"
window EventTime by 1d
group by UserId
having count() > lag(count(), 1) * 2
select windowStart() as Day, UserId, count() as Events
advancemakes windows that overlap, e.g.window EventTime by 1h advance 10mis a window of an hour that starts every 10 minutes.offsetmoves where windows start, e.g.window EventTime by 1d offset 6hmakes each day run from 06:00 to 06:00.- Windows of days, weeks, months and years follow the calendar in the time zone of the query.
- The new functions
windowStart()andwindowEnd()give the times of a row’s window. - The new functions
lag()andlead()give the value of an aggregate in an earlier or later window, so a window can be compared with another one. havingnow takes expressions, so the query above needs noeval.
Analytic rules judge a window only when it has all of its events.
A scheduled rule judges each window in the run whose time range holds the end of the window, and searches back before the range for the windows it reads with lag().
The periodN columns and the period() function that the old clause used have been removed, see Breaking Changes.