Skip to main content

Logstash

Use the Logstash Doris output plugin to load events from a Logstash pipeline into a VeloDB Cloud warehouse through Stream Load. Keep your existing inputs and filters, then configure the output with your warehouse endpoint and target table.

The output supports field mappings, batching, retries, and custom Stream Load headers. You run Logstash in your own environment. VeloDB Cloud provides the storage and SQL query layer.

Prerequisites​

  • A running SaaS or BYOC warehouse and a warehouse SQL user with load privileges on the target tables. You also need permission to create the sample database and tables.
  • Network access from Logstash to the warehouse Stream Load endpoint, including any additional ingestion ports required by your connection method. Copy the endpoint from Connect in the console. See Connection Methods.
  • A Logstash installation with the Doris output plugin and access to log files on a host that you operate.

Use the endpoint's required protocol and TLS settings. For HTTPS, the Logstash JVM must trust the endpoint's certificate. The examples do not require access to the managed warehouse's FE or BE hosts.

Install the plugin​

Obtain a plugin package compatible with your Logstash version, or build one from the Apache Doris Logstash extension source. Follow the build instructions for the selected revision, including its JRuby, Java, and dependency requirements.

Set LOGSTASH_HOME to your installation directory. Replace the package path with the .gem file you obtained:

"${LOGSTASH_HOME}/bin/logstash-plugin" install /absolute/path/to/logstash-output-doris.gem
"${LOGSTASH_HOME}/bin/logstash-plugin" list --verbose logstash-output-doris

For an offline host, prepare an offline pack on a connected host with a compatible Logstash installation, then transfer and install it. A .gem alone may still need dependencies. Follow the Logstash offline plugin management instructions.

Output configuration​

ParameterMeaning
http_hostsArray of Stream Load base URLs, including protocol and port, without /api/.../_stream_load. Use the warehouse endpoint.
user, passwordWarehouse SQL credentials with load privileges on the target table.
db, tableTarget database and table. The database key is db, not database.
label_prefixPrefix for generated load labels. The source default is logstash.
headersMap of Stream Load headers, such as "format" => "json".
mappingMap from target field names to Logstash field templates. Unmapped fields are excluded when a mapping is supplied.
message_onlySend only the message field as the request body instead of serializing the event. The default is false. Useful when message already contains JSON.
max_retriesRetry count. The source default is -1, which retries indefinitely. Monitor backpressure and queue capacity.
log_requestWhether to log Stream Load request and response details. Review logs for sensitive metadata before sharing them.
log_progress_intervalProgress logging interval in seconds. The source default is 10. Set it to 0 to disable progress logging.

Defaults and dependency requirements can differ by plugin revision. Check the package you install. Retry configuration alone does not guarantee delivery through a process or host failure.

Warning:

Some plugin revisions log request headers containing Authorization, including during startup. A Basic Authorization value contains reversibly encoded SQL credentials. Confirm that your build redacts credentials before deploying it. Setting log_request to false does not remove an unconditional startup log. Upgrade or patch affected builds, restrict log access, and remove credentials before sharing logs.

In the examples, replace the endpoint and file paths. Provide WAREHOUSE_SQL_USER and WAREHOUSE_SQL_PASSWORD through the Logstash keystore or your process environment. Keep passwords out of configuration files committed to source control.

Example 1: Collect multiline text logs​

Parse application fields and keep exception stack traces

Create the target table​

Run the following in the warehouse's SQL Editor:

CREATE DATABASE IF NOT EXISTS log_db;
USE log_db;

CREATE TABLE logstash_app_logs (
log_time DATETIME(3),
collect_time DATETIME(3),
host TEXT,
path TEXT,
level TEXT,
thread TEXT,
position TEXT,
message TEXT,
INDEX idx_level (level) USING INVERTED,
INDEX idx_message (message) USING INVERTED
PROPERTIES("parser" = "unicode", "support_phrase" = "true")
)
DUPLICATE KEY(log_time)
DISTRIBUTED BY RANDOM BUCKETS 4;

This demonstration table is unpartitioned so that you can replay historical sample data. It does not expire rows automatically. For continuous ingestion, design time partitions and retention for your workload. See Store and Analyze Logs.

Prepare the source log​

Save these synthetic records in a file that Logstash can read:

2024-07-08 21:18:01,432 INFO (worker|61) [OrderService.process():70] Order received
2024-07-08 21:18:53,710 WARN (worker|62) [OrderService.process():84] Payment service unavailable
java.lang.IllegalStateException: Retry payment
at example.OrderService.process(OrderService.java:84)

Configure the pipeline​

Save this as logstash_app_logs.conf. Replace /absolute/path/to/app.log and the HTTPS URL. The input uses ECS-compatible metadata paths for the host and source file.

input {
file {
path => "/absolute/path/to/app.log"
start_position => "beginning"
ecs_compatibility => "v1"
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601} "
negate => true
what => "previous"
auto_flush_interval => 2
}
}
}

filter {
grok {
match => {
"message" => "^%{TIMESTAMP_ISO8601:log_time} %{LOGLEVEL:level} \((?<thread>[^)]+)\) \[(?<position>[^\]]+)\]"
}
}
if "_grokparsefailure" not in [tags] {
mutate {
gsub => ["log_time", ",", "."]
}
}
}

