Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flusher-clickhouse不刷日志 #1202

Closed
starriesWEB opened this issue Oct 25, 2023 · 8 comments
Closed

flusher-clickhouse不刷日志 #1202

starriesWEB opened this issue Oct 25, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@starriesWEB
Copy link

starriesWEB commented Oct 25, 2023

配置文件

flushers:
  - Type: flusher_clickhouse
    Addresses: ["127.0.0.1:9000"]
    Authentication:
      PlainText:
        Database: default
        Username: root
        Password: xxxx
    Table: blade_logs

在default数据库会自动生成2个表 ilogtail_blade_logsilogtail_blade_logs_buffer

  • ilogtail_blade_logs 表一直是空的,干什么用的
  • ilogtail_blade_logs_buffer 表的数据会减少,知道是buffer,但是buffer的log刷到哪里去了,是需要自己建一个配置文件中对应的表吗(blade_logs)
@starriesWEB starriesWEB added the bug Something isn't working label Oct 25, 2023
@starriesWEB starriesWEB changed the title [BUG]:flusher-clickhouse示例报错 [BUG]:flusher-clickhouse不刷日志 Oct 25, 2023
@kl7sn
Copy link
Collaborator

kl7sn commented Oct 26, 2023

#554
ilogtail_blade_logs 应该是一个 null 表,需要你自己创建物化视图和实际的数据落地表

@1018565530
Copy link

#554 ilogtail_blade_logs 应该是一个 null 表,需要你自己创建物化视图和实际的数据落地表

你好,这个有没有参考的配置

@starriesWEB
Copy link
Author

#554 ilogtail_blade_logs 应该是一个 null 表,需要你自己创建物化视图和实际的数据落地表

你好,这个有没有参考的配置

需要自己建2个表,一个物化表,一个数据表

CREATE TABLE blade
(
    log_time       DateTime,
    container_name String,
    host_ip        String,
    host_name      String,
    content        String
)
    ENGINE = MergeTree PARTITION BY toYYYYMMDD(log_time)
        PRIMARY KEY log_time
        ORDER BY (log_time, container_name)
        SETTINGS index_granularity = 8192;
CREATE MATERIALIZED VIEW default.blade_view
            TO default.blade
            (
             `log_time` String,
             `container_name` String,
             `host_ip` String,
             `host_name` String,
             `content` String
                )
AS
SELECT
    replaceAll(visitParamExtractRaw(_log, 'time'), '"', '') AS log_time,
    visitParamExtractRaw(_log, 'container.name')            AS container_name,
    visitParamExtractRaw(_log, 'host.ip')                   AS host_ip,
    visitParamExtractRaw(_log, 'host.name')                 AS host_name,
    visitParamExtractRaw(_log, 'content')                   AS content
FROM
    default.ilogtail_blade;

@1018565530
Copy link

#554 ilogtail_blade_logs 应该是一个 null 表,需要你自己创建物化视图和实际的数据落地表

你好,这个有没有参考的配置

需要自己建2个表,一个物化表,一个数据表

CREATE TABLE blade
(
    log_time       DateTime,
    container_name String,
    host_ip        String,
    host_name      String,
    content        String
)
    ENGINE = MergeTree PARTITION BY toYYYYMMDD(log_time)
        PRIMARY KEY log_time
        ORDER BY (log_time, container_name)
        SETTINGS index_granularity = 8192;
CREATE MATERIALIZED VIEW default.blade_view
            TO default.blade
            (
             `log_time` String,
             `container_name` String,
             `host_ip` String,
             `host_name` String,
             `content` String
                )
AS
SELECT
    replaceAll(visitParamExtractRaw(_log, 'time'), '"', '') AS log_time,
    visitParamExtractRaw(_log, 'container.name')            AS container_name,
    visitParamExtractRaw(_log, 'host.ip')                   AS host_ip,
    visitParamExtractRaw(_log, 'host.name')                 AS host_name,
    visitParamExtractRaw(_log, 'content')                   AS content
FROM
    default.ilogtail_blade;

针对单表现在能正常存储,使用匹配好像就有问题,麻烦大佬帮忙看看
enable: true
inputs:

  • Type: file_log
    LogPath: /data
    FilePattern: "....log"
    flushers:
  • Type: flusher_clickhouse
    Addresses:
    • xxxxx
      Authentication:
      PlainText:
      Database: xxxx
      Username: xxxxxx
      Password: xxxxx
      Table: xxxx_log

@starriesWEB
Copy link
Author

#554 ilogtail_blade_logs 应该是一个 null 表,需要你自己创建物化视图和实际的数据落地表

你好,这个有没有参考的配置

需要自己建2个表,一个物化表,一个数据表

CREATE TABLE blade
(
    log_time       DateTime,
    container_name String,
    host_ip        String,
    host_name      String,
    content        String
)
    ENGINE = MergeTree PARTITION BY toYYYYMMDD(log_time)
        PRIMARY KEY log_time
        ORDER BY (log_time, container_name)
        SETTINGS index_granularity = 8192;
CREATE MATERIALIZED VIEW default.blade_view
            TO default.blade
            (
             `log_time` String,
             `container_name` String,
             `host_ip` String,
             `host_name` String,
             `content` String
                )
AS
SELECT
    replaceAll(visitParamExtractRaw(_log, 'time'), '"', '') AS log_time,
    visitParamExtractRaw(_log, 'container.name')            AS container_name,
    visitParamExtractRaw(_log, 'host.ip')                   AS host_ip,
    visitParamExtractRaw(_log, 'host.name')                 AS host_name,
    visitParamExtractRaw(_log, 'content')                   AS content
FROM
    default.ilogtail_blade;

针对单表现在能正常存储,使用匹配好像就有问题,麻烦大佬帮忙看看 enable: true inputs:

  • Type: file_log
    LogPath: /data
    FilePattern: "....log"
    flushers:

  • Type: flusher_clickhouse
    Addresses:

    • xxxxx
      Authentication:
      PlainText:
      Database: xxxx
      Username: xxxxxx
      Password: xxxxx
      Table: xxxx_log

针对单表现在能正常存储,使用匹配好像就有问题,麻烦大佬帮忙看看。没明白啥意思

@1018565530
Copy link

CREATE MATERIALIZED VIEW

请问下 这个是一定需要的吗 CREATE MATERIALIZED VIEW, 这种看起来会存储2份数据

@starriesWEB
Copy link
Author

CREATE MATERIALIZED VIEW

请问下 这个是一定需要的吗 CREATE MATERIALIZED VIEW, 这种看起来会存储2份数据

https://clickhouse.com/docs/en/engines/table-engines/special/null
需要物化表来接收null表的数据,并且使用物化表来进行过滤(取出自己想要的数据)

@starriesWEB starriesWEB changed the title [BUG]:flusher-clickhouse不刷日志 flusher-clickhouse不刷日志 Nov 3, 2023
@kl7sn
Copy link
Collaborator

kl7sn commented Nov 21, 2023

CREATE MATERIALIZED VIEW

请问下 这个是一定需要的吗 CREATE MATERIALIZED VIEW, 这种看起来会存储2份数据

null 表是临时表,不存储数据,最后物化视图的目标表进行存储

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants