Sample data for query practice

Most of the examples for query commands and functions in this documentation use web server logs as sample data. Follow the steps below to import data for query practice and use it to learn query commands and functions.

Creating a table

Create a table named WEB_APACHE_SAMPLE under Settings > Tables.

  1. Navigate to Settings > Tables in the menu.
  2. Click the Add button.
  3. Enter WEB_APACHE_SAMPLE in the Name field.
  4. Click OK to create the table.

Loading sample data

  1. Navigate to Analysis > Queries in the menu.

  2. Run the following query to fetch sample data from the Logpresso GitHub dataset repository and load it into the WEB_APACHE_SAMPLE table.

    wget url="https://raw.githubusercontent.com/logpresso/dataset/refs/heads/main/access.log"
    | eval lines=split(line, "\n") | explode lines | eval line=lines | search line != ""
    | rex field=line "(?<src_ip>\S+) - - \[(?<_time>[^\]]+)\] \"(?<request>[^\"]*)\" (?<status>\d+) (?<bytes>\S+) \"(?<referer>[^\"]*)\" \"(?<agent>[^\"]*)\""
    | rex field=request "(?<method>\S+)(?: (?<uri>\S+) (?<protocol>\S+))?"
    | eval _time=date(_time, "dd/MMM/yyyy:HH:mm:ss Z", "en"), src_ip=ip(src_ip), status=int(status), bytes=int(bytes)
    | fields _time, src_ip, method, uri, protocol, status, bytes, referer, agent, line
    | import WEB_APACHE_SAMPLE
    

Verifying the loaded data

Verify that the data was loaded correctly. The imported data consists of 5,000 records.

table WEB_APACHE_SAMPLE