I’m trying to have Telegraf parse the log file of the local Snowflake instance. It usually looks like this:
nohup: Input is ignored
2023/07/24 20:09:24 Proxy starting
2023/07/24 20:10:19 NAT type: restricted
2023/07/24 21:11:24 In the last 1h0m0s, there were 3 connections. Traffic Relayed ↓ 69528 KB, ↑ 2418 KB.
2023/07/24 22:11:24 In the last 1h0m0s, there were 13 connections. Traffic Relayed ↓ 622101 KB, ↑ 46242 KB.
2023/07/24 23:51:55 In the last 1h0m0s, there were 4 connections. Traffic Relayed ↓ 23649 KB, ↑ 5311 KB.
2023/07/25 00:51:55 In the last 1h0m0s, there were 7 connections. Traffic Relayed ↓ 123722 KB, ↑ 11554 KB.
2023/07/25 01:51:55 In the last 1h0m0s, there were 2 connections. Traffic Relayed ↓ 124297 KB, ↑ 5029 KB.
Here’s my current config:
[[inputs.tail]]
# file(s) to tail:
files = ["~/snowflake/proxy/snowflake.log"]
from_beginning = false
# name of the "Metric" (which I want to see in Grafana eventually)
name_override = "snowflake_log"
grok_patterns = ["%{CUSTOM_LOG}"]
grok_custom_patterns = '''
SNOWFLAKEDATE %{YEAR}/%{MONTHNUM}/%{MONTHDAY} %{TIME}
CUSTOM_LOG %{SNOWFLAKEDATE:date} In the last 1h0m0s, there were %{NUMBER:snowflake_connections:int} connections. Traffic Relayed ↓ %{NUMBER:snowflake_downstream:int} KB, ↑ %{NUMBER:snowflake_upstream:int} KB.
'''
data_format = "grok"
How can I tell Telegraf to ignore lines that include any of the following keywords?
nohup:
Proxy starting
NAT type:
Sometimes, however, there are also errors that include phrases like stream not found
. How can I tell Telegraf to use the value 0
for snowflake_connections
, snowflake_downstream
and snowflake_upstream
if the log line contains the phrase stream not found
?
Thank you!