Skip to main content

Log Storage and Analysis

Store application logs in a VeloDB Cloud warehouse to search messages, inspect recent events, and aggregate activity with SQL. Use a collector to parse and batch logs, or send JSON batches directly through Stream Load.

For the architecture and tool choices, see Custom observability. If you want a guided Collector and Grafana setup, use the DOG Stack quick start.

Prerequisites​

  • A running SaaS or BYOC warehouse and a SQL user that can create the example database and table. For continuous ingestion, use a dedicated user with load privileges on the destination table.
  • A collector host that can reach the warehouse's Stream Load endpoint. Use the endpoint, port, and TLS settings from Connect to a warehouse.
  • Permission to read the application logs on the collector host. This procedure collects logs from systems that you operate, rather than managed warehouse host logs.
  • A retention requirement and representative samples for testing event timestamps, field mappings, and parsing.

In VeloDB Cloud, you configure tables and warehouse compute. You do not deploy FE or BE servers, edit fe.conf or be.conf, select physical disks, or configure replica placement as part of this workflow. For service configuration changes, contact VeloDB Cloud support.

1. Plan capacity and retention​

A log pipeline has three layers: collectors read and transform events, the warehouse stores and queries them, and visualization tools display results. You operate the collectors and any external visualization tools.

InputPlanning use
Average and peak uncompressed bytes per secondSize ingestion capacity for bursts and retries as well as normal traffic.
Average event size and field countEstimate records per second, parsing work, and collector memory.
Retention periodSet partition expiration and estimate total stored data.
Measured compression, including indexesEstimate retained storage from a representative loaded sample.
Query patterns and concurrencyReserve capacity for searches and aggregations while ingestion continues.

For a first storage estimate, divide daily uncompressed volume by the measured compression ratio, then multiply by retention days. For example, 100 TB per day, a measured ratio of 5:1 including indexes, and 30 days of retention gives about 600 TB. This is a planning example, not a measured VeloDB Cloud result. Allow for growth and operational overhead, and validate with your data.

Choose warehouse compute by testing ingestion and representative queries together. Do not translate an upstream per-core throughput figure or a count of self-managed disks directly into a warehouse size. See Billing for compute and storage charges.

2. Create a log table​

Choose fields, partitions, and indexes​

ChoiceGuidance
Event timeUse a typed timestamp column and a consistent time zone across collectors, partitions, and queries.
PartitionsDaily range partitions make time filtering and retention management explicit. Dynamic partitioning can create future partitions and drop expired ones.
BucketsChoose a count from expected partition size and measured ingestion and query behavior. The count in the example is a starting point for a trial.
Text searchUse an inverted index with parser = unicode on the message. Enable support_phrase if you use phrase queries.
CompressionZstandard can reduce stored size. Measure the ratio with the fields and indexes you actually use.
Variable attributesUse VARIANT for changing nested attributes, and explicit columns for stable fields that drive queries.

See Dynamic partitioning and Bucketing for the relevant tradeoffs.

Warning:

The example below enables dynamic partition expiration. Partitions older than the configured 30-day window are dropped automatically. Change dynamic_partition.start to meet your retention requirements before loading production data.

Create the example schema​

Run the following SQL in your warehouse. The example uses UTC and keeps approximately 30 days of daily partitions. Use the same time zone when parsing log timestamps.

CREATE DATABASE IF NOT EXISTS log_db;
USE log_db;

CREATE TABLE log_table
(
ts DATETIMEV2(3),
host STRING,
path STRING,
message STRING,
INDEX idx_host (host) USING INVERTED,
INDEX idx_path (path) USING INVERTED,
INDEX idx_message (message) USING INVERTED
PROPERTIES("parser" = "unicode", "support_phrase" = "true")
)
ENGINE = OLAP
DUPLICATE KEY(ts)
PARTITION BY RANGE(ts) ()
DISTRIBUTED BY RANDOM BUCKETS 10
PROPERTIES (
"compression" = "zstd",
"dynamic_partition.enable" = "true",
"dynamic_partition.create_history_partition" = "true",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.time_zone" = "UTC",
"dynamic_partition.start" = "-30",
"dynamic_partition.end" = "1",
"dynamic_partition.prefix" = "p",
"dynamic_partition.buckets" = "10"
);

