Skip to content

Commit

Permalink
Metrics: add errors
Browse files Browse the repository at this point in the history
  • Loading branch information
0SkillAllLuck committed Apr 9, 2020
1 parent 94a2390 commit c2b56c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ var (
},
[]string{"route"},
)
metricsErrors = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "qumine_ingress_errors_total",
Help: "The total error count",
},
[]string{"error"},
)
metricsBytes = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "qumine_ingress_bytes_total",
Expand Down
2 changes: 2 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (server *Server) findAndConnectBackend(context context.Context, client net.
route, err := ReadRoute(hostname)
if err != nil {
logrus.WithError(err).Warn("no matching route found")
metricsConnections.With(prometheus.Labels{"error": "no route found"}).Inc()
return
}
logrus.WithFields(logrus.Fields{
Expand All @@ -154,6 +155,7 @@ func (server *Server) findAndConnectBackend(context context.Context, client net.
"client": client.RemoteAddr(),
"route": route,
}).Error("connecting to upstream failed")
metricsConnections.With(prometheus.Labels{"error": "coonection failed"}).Inc()
return
}
defer metricsConnections.With(prometheus.Labels{"route": route}).Dec()
Expand Down

0 comments on commit c2b56c0

Please sign in to comment.