Skip to content

Commit 2f5aaa2

Browse files
committed
Ingest log lines starting with at=error
This is an initial step in adding metrics for the errors identified in rust-lang#3.
1 parent 92649e3 commit 2f5aaa2

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

src/vector.toml

+48-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ query_parameters = ["app_name"]
1818
# Publish all the collected metrics as a Prometheus exporter.
1919
[sinks.prometheus]
2020
type = "prometheus_exporter"
21-
inputs = ["self", "heroku-postgres", "ingested-metrics"]
21+
inputs = ["self", "heroku-postgres", "ingested-metrics", "heroku-log-error"]
2222
address = "0.0.0.0:8002"
2323
# Long flush period needed due to Heroku Postgres's log frequency:
2424
flush_period_secs = 600
@@ -113,3 +113,50 @@ function (event, emit)
113113
end
114114
end
115115
'''
116+
117+
##########################
118+
# Heroku Log Metrics #
119+
##########################
120+
121+
# Heroku platform and application errors use a common `at=error ` prefix for
122+
# easy log ingestion.
123+
124+
[transforms.heroku-log-error-filter]
125+
type = "filter"
126+
inputs = ["heroku"]
127+
condition = 'starts_with(.message, "at=error ") ?? false'
128+
129+
[transforms.heroku-log-error]
130+
type = "lua"
131+
version = "2"
132+
inputs = ["heroku-log-error-filter"]
133+
hooks.process = '''
134+
function (event, emit)
135+
emit({
136+
["metric"] = {
137+
["counter"] = {
138+
["value"] = 1,
139+
},
140+
["kind"] = "absolute",
141+
["name"] = "error",
142+
["namespace"] = "heroku_logs",
143+
}
144+
})
145+
146+
for key, value in event.log.message:gmatch("(code|method|mod|status)=([^ ]+)") do
147+
emit({
148+
["metric"] = {
149+
["counter"] = {
150+
["value"] = 1,
151+
},
152+
["kind"] = "absolute",
153+
["name"] = key,
154+
["namespace"] = "heroku_logs",
155+
["tags"] = {
156+
[key] = value,
157+
},
158+
}
159+
})
160+
end
161+
end
162+
'''

0 commit comments

Comments
 (0)