# nifi-kafka-druid-earthquake-data

> Install this demo for a showcase of using Kafka, Druid and Superset to view the global earthquake distribution.

Install this demo on an existing Kubernetes cluster:

> **Note:** The namespace `nifi-kafka-druid-earthquake-data` will be assumed in this guide. This is the default namespace used by `stackablectl` for this demo, so the `-n` argument can be omitted. It will be created if it doesn’t exist.

```console
$ stackablectl demo install nifi-kafka-druid-earthquake-data -n nifi-kafka-druid-earthquake-data
```

## System requirements

To run this demo, your system needs at least:

-   9 [cpu units](https://kubernetes.io/docs/tasks/debug/debug-cluster/resource-metrics-pipeline/#cpu) (core/hyperthread)

-   42GiB memory (minimum of 16GiB per node)

-   75GiB disk storage


## Overview

This demo will

-   Install the required Stackable operators.

-   Spin up the following data products:

    -   **Superset**: A modern data exploration and visualization platform. This demo utilizes Superset to retrieve data from Druid via SQL queries and build dashboards on top of that data.

    -   **Kafka**: A distributed event streaming platform for high-performance data pipelines, streaming analytics and data integration. This demo uses it as an event streaming platform to stream the data in near real-time.

    -   **NiFi**: An easy-to-use, robust system to process and distribute data. This demo uses it to fetch earthquake data from the internet and ingest it into Kafka.

    -   **Druid**: A real-time database to power modern analytics applications. This demo uses it to ingest the near real-time data from Kafka, store it and enable access to the data via SQL.

    -   **Garage**: S3 compatible object store. This demo uses it as persistent storage for Druid to store all the data.


-   Continuously emit approximately 10,000 records/s of [earthquake data](https://earthquake.usgs.gov/) into Kafka.

-   Start a Druid ingestion job that ingests the data into the Druid instance.

-   Create Superset dashboards for visualization of the data.


The whole data pipeline will have a very low latency, from putting a record into Kafka to showing up in the dashboard charts. You can see the deployed products and their relationship in the following diagram:

![overview.drawio](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/overview.drawio.png)

## List the deployed Stackable services

To list the installed Stackable services run the following command:

```console
$ stackablectl stacklet list -n nifi-kafka-druid-earthquake-data

┌───────────┬───────────┬──────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────┐
│ PRODUCT   │ NAME      │ NAMESPACE                        │ ENDPOINTS                                                                                                            │ CONDITIONS                      │
╞═══════════╪═══════════╪══════════════════════════════════╪══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╪═════════════════════════════════╡
│ druid     ┆ druid     ┆ nifi-kafka-druid-earthquake-data ┆ broker-https                                https://172.19.0.3:32293                                                 ┆ Available, Reconciling, Running │
│           ┆           ┆                                  ┆ coordinator-https                           https://172.19.0.4:31283                                                 ┆                                 │
│           ┆           ┆                                  ┆ router-https                                https://172.19.0.3:32286                                                 ┆                                 │
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ kafka     ┆ kafka     ┆ nifi-kafka-druid-earthquake-data ┆ broker-default-0-listener-broker-kafka-tls  172.19.0.4:32321                                                         ┆ Available, Reconciling, Running │
│           ┆           ┆                                  ┆ broker-default-0-listener-broker-metrics    172.19.0.4:30556                                                         ┆                                 │
│           ┆           ┆                                  ┆ broker-default-bootstrap-kafka-tls          172.19.0.4:31352                                                         ┆                                 │
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ nifi      ┆ nifi      ┆ nifi-kafka-druid-earthquake-data ┆ node-https                                  https://172.19.0.2:32348                                                 ┆ Available, Reconciling, Running │
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ superset  ┆ superset  ┆ nifi-kafka-druid-earthquake-data ┆ node-http                                   http://172.19.0.4:30769                                                  ┆ Available, Reconciling, Running │
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ zookeeper ┆ zookeeper ┆ nifi-kafka-druid-earthquake-data ┆ server-zk                                   zookeeper-server.nifi-kafka-druid-earthquake-data.svc.cluster.local:2282 ┆ Available, Reconciling, Running │
└───────────┴───────────┴──────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────────────────────┘
```

> **Note:** When a product instance has not finished starting yet, the service will have no endpoint. Depending on your internet connectivity, creating all the product instances might take considerable time. A warning might be shown if the product is not ready yet.

## Inspect the data in Kafka

Kafka is an event streaming platform to stream the data in near real-time. All the messages put in and read from Kafka are structured in dedicated queues called topics. The test data will be put into a topic called `earthquakes`. The records are produced (written) by the test data generator and consumed (read) by Druid afterwards in the same order they were created.

Kafka uses mutual TLS, so clients wanting to connect to Kafka must present a valid TLS certificate. The easiest way to obtain this is to shell into the `kafka-broker-default-0` Pod, as we will do in the following section for demonstration purposes. For a production setup, you should spin up a dedicated Pod provisioned with a certificate acting as a Kafka client instead of shell-ing into the Kafka Pod.

### List the available Topics

You can execute a command on the Kafka broker to list the available topics as follows:

```console
$ kubectl exec -n nifi-kafka-druid-earthquake-data kafka-broker-default-0 -c kafka -- \
env KAFKA_LOG4J_OPTS=-Dlog4j2.configurationFile=/stackable/kafka/config/tools-log4j2.yaml \
/stackable/kafka/bin/kafka-topics.sh \
--describe \
--bootstrap-server kafka-broker-default-headless.nifi-kafka-druid-earthquake-data.svc.cluster.local:9093 \
--command-config /stackable/config/client.properties
Topic: earthquakes	TopicId: ND51v_XcQPK4Ilm7A35Pag	PartitionCount: 8	ReplicationFactor: 1	Configs: min.insync.replicas=1,segment.bytes=100000000,retention.bytes=900000000
	Topic: earthquakes	Partition: 0	Leader: 1243966388	Replicas: 1243966388	Isr: 1243966388	Elr: 	LastKnownElr:
	Topic: earthquakes	Partition: 1	Leader: 1243966388	Replicas: 1243966388	Isr: 1243966388	Elr: 	LastKnownElr:
	Topic: earthquakes	Partition: 2	Leader: 1243966388	Replicas: 1243966388	Isr: 1243966388	Elr: 	LastKnownElr:
	Topic: earthquakes	Partition: 3	Leader: 1243966388	Replicas: 1243966388	Isr: 1243966388	Elr: 	LastKnownElr:
	Topic: earthquakes	Partition: 4	Leader: 1243966388	Replicas: 1243966388	Isr: 1243966388	Elr: 	LastKnownElr:
	Topic: earthquakes	Partition: 5	Leader: 1243966388	Replicas: 1243966388	Isr: 1243966388	Elr: 	LastKnownElr:
	Topic: earthquakes	Partition: 6	Leader: 1243966388	Replicas: 1243966388	Isr: 1243966388	Elr: 	LastKnownElr:
	Topic: earthquakes	Partition: 7	Leader: 1243966388	Replicas: 1243966388	Isr: 1243966388	Elr: 	LastKnownElr:
```

You can see that Kafka consists of one broker, and the topic `earthquakes` with eight partitions has been created. To see some records sent to Kafka, run the following command. You can change the number of records to print via the `--max-messages` parameter.

```console
$ kubectl exec -n nifi-kafka-druid-earthquake-data kafka-broker-default-0 -c kafka -- \
env KAFKA_LOG4J_OPTS=-Dlog4j2.configurationFile=/stackable/kafka/config/tools-log4j2.yaml \
/stackable/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server kafka-broker-default-headless.nifi-kafka-druid-earthquake-data.svc.cluster.local:9093 \
--command-config /stackable/config/client.properties \
--topic earthquakes \
--offset earliest \
--partition 0 \
--max-messages 1
```

Below is an example of the output of one record:

```json
 {
   "time":"1950-02-07T10:37:29.240Z",
   "latitude":45.949,
   "longitude":151.59,
   "depth":35.0,
   "mag":5.94,
   "magType":"mw",
   "nst":null,
   "gap":null,
   "dmin":null,
   "rms":null,
   "net":"iscgem",
   "id":"iscgem895202",
   "updated":"2022-04-26T18:23:38.377Z",
   "place":"Kuril Islands",
   "type":"earthquake",
   "horizontalError":null,
   "depthError":12.6,
   "magError":0.55,
   "magNst":null,
   "status":"reviewed",
   "locationSource":"iscgem",
   "magSource":"iscgem"
}
```

If you are interested in how many records have been produced to the Kafka topic so far, use the following command.

```console
$ kubectl exec -n nifi-kafka-druid-earthquake-data kafka-broker-default-0 -c kafka -- \
env KAFKA_LOG4J_OPTS=-Dlog4j2.configurationFile=/stackable/kafka/config/tools-log4j2.yaml \
/stackable/kafka/bin/kafka-get-offsets.sh \
--bootstrap-server kafka-broker-default-headless.nifi-kafka-druid-earthquake-data.svc.cluster.local:9093 \
--command-config /stackable/config/client.properties \
--topic earthquakes
earthquakes:0:382154
earthquakes:1:382497
earthquakes:2:380081
earthquakes:3:383763
earthquakes:4:380450
earthquakes:5:384584
earthquakes:6:379054
earthquakes:7:380635
```

Summing the offsets of all `8` partitions gives the total number of records produced, ~ 3,050,000 in this case. The demo ingests the complete earthquake catalogue once, so the offsets stop growing when the import has finished.

## NiFi

NiFi is used to fetch earthquake data from the internet and ingest it into Kafka. This demo includes a workflow ("process group") that downloads a large CSV file, converts it to individual JSON records and produces the records into Kafka.

### View the testdata-generation Job

You can have a look at the ingestion job running in NiFi by opening the endpoint `https` from your `stackablectl stacklet list` command output. In this case, it is [https://172.19.0.2:32348](https://172.19.0.2:32348). Open it with your favourite browser. Suppose you get a warning regarding the self-signed certificate generated by the [Secret Operator](https://docs.stackable.tech/home/stable/secret-operator/index.md) (e.g. Warning: Potential Security Risk Ahead). In that case, you must tell your browser to trust the website and continue.

![nifi 1](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/nifi_1.png)

Log in with the username `admin` and password `adminadmin`.

![nifi 2](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/nifi_2.png)

You can see the started ProcessGroup consisting of three processors. The first one - `InvokeHTTP`, fetches the CSV file from the Internet and puts it into the queue of the next processor. The second processor - `SplitRecord`, takes the single FlowFile (NiFi Record) which contains all CSV records and splits it into chunks of 2000 records, which are then separately put into the queue of the next processor. The third one - `PublishKafka`, parses the CSV chunk, converts it to JSON records and writes them out into Kafka.

Double-click on the `InvokeHTTP` processor to show the processor details.

![nifi 3](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/nifi_3.png)

Head over to the `Properties` tab.

![nifi 4](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/nifi_4.png)

Here, you can see the setting `HTTP URL`, which specifies the download URL from where the CSV file is retrieved. Close the processor details popup by clicking `Close`. Afterwards, double-click on the processor `PublishKafka`.

![nifi 5](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/nifi_5.png)

The Kafka connection service, which contains the connection details, and the topic name is specified. It uses the `CSVReader` to parse the downloaded CSV and the `JsonRecordSetWriter` to split it into individual JSON records before writing it out.

## Druid

Druid is used to ingest the near real-time data from Kafka, store it and enable SQL access. The demo has started an ingestion job reading earthquake records from the Kafka topic earthquakes and saving them into Druid’s deep storage. The Druid deep storage is based on the S3 store provided by Garage.

### View the Ingestion job

You can have a look at the ingestion job running in Druid by opening the endpoint `router-https` from your `stackablectl stacklet list` command output ([https://172.19.0.3:32286](https://172.19.0.3:32286) in this case).

![druid 1](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/druid_1.png)

By clicking on `Supervisors` at the top, you can see the running ingestion jobs.

![druid 2](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/druid_2.png)

You can see additional information after clicking on the magnification glass to the right side of the `RUNNING` supervisor. On the tab `Task stats` on the left, you can see the number of processed records as well as the number of errors.

![druid 3](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/druid_3.png)

The statistics show that Druid ingested `13279` records per second within the last minute and has ingested around 600,000 records already. All entries have been consumed successfully, indicated by having no `processWithError`, `thrownAway` or `unparseable` records in the output of the `View raw` button at the top right.

### Query the Data Source

The ingestion job has automatically created the Druid data source `earthquakes`. You can see the available data sources by clicking on `Datasources` at the top.

![druid 4](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/druid_4.png)

You can see the data source’s segments by clicking on `Segments` in the menu bar at the top. In this case, the `earthquakes` data source is partitioned by the year of the earthquakes, resulting in 73 segments.

![druid 5](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/druid_5.png)

Druid offers a web-based way of querying the data sources via SQL. To achieve this, you must first click on `Query` at the top.

![druid 6](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/druid_6.png)

You can now enter any arbitrary SQL statement, to e.g. list 10 earthquakes run

```sql
select * from earthquakes limit 10
```

![druid 7](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/druid_7.png)

To count the number of earthquakes per year run

```sql
select
  time_format(__time, 'YYYY') as "year",
  count(*) as earthquakes
from earthquakes
group by 1
order by 1 desc
```

![druid 8](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/druid_8.png)

## Superset

Superset provides the ability to execute SQL queries and build dashboards. Open the endpoint `node-http` in your browser ([http://172.19.0.4:30769](http://172.19.0.4:30769) in this case).

![superset 1](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_1.png)

Log in with the username `admin` and password `adminadmin`.

![superset 2](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_2.png)

### View the dashboard

The demo has created a Dashboard to visualize the earthquake data. To open it, click on the tab `Dashboards` at the top.

![superset 3](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_3.png)

Click on the dashboard called `Earthquakes`. It might take some time until the dashboard renders all included charts.

![superset 4](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_4.png)

### View the charts

The dashboard `Earthquakes` consists of multiple charts. To list the charts, click on the tab `Charts` at the top.

![superset 5](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_5.png)

Click on the Chart `Number of earthquakes by magnitude`. On the left side you can modify the chart and click on `Update Chart` to see the effect.

![superset 6](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_6.png)

### View the Earthquake Distribution on the World Map

To look at the geographical distribution of the earthquakes you have to click on the tab `Charts` at the top again. Afterwards click on the chart `Earthquake distribution`.

![superset 7](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_7.png)

The distribution of the earthquakes matches the continental plate margins. This is the expected distribution from the [Wikipedia article on Earthquakes](https://en.wikipedia.org/wiki/Earthquake).

### Execute arbitrary SQL statements

Within Superset you can not only create dashboards but also run arbitrary SQL statements. On the top click on the tab `SQL` → `SQL Lab`.

![superset 10](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_10.png)

On the left select the database `druid`, the schema `druid` and select `earthquakes` from the `druid` folder. Click on `Add a new tab`.

![superset 11](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_11.png)

On the right textbox enter the desired SQL statement. If you do not want to make one up, you can use the following:

```sql
select
  time_format(__time, 'YYYY') as "year",
  count(*) as earthquakes
from earthquakes
group by 1
order by 1 desc
```

![superset 12](https://docs.stackable.tech/home/stable/demos/_images/nifi-kafka-druid-earthquake-data/superset_12.png)

## S3

The S3 provided by Garage is used as a persistent deep storage for Druid to store all the data used.

Garage has no web interface, so the buckets are inspected with an S3 client.

Read the endpoint and credentials out of the cluster:

```console
$ KUBECTL_NAMESPACE="default" # or whichever you set when running stackablectl demo install
$ NODE_IP="$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}' | cut -d' ' -f1)" # a dual-stack node reports several
$ case "$NODE_IP" in *:*) NODE_IP="[$NODE_IP]";; esac # an IPv6 address needs brackets in a URL
$ NODE_PORT="$(kubectl -n "$KUBECTL_NAMESPACE" get service garage -o jsonpath='{.spec.ports[0].nodePort}')"
$ export S3_ENDPOINT="https://$NODE_IP:$NODE_PORT"
$ export S3_ACCESS_KEY="$(kubectl -n "$KUBECTL_NAMESPACE" get secret s3-credentials -o jsonpath='{.data.accessKey}' | base64 -d)"
$ export S3_SECRET_KEY="$(kubectl -n "$KUBECTL_NAMESPACE" get secret s3-credentials -o jsonpath='{.data.secretKey}' | base64 -d)"
$ export S3_REGION=region-1
```

The region is not optional. Garage rejects any request signed for a different region than the one it is configured with, and most clients fall back to an AWS region when none is set.

The certificate is issued by the Stackable secret-operator, whose CA your machine does not trust, so the commands below skip certificate verification.

**Tab: AWS CLI**

```console
$ export AWS_ENDPOINT_URL="$S3_ENDPOINT"
$ export AWS_ACCESS_KEY_ID="$S3_ACCESS_KEY"
$ export AWS_SECRET_ACCESS_KEY="$S3_SECRET_KEY"
$ export AWS_DEFAULT_REGION="$S3_REGION"
$ aws configure set default.s3.addressing_style path
```

The commands below are written for `rclone`. The `aws` equivalents are `aws s3 ls` to list buckets and `aws s3 ls s3://<bucket>/ --recursive --human-readable` to list objects, both with `--no-verify-ssl`.

**Tab: rclone**

`rclone` needs no installation, it runs straight from a container image:

```console
$ rclone() {
    docker run --rm -i --network host \
      -e RCLONE_S3_PROVIDER=Other \
      -e RCLONE_S3_ENDPOINT="$S3_ENDPOINT" \
      -e RCLONE_S3_REGION="$S3_REGION" \
      -e RCLONE_S3_ACCESS_KEY_ID="$S3_ACCESS_KEY" \
      -e RCLONE_S3_SECRET_ACCESS_KEY="$S3_SECRET_KEY" \
      -e RCLONE_S3_FORCE_PATH_STYLE=true \
      -e RCLONE_NO_CHECK_CERTIFICATE=true \
      rclone/rclone:1.75.1 "$@"
  }
```

`--network host` is there for anyone trying the demos out on a local cluster, where the endpoint is only reachable from the host itself.

In the commands below, `lsd` lists buckets, `lsf` lists names only, and `lsl` adds sizes and modification times.

Druid writes its segments into the `demo` bucket, under `data/earthquakes`:

```console
$ rclone lsf --dirs-only :s3:demo/data/earthquakes
```

Each prefix corresponds to one segment, which in turn contains all the data of a year. Druid saved roughly 201.5 MiB of data across 73 prefixes. If nothing is listed, Druid has not flushed its data from memory to the deep storage yet. After waiting for roughly an hour, the data should show up.

If you don’t want to wait, you can make Druid publish the data to the deep storage right away:

1.  Open the Druid web interface (the endpoint `router-https` from your `stackablectl stacklet list` command output).

2.  Click on `Supervisors` at the top.

3.  Open the actions menu of the `earthquakes` supervisor and click on `Suspend`. The running ingestion task stops reading from Kafka, publishes its segments to S3 and finishes.

4.  Run the `rclone lsf` command from above again. The prefixes should show up after a short while.

5.  Open the actions menu of the supervisor again and click on `Resume` to continue the ingestion.


Opening up a prefix for a specific year shows the file containing the data of that year:

```console
$ rclone lsl :s3:demo/data/earthquakes
```

`size` totals the segments up, once the whole data set has been ingested:

```console
$ rclone size :s3:demo/data/earthquakes
Total objects: 73
Total size: 201.537 MiB (211326832 Byte)
```

## Summary

The demo streamed 10,000 earthquake records/s for a total of ~3 million earthquakes into a Kafka steaming pipeline. Druid ingested the data near real-time into its data source and enabled SQL access to it. Superset was used as a web-based frontend to execute SQL statements and build dashboards.

## Where to go from here

There are multiple paths to go from here. The following sections give you some ideas on what to explore next. You can find the description of the earthquake data [on the United States Geological Survey website](https://earthquake.usgs.gov/earthquakes/feed/v1.0/csv.php).

### Execute arbitrary SQL statements

Within Superset (or the Druid web interface), you can execute arbitrary SQL statements to explore the earthquake data.

### Create additional dashboards

You also can create additional charts and bundle them together in a Dashboard. Have a look at [the Superset documentation](https://superset.apache.org/docs/using-superset/creating-your-first-dashboard/#creating-charts-in-explore-view) on how to do that.

### Load additional data

You can use the NiFi web interface to collect arbitrary data and write it to Kafka (it’s recommended to use new Kafka topics for that). Alternatively, you can use a Kafka client like [kcat](https://github.com/edenhill/kcat) to create new topics and ingest data. Using the Druid web interface, you can start an ingestion job that consumes and stores the data in an internal data source. There is an excellent [tutorial](https://druid.apache.org/docs/latest/tutorials/tutorial-kafka.html#loading-data-with-the-data-loader) from Druid on how to do this. Afterwards, the data source can be analyzed within Druid and Superset, like the earthquake data.
