How to match multi-line text in mtail (e.g., for PostgreSQL CSV logs with multi-line statements)

Đang mở
#970 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
postgresql
Lĩnh vực
observability

Hướng nghiên cứu

Bắt đầu bằng việc xem xét quá trình xử lý log theo từng dòng của mtail và mọi tài liệu hiện có về việc khớp nhiều dòng hoặc buffering. Sử dụng ví dụ CSV của PostgreSQL để xác định xem có thể tích lũy các câu lệnh nhiều dòng hay không; công việc được xem là hoàn tất khi có một cách tiếp cận được hỗ trợ và được tài liệu hóa, hoặc một giải pháp thay thế được mô tả rõ ràng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I'm currently working on monitoring PostgreSQL logs in CSV format using mtail. One challenge is that SQL statements in the statement field may span multiple lines. This makes it difficult to extract meaningful labels or metrics using mtail, since it appears to process logs line-by-line.

For example, a single statement field in a PostgreSQL log might contain embedded newlines like this:

2025-06-26 01:47:40.578 CST,,,2348220,,685c3414.23d4bc,1,,2025-06-26 01:38:28 CST,509/2455864,0,LOG,00000,"automatic vacuum of table ""bdc.pg_catalog.pg_attribute"": index scans: 1
pages: 0 removed, 2420645 remain, 0 skipped due to pins, 2391644 skipped frozen
tuples: 18257 removed, 1605338 remain, 1419055 are dead but not yet removable, oldest xmin: 3862849561
buffer usage: 1441377 hits, 1443437 misses, 2468 dirtied
avg read rate: 22.069 MB/s, avg write rate: 0.038 MB/s
system usage: CPU: user: 9.42 s, system: 8.80 s, elapsed: 510.99 s",,,,,,,,,""

I’m wondering:

  • Does mtail support any way to accumulate or buffer multiple lines to allow multi-line matching?
  • If not directly supported, are there recommended workarounds for this scenario?

This would be very helpful when we want to extract meaningful metrics or tags (e.g., command type, table name) from full SQL statements for observability purposes.

Thanks in advance for your guidance!

Ngôn ngữ chính
Go
Star
4k
Fork
396
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.