Check that partitions exist before loading data:

SHOW PARTITIONS FROM log_db.log_table;

The example omits CREATE RESOURCE, CREATE STORAGE POLICY, and replica-count settings used in some self-managed Apache Doris examples. Warehouse data uses shared object storage. A table storage_policy is not a VeloDB Cloud archival policy. See Storage and cache.

Handle changing fields​

For occasional top-level changes, use schema changes such as ADD COLUMN and DROP COLUMN. For a JSON object whose keys change between records, add a VARIANT column:

ALTER TABLE log_db.log_table ADD COLUMN properties VARIANT;

A log can then include attributes such as:

{
"properties": {
"format": "parquet",
"size": 1495636750,
"rowCount": 855138,
"downloadDuration": "00:01:58.3520561"
}
}

Plan indexes from the filters you use. Indexing every field increases ingestion work and storage. Schema changes and index builds can take time depending on the operation and data volume.

3. Collect logs​

Choose the collection method that matches your existing pipeline:

MethodUse whenConfiguration guide
LogstashYou already use Logstash inputs and filters, or need its parsing plugins.Logstash integration
FilebeatYou need file collection with a Filebeat build that includes the Doris output plugin.Filebeat integration
Fluent BitYou already use Fluent Bit and have verified the Doris output build's compatibility.Fluent Bit integration
OpenTelemetry CollectorYou already collect OpenTelemetry data or want a common collector for logs and traces.OpenTelemetry integration
Kafka Routine LoadLogs are already in Kafka and the warehouse can reach and authenticate to the brokers.Routine Load
A custom applicationYou need direct control over batching and delivery.Stream Load

The integration guides use their own example schemas. When writing to log_table, map events to ts, host, path, and message. Parse event time into the table's time zone and join multiline stack traces before export.

Configure Logstash or Filebeat​

For Logstash, install logstash-output-doris, keep your input and filter stages, and configure the output as follows. Replace the endpoint, username, and password with your warehouse values. Keep passwords in the Logstash keystore for production use.

output {
doris {
http_hosts => ["https://<warehouse-stream-load-host>:<port>"]
user => "<load-user>"
password => "<load-password>"
db => "log_db"
table => "log_table"
headers => {
"format" => "json"
"read_json_by_line" => "true"
"load_to_single_tablet" => "true"
}
mapping => {
"ts" => "%{event_time}"
"host" => "%{[host][name]}"
"path" => "%{[log][file][path]}"
"message" => "%{message}"
}
}
}

The input and filters must populate event_time in yyyy-MM-dd HH:mm:ss.SSS format in UTC. This output fragment is not a complete Logstash pipeline. See the complete Logstash examples for file input and parsing.

For Filebeat, use a build that includes output.doris. Set http_hosts to the warehouse Stream Load endpoint, database to log_db, and table to log_table. Use the field mapping in the Filebeat integration guide to output the columns above. Standard Filebeat binaries do not include this output plugin.

Start with the collector's normal batch settings, then measure queue growth, event freshness, request size, and memory. A million-event batch can consume substantial memory and delay delivery. Increasing retry counts alone does not guarantee delivery or prevent duplicates.

Collect logs from Kafka​

Create a Routine Load job after configuring warehouse-to-Kafka connectivity. The following example assumes newline-delimited JSON records with the same field names as log_table and Kafka SASL/SSL authentication. Replace the broker, topic, and credentials.

CREATE ROUTINE LOAD log_db.load_log_kafka ON log_table
COLUMNS(ts, host, path, message)
PROPERTIES (
"format" = "json",
"max_batch_interval" = "10",
"load_to_single_tablet" = "true"
)
FROM KAFKA (
"kafka_broker_list" = "<kafka-broker>:9093",
"kafka_topic" = "<log-topic>",
"property.security.protocol" = "SASL_SSL",
"property.sasl.mechanism" = "PLAIN",
"property.sasl.username" = "<kafka-user>",
"property.sasl.password" = "<kafka-password>"
);

SHOW ROUTINE LOAD FOR log_db.load_log_kafka;

Match the security protocol and mechanism to your Kafka service. Do not copy host-local keytab paths from self-managed examples into a Cloud job. See Routine Load for authentication and network requirements.

Send JSON with Stream Load​

