Bacalhau Docs
GithubSlackBlogEnterprise
v1.6.x
  • Documentation
  • Use Cases
  • CLI & API
  • References
  • Community
v1.6.x
  • Welcome
  • Getting Started
    • How Bacalhau Works
    • Getting Started
      • Step 1: Install the Bacalhau CLI
      • Step 2: Running Your Own Job
      • Step 3: Checking on the Status of Your Job
    • Creating Your Own Bacalhau Network
      • Setting Up a Cluster on Amazon Web Services (AWS) with Terraform πŸš€
      • Setting Up a Cluster on Google Cloud Platform (GCP) With Terraform πŸš€
      • Setting Up a Cluster on Azure with Terraform πŸš€
    • Hardware Setup
    • Container Onboarding
      • Docker Workloads
      • WebAssembly (Wasm) Workloads
  • Setting Up
    • Running Nodes
      • Node Onboarding
      • GPU Installation
      • Job selection policy
      • Access Management
      • Node persistence
      • Configuring Your Input Sources
      • Configuring Transport Level Security
      • Limits and Timeouts
      • Test Network Locally
      • Bacalhau WebUI
      • Private IPFS Network Setup
    • Workload Onboarding
      • Container
        • Docker Workload Onboarding
        • WebAssembly (Wasm) Workloads
        • Bacalhau Docker Image
        • How To Work With Custom Containers in Bacalhau
      • Python
        • Building and Running Custom Python Container
        • Running Pandas on Bacalhau
        • Running a Python Script
        • Running Jupyter Notebooks on Bacalhau
        • Scripting Bacalhau with Python
      • R (language)
        • Building and Running your Custom R Containers on Bacalhau
        • Running a Simple R Script on Bacalhau
      • Run CUDA programs on Bacalhau
      • Running a Prolog Script
      • Reading Data from Multiple S3 Buckets using Bacalhau
      • Running Rust programs as WebAssembly (WASM)
      • Generate Synthetic Data using Sparkov Data Generation technique
    • Networking Instructions
      • Accessing the Internet from Jobs
      • Utilizing NATS.io within Bacalhau
    • GPU Workloads Setup
    • Automatic Update Checking
    • Marketplace Deployments
      • Google Cloud Marketplace
    • Inter-Nodes TLS
  • Guides
    • Configuration Management
    • Write a config.yaml
    • Write a SpecConfig
    • Using Labels and Constraints
  • Examples
    • Table of Contents for Bacalhau Examples
    • Data Engineering
      • Using Bacalhau with DuckDB
      • Ethereum Blockchain Analysis with Ethereum-ETL and Bacalhau
      • Convert CSV To Parquet Or Avro
      • Simple Image Processing
      • Oceanography - Data Conversion
      • Video Processing
      • Bacalhau and BigQuery
    • Data Ingestion
      • Copy Data from URL to Public Storage
      • Pinning Data
      • Running a Job over S3 data
    • Model Inference
      • EasyOCR (Optical Character Recognition) on Bacalhau
      • Running Inference on Dolly 2.0 Model with Hugging Face
      • Speech Recognition using Whisper
      • Stable Diffusion on a GPU
      • Stable Diffusion on a CPU
      • Object Detection with YOLOv5 on Bacalhau
      • Generate Realistic Images using StyleGAN3 and Bacalhau
      • Stable Diffusion Checkpoint Inference
      • Running Inference on a Model stored on S3
    • Model Training
      • Training Pytorch Model with Bacalhau
      • Training Tensorflow Model
      • Stable Diffusion Dreambooth (Finetuning)
    • Molecular Dynamics
      • Running BIDS Apps on Bacalhau
      • Coresets On Bacalhau
      • Genomics Data Generation
      • Gromacs for Analysis
      • Molecular Simulation with OpenMM and Bacalhau
    • Systems Engineering
      • Ad-hoc log query using DuckDB
  • References
    • Jobs Guide
      • Job Specification
        • Job Types
        • Task Specification
          • Engines
            • Docker Engine Specification
            • WebAssembly (WASM) Engine Specification
          • Publishers
            • IPFS Publisher Specification
            • Local Publisher Specification
            • S3 Publisher Specification
          • Sources
            • IPFS Source Specification
            • Local Source Specification
            • S3 Source Specification
            • URL Source Specification
          • Network Specification
          • Input Source Specification
          • Resources Specification
          • ResultPath Specification
        • Constraint Specification
        • Labels Specification
        • Meta Specification
      • Job Templates
      • Queuing & Timeouts
        • Job Queuing
        • Timeouts Specification
      • Job Results
        • State
    • CLI Guide
      • Single CLI commands
        • Agent
          • Agent Overview
          • Agent Alive
          • Agent Node
          • Agent Version
        • Config
          • Config Overview
          • Config Auto-Resources
          • Config Default
          • Config List
          • Config Set
        • Job
          • Job Overview
          • Job Describe
          • Job Executions
          • Job History
          • Job List
          • Job Logs
          • Job Run
          • Job Stop
        • Node
          • Node Overview
          • Node Approve
          • Node Delete
          • Node List
          • Node Describe
          • Node Reject
      • Command Migration
    • API Guide
      • Bacalhau API overview
      • Best Practices
      • Agent Endpoint
      • Orchestrator Endpoint
      • Migration API
    • Node Management
    • Authentication & Authorization
    • Database Integration
    • Debugging
      • Debugging Failed Jobs
      • Debugging Locally
    • Running Locally In Devstack
    • Setting up Dev Environment
  • Help & FAQ
    • Bacalhau FAQs
    • Glossary
    • Release Notes
      • v1.5.0 Release Notes
      • v1.4.0 Release Notes
  • Integrations
    • Apache Airflow Provider for Bacalhau
    • Lilypad
    • Bacalhau Python SDK
    • Observability for WebAssembly Workloads
  • Community
    • Social Media
    • Style Guide
    • Ways to Contribute
