本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
常見的處理器使用案例
以下是合併處理器的常見案例和範例組態:
範例 標準化日誌格式並新增中繼資料
剖析 JSON 日誌、標準化欄位名稱,以及新增環境資訊:
processor: - parse_json: {} - rename_keys: entries: - from_key: "timestamp" to_key: "@timestamp" - from_key: "log_level" to_key: "level" - add_entries: entries: - key: "environment" value: "production" - key: "application" value: "payment-service"
範例 清除和標準化欄位值
標準化狀態碼並移除敏感資料:
processor: - uppercase_string: with_keys: ["status", "method"] - delete_entries: with_keys: ["credit_card", "password"] - substitute_string: entries: - source: "status" from: "SUCCESS" to: "OK"
範例 擷取和轉換特定欄位
擷取用於分析的使用者資訊和格式:
processor: - extract_value: entries: - source: "user_agent" target: "browser" from: "(?<browser>Chrome|Firefox|Safari)" to: "${browser}" - lowercase_string: with_keys: ["browser"] - move_keys: entries: - from_key: "browser" to_key: "user_data.browser"