Create logfile.json with one JSON object per line. Each record must contain ts, host, path, and message. Use timestamps within the table's retained partition range, formatted as yyyy-MM-dd HH:mm:ss.SSS in UTC.

Replace the endpoint and username below. Use the URL generated for the warehouse and preserve its HTTPS scheme when TLS is enabled. curl prompts for the password.

curl --location-trusted \
--user "<load-user>" \
-H "format:json" \
-H "read_json_by_line:true" \
-H "load_to_single_tablet:true" \
-H "timezone:UTC" \
-T logfile.json \
"https://<warehouse-stream-load-host>:<port>/api/log_db/log_table/_stream_load"

Inspect the response body. A successful HTTP status alone does not prove that the load succeeded. Check Status, NumberLoadedRows, NumberFilteredRows, and Message. If the response contains an ErrorURL, use it to inspect rejected rows. See Stream Load for complete result handling.

The load_to_single_tablet header batches a load into one bucket for random-bucket tables. Measure its effect with your load size and concurrency. Select batch sizes from collector memory, ingestion latency, and warehouse capacity. See Group Commit if you need to combine small loads.

4. Query and analyze logs​

Run queries in a SQL client connected to the warehouse. Include a time range in production queries to limit the partitions scanned.

View the latest ten logs:

SELECT ts, host, path, message
FROM log_db.log_table
ORDER BY ts DESC
LIMIT 10;

Filter logs for a host:

SELECT ts, message
FROM log_db.log_table
WHERE host = 'demo-host'
ORDER BY ts DESC
LIMIT 10;

Search for either error or 404 with MATCH_ANY:

SELECT ts, host, message
FROM log_db.log_table
WHERE message MATCH_ANY 'error 404'
ORDER BY ts DESC
LIMIT 10;

Search for both image and faq with MATCH_ALL:

SELECT ts, message
FROM log_db.log_table
WHERE message MATCH_ALL 'image faq'
ORDER BY ts DESC
LIMIT 10;

Search for the phrase image faq with MATCH_PHRASE. The tokens must occur consecutively in that order. This query requires the index's support_phrase setting:

SELECT ts, message
FROM log_db.log_table
WHERE message MATCH_PHRASE 'image faq'
ORDER BY ts DESC
LIMIT 10;

For visualization, configure a tool such as Grafana to query the warehouse. The SQL queries and field mappings must match your schema. For a configured search interface, see DOG Stack search.

Common errors​

SymptomWhat to checkResolution
Connection refused or timeoutWarehouse endpoint, DNS, IP allowlist, private connectivity, and reachable ports.Verify the collector host's route using the connection guide. Use warehouse endpoints rather than FE hostnames from self-managed examples.
Authentication or authorization failureSQL credentials and destination-table load privileges.Use warehouse SQL credentials and grant the required privileges to the ingestion user.
Load response reports filtered rowsTimestamp format, JSON shape, field types, and available partitions.Inspect ErrorURL when present and compare sample records with the table schema and SHOW PARTITIONS.
Historical sample data fails to loadSample dates fall outside the dynamic-partition window.Use current timestamps for a trial or create suitable historical partitions before loading. Do not extend production retention without assessing storage impact.
Logs appear under the wrong time rangeCollector, partition, session, and dashboard time zones.Normalize timestamps consistently and compare a known event's time at each stage.
Phrase search fails or returns unexpected resultsIndex parser and support_phrase settings.Use an index configured for phrase search and check how the parser tokenizes the message.
Queues grow or ingestion slowsRequest rate, batch size, concurrency, warehouse load, and collector retries.Measure the bottleneck, tune one setting at a time, and size compute accordingly. Contact VeloDB Cloud support for service configuration changes.

Retention and cleanup​

Monitor storage growth and query performance while ingestion runs. Dynamic partitioning drops expired daily partitions according to dynamic_partition.start. This setting manages retention, rather than moving rows to a separate archive.

For a trial, stop the collector before removing its destination. If you created the Routine Load job above, stop it with:

STOP ROUTINE LOAD FOR log_db.load_log_kafka;

If the example table contains only disposable test data, remove it after the trial:

DROP TABLE log_db.log_table;

Remove any other example tables that you created, and remove unused collectors and visualization resources. Review Billing for ongoing warehouse charges.

See also​

Enter to send · Shift+Enter for a new line