Thursday, 7 August 2025

How to load data from Druid Console?

Navigate to Druid console by opening the url (http://localhost:8888) in browser.

Load data -> Batch - classic

 


Apache Druid installation comes with some sample datasets to start experimenting. These datasets are available in apache-druid-32.0.1/quickstart/tutorial/ folder.

$ls apache-druid-32.0.1/quickstart/tutorial/
compaction-day-granularity.json		transform-data.json			updates-overwrite-index.json
compaction-init-index.json		transform-index.json			wikipedia-index-hadoop3.json
compaction-keep-granularity.json	updates-append-index.json		wikipedia-index.json
deletion-index.json			updates-append-index2.json		wikipedia-kafka-supervisor.json
deletion-kill.json			updates-data.json			wikipedia-top-pages-sql.json
hadoop					updates-data2.json			wikipedia-top-pages.json
retention-index.json			updates-data3.json			wikiticker-2015-09-12-sampled.json.gz
rollup-data.json			updates-data4.json
rollup-index.json			updates-init-index.json

Let’s use the file wikiticker-2015-09-12-sampled.json.gz to start with.

 


Select ‘Local disk’ and click on Connect data button.

 


Since we are going to refer the file in Druid installation directory, we can give the relative path for the Base Directory as quickstart/tutorial, Set the file name wikiticker-2015-09-12-sampled.json.gz in File filter field. Click on Apply button.

 

If everything goes well, you can see the json records from the file.

 


At bottom right corner of the same page, you can see a button ‘Next: Parse data’, click on this.

 


You will be taken to ‘Parse data’ tab. The "Parse data" tab in Apache Druid is one of the first steps in the data ingestion wizard (via the web console at http://localhost:8888). It helps you to preview, configure, and transform your raw data before ingestion into Druid.

 


Click on the button Parse time available at bottom right corner to proceed to parse time tab.

 

The Parse time tab is where you configure:

 

·      Which field (column) in your data represents time

·      What format that time is in

 

Druid needs this because it’s a time-first database, it requires a special column called __time, which is used to:

 

·      Partition data

·      Index efficiently

·      Query quickly

·      Filter using time ranges

 


From the above image, you can observe that Druid automatically took the time column as __time. Let’s keep this as it is and click on Transform button available at bottom right corner of the page. You will be taken to Transform tab.

 

The Transform tab allows you to create new derived columns from your raw input data before it’s ingested into Druid. These transformations happen:

 

·      Before filtering

·      Before ingestion

·      Before storage

 

So, it's a pre-processing stage. Think of it as "cleaning and preparing" your data as it flows into Druid.

 


Let’s keep it as it and click on Filter button available at bottom right corner. The Filter tab in Apache Druid's ingestion wizard is where you define conditions to exclude rows of data before they're ingested.

 


Let’s proceed further by clicking on ‘Configure Schema’ button available at bottom right corner. The Configure Schema tab in Apache Druid’s web console is where you:

 

·      Define which fields in your data are dimensions

·      Pick or create metrics/aggregators

·      Configure timestamp handling

·      Choose how the data should be partitioned and indexed

 

This step is all about structuring your data so Druid can ingest, index, and query it efficiently.

 


Let’s proceed further by clicking on the Partition button.

 


The Partition tab is all about:

 

·      How your data is split into segments (files stored by Druid)

·      How much data goes into each segment

·      Whether or not segments are further partitioned internally

·      Which time ranges your ingestion covers

·      This affects query performance, storage layout, and parallelism during ingestion.

Select Segment granularity as day and click on Tune button.

 


 

You will be taken to Tune tab. The Tune tab is where you configure how much power, memory, and error forgiveness Druid uses while ingesting your data.

 

·      How many rows do I buffer before flushing?

·      How many errors am I allowed?

·      How many tasks should run in parallel?

·      How much memory should each task use?

 


Click on Publish button. The Publish tab defines metadata-level configuration for the ingested data:

 

·      What should the final data source be called?

·      Should it overwrite existing data or append to it?

·      What visibility should it have (for queries)?

·      How should it be stored?

 

Think of this as the part where Druid wraps up the ingestion process and publishes the results for querying and storage.

 

Let’s give the datasource name as wikiticker-local-db.

 


Click on Edit spec button at bottom right corner. You will be taken to Edit spec tab.

 


The Edit Spec tab allows you to:

 

·      View the entire ingestion spec as raw JSON

·      Edit any part of the spec (schema, tuning, transforms, filters, etc.)

·      Fine-tune or customize things that may not be exposed via the UI

·      Save or reuse the spec for automating future ingestion jobs

 

This is very helpful for advanced users or anyone who wants to automate ingestion.

 

Click on the Submit task button available at bottom right corner of Edit spec tab.

 

Upon successful submission of the task, you will be taken to the Tasks tab.

 


Give it sometime to finish the task and reload the page, you can see Task status as SUCCESS.

 


Click on the Query button available at top (Horizontal Navigation Bar). You will be taken to Query page.

 

What Is the "Query" page?

The Query page is where you can:

 

·      Test queries on the ingested data

·      Explore your data quickly

·      Run different types of Druid queries such as timeseries, groupBy, select, and scan

·      View the results of those queries to make sure your ingestion worked as expected

 

This page is highly useful for interacting with your data without writing code or using external tools.

 


You can expand the file ‘wikiticker-local-db’ to see all the columns in it.

 


Let’s execute the following query (Data source must be mentioned in double quotes)

SELECT * FROM "wikiticker-local-db"

 


 

Upon successful execution of the query, you can see the first page results.

 

Example 1: Fetching the First 5 Records

You can retrieve a few rows from the datasource with the following query.

 

SELECT * FROM "wikiticker-local-db" LIMIT 5
 

This will return the first 5 rows in the wikiticker-local-db table. It’s useful for inspecting the data when you don’t want to overwhelm yourself with too many records.

Example 2: Timeseries Query, Count of Edits Over Time

To get a count of the edits made over time, you can perform a timeseries query. This aggregates the data by timestamp and counts the number of edits for each time bucket.

SELECT 
  __time,
  COUNT(*) AS edit_count
FROM "wikiticker-local-db"
WHERE __time BETWEEN '2015-09-12T00:00:00.000Z' AND '2015-09-12T23:59:59.999Z'
GROUP BY __time

Example 3: GroupBy Query, Count Edits by Country

Let’s say you want to count how many edits were made from different countries. You can group by the countryIsoCode dimension to see the number of edits from each country.

 

SELECT 
  countryIsoCode,
  COUNT(*) AS edit_count
FROM "wikiticker-local-db"
GROUP BY countryIsoCode
ORDER BY edit_count DESC
LIMIT 10

 

Example 4: GroupBy Query, Number of Edits by User

If you want to find out how many edits each user has made, you can group the data by user and count the number of edits per user.

SELECT 
  user,
  COUNT(*) AS edit_count
FROM "wikiticker-local-db"
WHERE user IS NOT NULL
GROUP BY user
ORDER BY edit_count DESC
LIMIT 10

 

This query will return the top 10 users by the number of edits they have made.

 

Example 5: Select Query, Retrieve Specific Fields

You might want to retrieve only specific fields, such as the channel, cityName, and comment fields, to inspect the content of specific edits. Here’s a select query for that:

SELECT 
  channel,
  cityName,
  comment
FROM "wikiticker-local-db"
LIMIT 5

This query will return the first 5 records with only the specified columns (channel, cityName, comment).

 

Example 6: Filter Query, Fetch Edits by Specific User

If you're interested in fetching all records made by a specific user (e.g., "GELongstreet"), you can filter the data:

SELECT *
FROM "wikiticker-local-db"
WHERE user = 'GELongstreet'
LIMIT 10

This query will return the first 10 records where the user is "GELongstreet". You can adjust the limit to retrieve more or fewer records.

 

Example 7: TopN Query: Top 5 Cities with the Most Edits

You can use the TopN query type to get the top 5 cities that had the most edits. The TopN query is useful for when you want to get the highest-ranked records based on some metric.

SELECT 
  cityName,
  COUNT(*) AS edit_count
FROM "wikiticker-local-db"
GROUP BY cityName
ORDER BY edit_count DESC
LIMIT 5

This will return the top 5 cities based on the number of edits.

 

Example 8: Scan Query, Fetch Raw Data Quickly

The scan query type provides a low-latency, unaggregated view of the data. It is typically used for fast access to raw data without any aggregation.

SELECT *
FROM "wikiticker-local-db"
WHERE cityName = 'New York'
LIMIT 5

This will return the first 5 records where the cityName is "New York".

 

Example 9: Filter by Time Interval, Data for a Specific Day

If you want to get the records for a specific day, say September 12, 2015, you can use the following query.

SELECT * 
FROM "wikiticker-local-db"
WHERE __time BETWEEN '2015-09-12T00:00:00.000Z' AND '2015-09-12T23:59:59.999Z'
LIMIT 5

This query will return the first 5 records from September 12, 2015.

 

These queries provide a good starting point to understand the core capabilities of Apache Druid for analyzing and querying your data in real time.

 

Happy learning….


Previous                                                    Next                                                    Home

Wednesday, 6 August 2025

How to Install Apache Druid : A Step-by-Step Guide for Single-Server Quickstart

Apache Druid is a high-performance real-time analytics database built for fast slice-and-dice analytics ("OLAP" queries) on large data sets. If you're exploring real-time data ingestion, interactive dashboards, or need lightning-fast queries on time-series data, Druid is an excellent choice.

This guide walks you through setting up a Single-Server Druid instance on a macOS machine. This setup is great for development, testing, and local experimentation. Production-grade installations should use Druid’s clustered deployment architecture.

 

1. Prerequisites

Java 11 or later

 

2. Steps to Setup Druid

Step 1: Download Apache Druid

Visit the Apache Druid Downloads Page 9 https://druid.apache.org/downloads/) and grab the latest stable version (e.g., apache-druid-32.0.1-bin.tar.gz).

 

Step 2: Extract the Archive, and start the Druid Cluster (Single-Server Quickstart)

 

Run the following command:

bin/start-micro-quickstart

$bin/start-micro-quickstart
Druid requires Java 11 or 17. Your current version is: 21.0.4.

If you believe this check is in error, or you want to proceed with a potentially
unsupported Java runtime, you can skip this check using an environment variable:

  export DRUID_SKIP_JAVA_CHECK=1

Otherwise, install Java 11 or 17 in one of the following locations.

  * DRUID_JAVA_HOME
  * JAVA_HOME
  * java (installed on PATH)

Other versions of Java versions may work, but are not officially supported.

For more information about selecting a Java runtime visit:
https://druid.apache.org/docs/latest/operations/java.html

Oops, Druid latest version require Java11 or 17, but I have Java 21.

 

Let me ignore java version check by setting below environment variable.

export DRUID_SKIP_JAVA_CHECK=1

Let me start the druid again.

$export DRUID_SKIP_JAVA_CHECK=1
$
$
$bin/start-micro-quickstart
[Fri Apr 18 07:40:01 2025] Starting Apache Druid.
[Fri Apr 18 07:40:01 2025] Open http://localhost:8888/ in your browser to access the web console.
[Fri Apr 18 07:40:01 2025] Or, if you have enabled TLS, use https on port 9088.
[Fri Apr 18 07:40:01 2025] Starting services with log directory [/Users/h0g01ex/Documents/technical-documents/bigdata/softwares/apache-druid-32.0.1/log].
[Fri Apr 18 07:40:01 2025] Running command[zk]: bin/run-zk conf
[Fri Apr 18 07:40:01 2025] Running command[coordinator-overlord]: bin/run-druid coordinator-overlord conf/druid/single-server/micro-quickstart
[Fri Apr 18 07:40:01 2025] Running command[broker]: bin/run-druid broker conf/druid/single-server/micro-quickstart
[Fri Apr 18 07:40:01 2025] Running command[router]: bin/run-druid router conf/druid/single-server/micro-quickstart
[Fri Apr 18 07:40:01 2025] Running command[historical]: bin/run-druid historical conf/druid/single-server/micro-quickstart
[Fri Apr 18 07:40:01 2025] Running command[middleManager]: bin/run-druid middleManager conf/druid/single-server/micro-quickstart

Open the url http://localhost:8888/ in browser, to see Apache Druid Console.

 


3. start-micro-quickstart

Let’s understand what happened when I ran the start-micro-quickstart command.

 

When you start Druid with start-micro-quickstart, it spins up a mini cluster on your local machine. Even though it's just one machine, Druid still follows a distributed architecture, so each service runs as a separate process.

 

3.1 zk: Zookeeper

[Fri Apr 18 07:40:01 2025] Running command[zk]: bin/run-zk conf

 

Zookeeper is a coordination service. Druid uses it to handle following operations.

·      Manage cluster metadata (which node is doing what)

·      Handle leader election (e.g., who is the master coordinator?)

 

3.2 coordinator-overlord: Management Processes

[Fri Apr 18 07:40:01 2025] Running command[coordinator-overlord]: bin/run-druid coordinator-overlord ...

 

Druid combines two critical services into one process:

 

Coordinator

·      Responsible for data management on the Historical nodes

·      Tells which data segments should be loaded/unloaded

·      Ensures replication, availability, and data balancing

 

Overlord

·      Manages task-based ingestion via MiddleManagers

·      Accepts ingestion specs, creates tasks, and monitors them

 

3.3 broker: Query Dispatcher

[Fri Apr 18 07:40:01 2025] Running command[broker]: bin/run-druid broker ...

 

Receives queries from clients (like the Druid Console or your app), figures out which nodes have the needed data, Distributes the query to the correct Historical/MiddleManager nodes and merges results and returns a final response.

 

3.4 router: API Gateway and UI

[Fri Apr 18 07:40:01 2025] Running command[router]: bin/run-druid router ...

 

Acts as a reverse proxy that routes traffic to:

·      Coordinator/Overlord UI

·      Broker for queries

·      Druid console (localhost:8888)

·      Useful in production setups where you want to expose only one endpoint

 

You can correlate it like an API Gateway that sends your request to the right backend service.

 

3.5 historical: Immutable Data Store

[Fri Apr 18 07:40:01 2025] Running command[historical]: bin/run-druid historical ...

 

·      Stores read-only, queried data in the form of segments

·      Very fast for historical data queries

·      Used for querying large amounts of past data efficiently

 

3.6 middleManager: Ingestion Engine

[Fri Apr 18 07:40:01 2025] Running command[middleManager]: bin/run-druid middleManager ...

 

·      Handles data ingestion into Druid

·      Runs tasks (in separate threads or JVMs) to pull, parse, and push data

·      Sends processed segments to Historical nodes

 

 

Previous                                                    Next                                                    Home

Sunday, 3 August 2025

Introduction to Apache Druid

As per the Official Druid website, Apache Druid is A high performance, real-time analytics database that delivers sub-second queries on streaming and batch data at scale and under load.

Ever wondered how apps like dashboards and data visualizations show huge amounts of information in real time like tracking millions of website visits, stock market movements, or user behavior? That magic often runs on powerful analytics databases behind the scenes.

 

One of those is Apache Druid a high-performance, open-source database built for super-fast analytics, especially when working with real-time and historical data.

 

Whether it’s processing streams of live events (like sensor data or live user clicks), or scanning years of data within seconds, Druid is designed to do it fast and with minimal resources.

 

1. Some Key points to know about Apache Druid:

·      It handles massive datasets with speed (even trillions of records!)

·      Works smoothly with tools like Apache Kafka and Amazon Kinesis

·      Helps developers and data enthusiasts use SQL to run powerful analytics

·      It's built for scale, speed, and reliability, making it ideal for real-world applications like gaming, finance, IoT, or any app that needs real-time insights

 

2. Key Features of Apache Druid

·      Superfast Queries: Druid is optimized to answer complex questions on massive data sets in milliseconds.

 

·      Real-Time + Historical Data: It can handle both live streaming data (like from Kafka or Kinesis) and older stored data at the same time.

 

·      Smart Storage Format: When data is added, Druid organizes it in a super-efficient format that makes future searches way faster.

 

·      Automatic Schema Detection: No need to define every column up front. Druid can figure out the structure of your data as it comes in.

 

·      Flexible Joins: Want to combine data from different tables? Druid can do that either while loading data or while querying.

 

·      SQL Support: You can interact with Druid using SQL, the same language most databases use and make it easy for students and analysts.

 

·      Scalable Architecture: Its components are loosely connected, so it can scale up or down easily, depending on your needs.

 

·      High Reliability: With built-in backup, recovery, and data replication, Druid ensures your data is safe and always available.

 

·      Tiered Performance (QoS): You can choose which types of tasks or data get top priority, helping balance speed and cost.

 

·      True Stream Ingestion: Unlike other databases that need extra tools, Druid connects directly to streaming platforms for real-time processing.

 

3. When Not to Use Apache Druid?

Apache Druid is a powerful database for real-time analytics, but it’s not a one-size-fits-all solution.

 

3. 1. Not for Transactional Systems (OLTP)  Like Banking or E-Commerce

Druid is built for analyzing large datasets, not handling thousands of small transactions per second (e.g., payments, user logins, inventory updates). It does not support row-level locking or ACID transactions (which ensure data integrity in systems like banks).

 

If you are looking for transactional usecase try PostgreSQL, MySQL, MongoDB etc.,

 

3.2 Avoid Frequent Updates or Deletes

Druid works best as an append-only system (adding new data, not changing old data). Updating or deleting records is slow and complex (requires rewriting entire data segments).

 

3.3 Not for Complex Joins Like Relational Business Data

Druid can join tables, but performance drops with multi-table, large-scale joins. It works best with denormalized data (flattened tables).

 

3.4 Not for Full-Text Search like Elasticsearch

Druid supports basic filtering, but not advanced text search (fuzzy matching, synonyms, scoring). If you need to search logs for phrases like "error 404 not found", Druid won’t be as efficient as Elasticsearch, which is built for text search.

 

3.5 Not for Non-Time-Based Data

Druid schemas must always include a primary timestamp. The primary timestamp is used for partitioning and sorting your data, so it should be the timestamp that you will most often filter on. Druid is able to rapidly identify and retrieve data corresponding to time ranges of the primary timestamp column.

 

3.6 Not for Strict Consistency

Druid is eventually consistent (not immediately ACID-compliant).

 

4. When Should You Use Druid?

·      Real-time dashboards (e.g., live sales analytics).

·      Streaming data analysis (e.g., IoT sensor monitoring).

·      Low-latency aggregations (e.g., counting user clicks per minute).

 

Previous                                                    Next                                                    Home

Apache Druid tutorial

      Introduction to Apache Druid
      How to Install Apache Druid : A Step-by-Step Guide for Single-Server Quickstart
      How to load data from Druid Console?
      Druid Architecture
      Getting Started with Loading Data into Apache Druid Using a Spec File and CURL request
      Ingesting Files Using post-index-task of Druid command
      Transforming Dimensions in Apache Druid: Using Uppercase on City and Product Fields
      Filtering Rows During Ingestion in Apache Druid
      Parsing Nested JSON in Apache Druid: A Beginner’s Guide with Student Data Example
      Understanding Roll-up in Druid
      Understanding Segments in Apache Druid
      How to delete segments in Druid?
      Loading Data from Kafka into Apache Druid
      How to Ingest Data from an HTTPS Endpoint into Apache Druid?
      How to load data from ORC file into Druid?
      Exploring Apache Druid Native Queries
      Querying Apache Druid via HTTP APIs
      Apache Pinot vs. Druid: Which Real-Time Analytics Database Should You Choose?
Previous                                                    Next                                                    Home