June 9, 2025
greptimedb
store logs into a analytical database..
-
use the free homeuser plan with greptimedb cloud, see https://docs.greptime.com/
-
create a new database
-
send logs with vector.dev, see https://vector.dev/docs/reference/configuration/sinks/greptimedb_logs/S
-
vector create the table and inserts rows into "demo_logs"
## logs
[sources.logs_in]
type = "demo_logs"
format = "json"
[transforms.logs_json]
type = "remap"
inputs = ["logs_in"]
source = '''
. = parse_json!(.message)
'''
[sinks.logs_out]
inputs = ["logs_json"]
type = "greptimedb_logs"
endpoint = "https://z9ckhxuvohe1.us-west-2.aws.greptime.cloud"
compression = "gzip"
dbname = "fill-in-here-public"
username = "fill-in-here"
password = "fill-in-here"
table = "demo_logs"
pipeline_name = "greptime_identity"
and view the data in the cloud: https://console.greptime.cloud/service/detail/17476
or create a table explicitly like:
$uri = "https://z9ckhxuvohe1.us-west-2.aws.greptime.cloud/v1/sql?db=fill-db-here"
$username = "fill-user-here"
$password = "fill-pw-here"
# Encode credentials as Base64
# Manually construct basic auth header
$pair = "$username`:$password"
$bytes = [System.Text.Encoding]::UTF8.GetBytes($pair)
$base64 = [Convert]::ToBase64String($bytes)
$headers = @{
"Content-Type" = "application/x-www-form-urlencoded"
"Authorization" = "Basic $base64"
}
# URL encode the SQL query
$sql = @"
CREATE TABLE simple_logs (
"timestamp" TIMESTAMP NOT NULL,
host STRING NOT NULL,
service STRING NOT NULL,
message STRING NOT NULL,
"level" STRING NOT NULL,
"file" STRING,
line INT,
TIME INDEX ("timestamp")
);
"@
$body = [System.Web.HttpUtility]::UrlEncode("sql") + "=" + [System.Web.HttpUtility]::UrlEncode($sql)
Invoke-WebRequest -Uri $uri `
-Method POST `
-Headers $headers `
-Body $body `
-UseBasicParsing
.