Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Overview

Instead of using the Devo interface, queries can also be directly written using LINQ language.

LINQ is the query language used by Devo to query data tables. LINQ syntax is very flexible as it allows to make a query expression very close to the data discovery process by:

  1. selecting the source data table (using from)

  2. filtering data (using where)

  3. creating new columns (using select and optionally as...)

  4. grouping the data by a time value (using group every and every)

  5. applying aggregation operations over the grouped data (using select... as...)

    from <table name>
    group every <server period> by <column1>, <column2>
    every <browser period>
    select <aggregation operation 1>(<column>) as <NewColumnName1>,
    <aggregation operation 2>(<column>) as <NewColumnName2>,

For example, the following is a LINQ query where we want to retrieve only those events with status code 404 grouped every 10 minutes, displaying the method and clientIpAddress columns. Additionally, we have created the myCount column to count the records in each interval. For more examples using different operations, see the LINQ query examples section.

from demo.ecommerce.data
where statusCode = 404
group every 10m by method, clientIpAddress
every 10m
select count() as myCount

Sometimes you may have to create a column. The syntax would be:

select <create column operation 1> as <NewColumnName1>,
create <column operation 2> as <NewColumnName2>,

There are two different ways of accessing the query editor, where you can write your LINQ query:

In Data Search → Explore Your Data → Free Text Query. Learn more about this option here.

After accessing a data table, you can build and edit the query by selecting the Query code editor icon in the query toolbar and clicking Run.

Filter data using LINQ

These are the necessary clauses you need to add to your LINQ query in order to perform a filtering operation:

from <table name> 
where <filter1>,
<filter2>
...

For example, the following query performs a filter to get only those events where the number of bytes sent is greater than 800:

from demo.ecommerce.data 
where bytesTransferred > 800

And this one returns the events where the client IP address is not null and the bytes transferred are less than 1000:

from demo.ecommerce.data 
where isnotnull(clientIpAddress),
   bytesTransferred < 1000

Learn how to build queries using the search window interface, as well as the details about client and server periods in the following article: Filter data.

Group data using LINQ

These are the necessary clauses you need to add to your LINQ query in order to group data:

Time-based

group every <server period> by <column1>, <column2>
every <client period>

Non-time-based

group every - by <column1>, <column2>
group by <column1>, <column2>

Adding two different grouping periods might look like an unnecessary complexity, but it brings many advantages, such as the optimization of the query response. The server period is smaller than the client period, so the information is sent from the server in smaller chunks. This allows you to apply other grouping periods from the browser without having to query the server again. An every 0 is also allowed in the case you don’t want any grouping period.

For example, the following query groups data by IP address and status code every 3 hours (client period). The server period has been set to 30 minutes to optimize performance.

from demo.ecommerce.data 
group every 30m by clientIpAddress, statusCode
every 3h

Learn how to build queries using the search window interface, as well as the details about client and server periods in the following article: Group data.

Aggregate data using LINQ

These are the necessary clauses you need to add to your LINQ query in order to perform an aggregation operation. You must always group the data before aggregating data. 

from  <table name>
group every <server period> by <column1>, <column2>
every <client period>
select  <aggregation operation 1>(<column>) as <NewColumnName1>,
<aggregation operation 2>(<column>) as <NewColumnName2>,
...

For example, this query returns the average of bytes transferred every 5 minutes for each status code.

from demo.ecommerce.data 
group every 5m by statusCode 
every 5m select 
avg(bytesTransferred) as AvgOfBytes

And this one returns the first non-null client IP address every 3 hours for each method.

from demo.ecommerce.data 
group every 30m by method 
every 3h 
select nnfirst(clientIpAddress) as FirstNonNullIP

Learn how to build queries using the search window interface, as well as the details about client and server periods in the following article: Aggregate data.

Create new columns using LINQ

These are the necessary clauses you need to add to your LINQ query in order to perform a create column operation. You must always include the select operator followed by the operation name and column.

Optionally, you can add an as operator if you want to choose the name of the new column. In case you don't add an as operator, the name of the new column will be the operation(column).

from <table name>
 select  <aggregation operation 1>(<column>) as <NewColumnName1>,
  <aggregation operation 2>(<column>) as <NewColumnName2>,
...

For example, the following query creates two columns showing the corresponding latitude and longitude values of the IPs in the ClientIpAddress column of the table.

from demo.ecommerce.data
 select mmlatitude(clientIpAddress),
  mmlongitude(clientIpAddress)

And this one displays the definitions of the status codes in a new column.

from demo.ecommerce.data 
select decode(statusCode, 200, "Successful Login", 400, "Bad/Invalid Request", 401, "Invalid Password/Username") as StatusCodeMessages

Learn how to build queries using the search window interface, as well as the details about client and server periods in the following article: Create columns.

  • No labels