Powered by GitBook
LogoLogo

Use Cases

  • Distributed ETL
  • Edge ML
  • Distributed Data Warehousing
  • Fleet Management

About Us

  • Who we are
  • What we value

News & Blog

  • Blog

Get Support

  • Request Enterprise Solutions

Expanso (2025). All Rights Reserved.

On this page
  • Remote Log Analysis using DuckDB and Bacalhau
  • Overview
  • Prerequisites
  • 1. Run a DuckDB job on Bacalhau
  • 3. Declarative Job Description
  • 4. Checking the State of Your Jobs
  • 5. Viewing Your Job Output
  • 6. Running Arbitrary SQL Commands
  • 7. Declarative Job Description for Arbitrary SQL
  • 8. Checking Job Status, Describing, Downloading Results
  • Need Support?

Was this helpful?

Export as PDF
  1. Examples
  2. Systems Engineering

Ad-hoc log query using DuckDB

Remote Log Analysis using DuckDB and Bacalhau

This guide provides an overview of using DuckDB with Bacalhau for remote log analysis. By leveraging these tools, you can perform detailed analyses without the need to download datasets locally.

Overview

DuckDB is a powerful in-memory SQL database management system ideal for data analytics. Bacalhau facilitates decentralized job execution, meaning you can run jobs remotely without having to log in or build complicated services. Together, they make a powerful tool for remote, ad-hoc server interaction.

Prerequisites

  • You will need a Bacalhau cluster with the following configuration:

NameProvider: "uuid"
Compute:
  Enabled: true
  Orchestrators:
    - nats://<YOUR_ORCHESTRATOR_IP_HERE>:4222
  Auth:
    Token: YOUR_TOKEN
  TLS:
    RequireTLS: true
  AllowListedLocalPaths:
    - /var/log/logs_to_process:rw
JobAdmissionControl:
  AcceptNetworkedJobs: true

1. Run a DuckDB job on Bacalhau

To run a DuckDB job on Bacalhau, all you need to do is use the DuckDB container. To submit a job, run the following command:

bacalhau docker run \
  davidgasquez/datadex:v0.2.0 \
  -- duckdb -s "select 1")

Structure of the Command

  1. bacalhau docker run: command to run a Docker container on Bacalhau

  2. davidgasquez/datadex:v0.2.0: name and tag of the Docker image

  3. duckdb -s "select 1": the DuckDB CLI command to execute

