File tree 1 file changed +48
-1
lines changed
1 file changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ query_parameters = ["app_name"]
18
18
# Publish all the collected metrics as a Prometheus exporter.
19
19
[sinks .prometheus ]
20
20
type = " prometheus_exporter"
21
- inputs = [" self" , " heroku-postgres" , " ingested-metrics" ]
21
+ inputs = [" self" , " heroku-postgres" , " ingested-metrics" , " heroku-log-error " ]
22
22
address = " 0.0.0.0:8002"
23
23
# Long flush period needed due to Heroku Postgres's log frequency:
24
24
flush_period_secs = 600
@@ -113,3 +113,50 @@ function (event, emit)
113
113
end
114
114
end
115
115
'''
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
+ '''
You can’t perform that action at this time.
0 commit comments