output {
if "_grokparsefailure" not in [tags] {
doris {
http_hosts => ["https://<warehouse-host>:<https-port>"]
user => "${WAREHOUSE_SQL_USER}"
password => "${WAREHOUSE_SQL_PASSWORD}"
db => "log_db"
table => "logstash_app_logs"
headers => {
"format" => "json"
"read_json_by_line" => "true"
}
mapping => {
"log_time" => "%{log_time}"
"collect_time" => "%{@timestamp}"
"host" => "%{[host][name]}"
"path" => "%{[log][file][path]}"
"level" => "%{level}"
"thread" => "%{thread}"
"position" => "%{position}"
"message" => "%{message}"
}
}
} else {
stdout { codec => rubydebug }
}
}

The input combines multiline exceptions with their first timestamped line. The filter extracts searchable fields, and the output serializes the mapped fields as JSON, including escaping newlines and quotation marks. In this example, records that fail parsing go to the local diagnostic output. Use a controlled failure destination and monitor it in production.

log_time is the time in the application record, while collect_time is the Logstash event timestamp. This sample's application timestamps have no UTC offset. Align their interpretation with the warehouse session and dashboard time zone.

Start with Logstash's default pipeline batch settings. Tune pipeline.batch.size, worker count, and queue settings against measured event sizes and latency. A very large batch can use substantial heap memory. pipeline.batch.delay is measured in milliseconds and is not an end-to-end delivery interval. Review Logstash performance tuning before changing it.

Start and verify collection​

Validate the configuration, then start the pipeline:

"${LOGSTASH_HOME}/bin/logstash" --config.test_and_exit -f logstash_app_logs.conf
"${LOGSTASH_HOME}/bin/logstash" -f logstash_app_logs.conf

Inspect the Stream Load result for Status: Success and zero filtered rows. Query the loaded data:

SELECT log_time, level, message
FROM log_db.logstash_app_logs
ORDER BY log_time DESC
LIMIT 10;

The two timestamped records should appear, with the stack trace in the warning record. The file input saves read offsets. start_position => "beginning" only affects files that have no saved position, so restarting the process does not necessarily replay the sample.

Example 2: Collect JSON logs​

Extract typed fields from nested JSON events

Create the target table​

This example extracts selected nested fields into typed columns. You can instead use VARIANT columns when you need to retain changing nested attributes.

CREATE DATABASE IF NOT EXISTS log_db;
USE log_db;

CREATE TABLE logstash_github_events (
created_at DATETIME,
id BIGINT,
type TEXT,
public BOOLEAN,
actor_id BIGINT,
actor_login TEXT,
repo_name TEXT,
payload TEXT,
INDEX idx_type (type) USING INVERTED,
INDEX idx_actor_login (actor_login) USING INVERTED,
INDEX idx_payload (payload) USING INVERTED
PROPERTIES("parser" = "unicode", "support_phrase" = "true")
)
DUPLICATE KEY(created_at)
DISTRIBUTED BY RANDOM BUCKETS 4;

The table is unpartitioned for historical sample replay. Configure retention before using it for continuous ingestion.

Prepare JSON data​

Save this synthetic record on a single line in a local file:

{"created_at":"2024-01-01T15:00:00Z","id":1,"type":"PushEvent","public":true,"actor":{"id":101,"login":"example-user"},"repo":{"name":"example/project"},"payload":{"size":1}}

For a larger public dataset, download and decompress an hourly file from GH Archive. If you use time partitions, create partitions that cover the archived timestamps before loading.

Configure and start Logstash​

Save this as logstash_github_events.conf, replacing the path and endpoint:

input {
file {
path => "/absolute/path/to/events.json"
start_position => "beginning"
codec => json
}
}

output {
if "_jsonparsefailure" not in [tags] {
doris {
http_hosts => ["https://<warehouse-host>:<https-port>"]
user => "${WAREHOUSE_SQL_USER}"
password => "${WAREHOUSE_SQL_PASSWORD}"
db => "log_db"
table => "logstash_github_events"
headers => {
"format" => "json"
"read_json_by_line" => "true"
}
mapping => {
"created_at" => "%{created_at}"
"id" => "%{id}"
"type" => "%{type}"
"public" => "%{public}"
"actor_id" => "%{[actor][id]}"
"actor_login" => "%{[actor][login]}"
"repo_name" => "%{[repo][name]}"
"payload" => "%{[payload]}"
}
}
} else {
stdout { codec => rubydebug }
}
}
"${LOGSTASH_HOME}/bin/logstash" --config.test_and_exit -f logstash_github_events.conf
"${LOGSTASH_HOME}/bin/logstash" -f logstash_github_events.conf

Verify the extracted values:

SELECT id, type, actor_login, repo_name
FROM log_db.logstash_github_events
ORDER BY created_at DESC
LIMIT 10;

Common errors​

SymptomCause and resolution
The doris output cannot be foundConfirm the plugin is installed in the same Logstash installation that starts the pipeline.
Unknown configuration parameterCheck the installed plugin version. Use log_progress_interval for progress logging.
Connection or TLS failureVerify the warehouse endpoint, DNS, routing, ingestion ports, and JVM certificate trust.
Authentication or load permission failureCheck the SQL credentials, keystore or environment substitution, and target table privileges.
Rows are filteredInspect the load result and error details. Check mapped names, timestamp formats, and partition coverage.
No new events appearCheck file permissions, saved offsets, parse-failure output, and plugin retry logs.

Cost and cleanup​

Continuous ingestion consumes warehouse storage and compute, and network transfer can incur charges. See Billing. Stop the test pipeline when finished. Drop only the sample tables you created and no longer need:

DROP TABLE log_db.logstash_app_logs;
DROP TABLE log_db.logstash_github_events;

Stopping Logstash does not delete warehouse data. Retain production tables and file input offset records.

Enter to send · Shift+Enter for a new line