-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Some Prometheus Metrics To Lookout (#3781)
* Better metrics for lookout Signed-off-by: Chris Martin <chris@cmartinit.co.uk> * lint Signed-off-by: Chris Martin <chris@cmartinit.co.uk> * add service monitor Signed-off-by: Chris Martin <chris@cmartinit.co.uk> --------- Signed-off-by: Chris Martin <chris@cmartinit.co.uk> Co-authored-by: Chris Martin <chris@cmartinit.co.uk>
- Loading branch information
Showing
8 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
apiPort: 10000 | ||
metricsPort: 9003 | ||
corsAllowedOrigins: | ||
- "http://localhost:3000" | ||
- "http://localhost:8089" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{- if .Values.prometheus.enabled }} | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
name: {{ include "lookout_v2.name" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "lookout_v2.name.labels.all" . | nindent 4 -}} | ||
{{- if .Values.prometheus.labels }} | ||
{{- toYaml .Values.prometheus.labels | nindent 4 -}} | ||
{{- end }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
{{- include "lookout_v2.name.labels.identity" . | nindent 6 }} | ||
endpoints: | ||
- port: metrics | ||
interval: {{ .Values.prometheus.scrapeInterval }} | ||
scrapeTimeout: {{ .Values.prometheus.scrapeTimeout }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package metrics | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
) | ||
|
||
var requestDuration = promauto.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Name: "lookout_request_duration_ms", | ||
Help: "Request duration in milliseconds", | ||
Buckets: []float64{1, 10, 100, 1000, 10000, 100000, 1000000}, | ||
}, | ||
[]string{"user", "endpoint"}, | ||
) | ||
|
||
func RecordRequestDuration(user, endpoint string, duration float64) { | ||
requestDuration. | ||
With(map[string]string{"user": user, "endpoint": endpoint}). | ||
Observe(duration) | ||
} |