This is an automated email from the ASF dual-hosted git repository.
Duansg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push:
new 1429115282 [improve] pre-create hertzbeat_logs table during greptime
signal initialization (#4231)
1429115282 is described below
commit 1429115282d19e037fa57bc65792b65f3bcd3fa9
Author: Duansg <[email protected]>
AuthorDate: Thu Jul 23 11:34:35 2026 +0800
[improve] pre-create hertzbeat_logs table during greptime signal
initialization (#4231)
---
.../log/config/GreptimeSignalInitializer.java | 4 +++
.../resources/greptime/tables/hertzbeat_logs.sql | 32 ++++++++++++++++++++++
.../log/config/GreptimeSignalInitializerTest.java | 2 ++
3 files changed, 38 insertions(+)
diff --git
a/hertzbeat-log/src/main/java/org/apache/hertzbeat/log/config/GreptimeSignalInitializer.java
b/hertzbeat-log/src/main/java/org/apache/hertzbeat/log/config/GreptimeSignalInitializer.java
index d6b2bc2422..24c8725457 100644
---
a/hertzbeat-log/src/main/java/org/apache/hertzbeat/log/config/GreptimeSignalInitializer.java
+++
b/hertzbeat-log/src/main/java/org/apache/hertzbeat/log/config/GreptimeSignalInitializer.java
@@ -44,6 +44,7 @@ import org.springframework.web.client.RestTemplate;
public class GreptimeSignalInitializer {
private static final String TRACE_SCHEMA =
"greptime/tables/hzb_traces.sql";
+ private static final String LOG_SCHEMA =
"greptime/tables/hertzbeat_logs.sql";
private static final String LOG_PIPELINE =
"greptime/pipelines/hertzbeat_otlp_log_v1.yaml";
private final GreptimeProperties greptimeProperties;
private final GreptimeSqlQueryExecutor sqlQueryExecutor;
@@ -68,6 +69,9 @@ public class GreptimeSignalInitializer {
+ "\"resource_attributes.service.namespace\" STRING NULL");
sqlQueryExecutor.execute("ALTER TABLE hzb_traces ADD COLUMN IF NOT
EXISTS "
+ "\"resource_attributes.deployment.environment.name\"
STRING NULL");
+ String logSchema = new ClassPathResource(LOG_SCHEMA)
+ .getContentAsString(StandardCharsets.UTF_8).strip();
+
sqlQueryExecutor.execute(StringUtils.trimTrailingCharacter(logSchema, ';'));
uploadLogPipeline(new ClassPathResource(LOG_PIPELINE)
.getContentAsString(StandardCharsets.UTF_8));
if (sqlQueryExecutor.execute("SELECT 1 AS ready").isEmpty()) {
diff --git
a/hertzbeat-log/src/main/resources/greptime/tables/hertzbeat_logs.sql
b/hertzbeat-log/src/main/resources/greptime/tables/hertzbeat_logs.sql
new file mode 100644
index 0000000000..ea5c4d25f1
--- /dev/null
+++ b/hertzbeat-log/src/main/resources/greptime/tables/hertzbeat_logs.sql
@@ -0,0 +1,32 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+-- Schema must stay in sync with the transform section of
+-- greptime/pipelines/hertzbeat_otlp_log_v1.yaml, which GreptimeDB would
+-- otherwise use to auto-create this table on first ingestion.
+CREATE TABLE IF NOT EXISTS hertzbeat_logs (
+ "time_unix_nano" TIMESTAMP(9) TIME INDEX,
+ "observed_time_unix_nano" TIMESTAMP(9) NULL,
+ "trace_id" STRING NULL SKIPPING INDEX WITH(granularity = '10240', type =
'BLOOM'),
+ "span_id" STRING NULL SKIPPING INDEX WITH(granularity = '10240', type =
'BLOOM'),
+ "trace_flags" INT NULL,
+ "severity_text" STRING NULL,
+ "severity_number" INT NULL,
+ "body" STRING NULL,
+ "attributes" JSON NULL,
+ "resource" JSON NULL,
+ "instrumentation_scope" JSON NULL,
+ "dropped_attributes_count" INT NULL
+) WITH (append_mode = true);
diff --git
a/hertzbeat-log/src/test/java/org/apache/hertzbeat/log/config/GreptimeSignalInitializerTest.java
b/hertzbeat-log/src/test/java/org/apache/hertzbeat/log/config/GreptimeSignalInitializerTest.java
index 840d184f4c..1d21fc7a63 100644
---
a/hertzbeat-log/src/test/java/org/apache/hertzbeat/log/config/GreptimeSignalInitializerTest.java
+++
b/hertzbeat-log/src/test/java/org/apache/hertzbeat/log/config/GreptimeSignalInitializerTest.java
@@ -76,6 +76,8 @@ class GreptimeSignalInitializerTest {
"ALTER TABLE hzb_traces ADD COLUMN IF NOT EXISTS
\"resource_attributes.service.namespace\""));
sqlOrder.verify(sqlQueryExecutor).execute(org.mockito.ArgumentMatchers.startsWith(
"ALTER TABLE hzb_traces ADD COLUMN IF NOT EXISTS
\"resource_attributes.deployment.environment.name\""));
+
sqlOrder.verify(sqlQueryExecutor).execute(org.mockito.ArgumentMatchers.contains(
+ "CREATE TABLE IF NOT EXISTS hertzbeat_logs"));
sqlOrder.verify(sqlQueryExecutor).execute("SELECT 1 AS ready");
verify(restTemplate).exchange(eq("http://127.0.0.1:4000/v1/pipelines/hertzbeat_otlp_log_v1"),
eq(HttpMethod.POST), any(HttpEntity.class), eq(String.class));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]