When a job is submitted, Bacalhau prints out the related job_id. We store that ID in an environment variable (JOB_ID) so that we can reuse it later on.


3. Declarative Job Description

The same job can be submitted in a declarative format. Create a YAML file (e.g., duckdb1.yaml) with the following content:

yamlCopy codename: DuckDB Hello World
type: batch
count: 1
tasks:
  - name: My main task
    Engine:
      type: docker
      params:
        Image: davidgasquez/datadex:v0.2.0
        Entrypoint:
          - /bin/bash
        Parameters:
          - -c
          - duckdb -s "select 1"

Then run the command:

bashCopy codebacalhau job run duckdb1.yaml

4. Checking the State of Your Jobs

  • Job Status Check the status of the job:

    bashCopy codebacalhau job list --id-filter ${JOB_ID}

    When it says Published or Completed, the job is done, and we can fetch the results.

  • Job Information Get more details about your job:

    bashCopy codebacalhau job describe ${JOB_ID}
  • Job Download Download your job results:

    bashCopy coderm -rf results && mkdir -p results
    bacalhau job get $JOB_ID --output-dir results

5. Viewing Your Job Output

Each job creates 3 subfolders in your results directory:

  1. combined_results

  2. per_shard

  3. raw

To view the output file:

bashCopy codecat results/stdout

Expected output:

Copy codeβ”Œβ”€β”€β”€β”
β”‚ 1 β”‚
β”œβ”€β”€β”€β”€
β”‚ 1 β”‚
β””β”€β”€β”€β”˜

6. Running Arbitrary SQL Commands

Below is an example command to run arbitrary SQL queries against the NYC Yellow Taxi Trips dataset. This dataset is hosted on IPFS for demonstration purposes.

bashCopy codeexport JOB_ID=$(bacalhau docker run \
  -i ipfs://bafybeiejgmdpwlfgo3dzfxfv3cn55qgnxmghyv7vcarqe3onmtzczohwaq \
  --workdir /inputs \
  --id-only \
  --wait \
  davidgasquez/duckdb:latest \
  -- duckdb -s "select count(*) from '0_yellow_taxi_trips.parquet'")

Structure of the Command

  1. bacalhau docker run: command to run a Docker container on Bacalhau

  2. -i ipfs://...: specifying IPFS CIDs so Bacalhau can mount the data at /inputs

  3. --workdir /inputs: sets the working directory inside the container to /inputs

  4. davidgasquez/duckdb:latest: Docker image with DuckDB installed

  5. duckdb -s: the DuckDB CLI command to execute


7. Declarative Job Description for Arbitrary SQL

You can also present the above job in YAML format. For example, duckdb2.yaml:

yamlCopy codename: DuckDB Parquet Query
type: batch
count: 1
tasks:
  - name: My main task
    Engine:
      type: docker
      params:
        WorkingDirectory: "/inputs"
        Image: davidgasquez/duckdb:latest
        Entrypoint:
          - /bin/bash
        Parameters:
          - -c
          - duckdb -s "select count(*) from '0_yellow_taxi_trips.parquet'"
    InputSources:
      - Target: "/inputs"
        Source:
          Type: "s3"
          Params:
            Bucket: "bacalhau-duckdb"
            Key: "*"
            Region: "us-east-1"

Then run:

bashCopy codebacalhau job run duckdb2.yaml

8. Checking Job Status, Describing, Downloading Results

  • Job Status

    bashCopy codebacalhau job list --id-filter ${JOB_ID} --wide
  • Job Information

    bashCopy codebacalhau job describe ${JOB_ID}
  • Job Download

    bashCopy coderm -rf results && mkdir -p results
    bacalhau job get $JOB_ID --output-dir results

Viewing Your Job Output

bashCopy codecat results/stdout

Sample output might look like this:

scssCopy codeβ”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ count_star() β”‚
β”‚    int64     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     24648499 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Need Support?

If you have questions or need support or guidance, please reach out to the Bacalhau team via Slack (look for the #general channel).

PreviousSystems EngineeringNextJobs Guide

Was this helpful?