Basic Prometheus metrics #7
|
@ -75,7 +75,7 @@ var (
|
||||||
pasteViews = promauto.NewCounterVec(prometheus.CounterOpts{
|
pasteViews = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||||
Name: "tclip_paste_views",
|
Name: "tclip_paste_views",
|
||||||
Help: "Number of times a paste has been viewed",
|
Help: "Number of times a paste has been viewed",
|
||||||
}, []string{"id", "origin", "type"})
|
}, []string{"id", "origin"})
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataLocation() string {
|
func dataLocation() string {
|
||||||
|
@ -590,7 +590,7 @@ WHERE p.id = $1`
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprint(w, data)
|
fmt.Fprint(w, data)
|
||||||
|
|
||||||
pasteViews.With(prometheus.Labels{"id": id, "origin": origin, "type": "raw"}).Inc()
|
pasteViews.With(prometheus.Labels{"id": id, "origin": origin}).Inc()
|
||||||
|
|
||||||
return
|
return
|
||||||
// download file to disk (plain text view plus download hint)
|
// download file to disk (plain text view plus download hint)
|
||||||
|
@ -601,7 +601,7 @@ WHERE p.id = $1`
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprint(w, data)
|
fmt.Fprint(w, data)
|
||||||
pasteViews.With(prometheus.Labels{"id": id, "origin": origin, "type": "download"}).Inc()
|
pasteViews.With(prometheus.Labels{"id": id, "origin": origin}).Inc()
|
||||||
|
|
||||||
return
|
return
|
||||||
case "":
|
case "":
|
||||||
|
@ -625,7 +625,7 @@ WHERE p.id = $1`
|
||||||
title = ogTitle
|
title = ogTitle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pasteViews.With(prometheus.Labels{"id": id, "origin": origin, "type": "fancy"}).Inc()
|
pasteViews.With(prometheus.Labels{"id": id, "origin": origin}).Inc()
|
||||||
|
|
||||||
err = s.tmpls.ExecuteTemplate(w, "fancypost.html", struct {
|
err = s.tmpls.ExecuteTemplate(w, "fancypost.html", struct {
|
||||||
Title string
|
Title string
|
||||||
|
@ -658,7 +658,7 @@ WHERE p.id = $1`
|
||||||
remoteUserID = up.ID
|
remoteUserID = up.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
pasteViews.With(prometheus.Labels{"id": id, "origin": origin, "type": "normal"}).Inc()
|
pasteViews.With(prometheus.Labels{"id": id, "origin": origin}).Inc()
|
||||||
|
|
||||||
err = s.tmpls.ExecuteTemplate(w, "showpaste.html", struct {
|
err = s.tmpls.ExecuteTemplate(w, "showpaste.html", struct {
|
||||||
UserInfo *tailcfg.UserProfile
|
UserInfo *tailcfg.UserProfile
|
||||||
|
|
|
@ -164,7 +164,7 @@
|
||||||
"axisPlacement": "auto",
|
"axisPlacement": "auto",
|
||||||
"barAlignment": 0,
|
"barAlignment": 0,
|
||||||
"drawStyle": "line",
|
"drawStyle": "line",
|
||||||
"fillOpacity": 0,
|
"fillOpacity": 5,
|
||||||
"gradientMode": "none",
|
"gradientMode": "none",
|
||||||
"hideFrom": {
|
"hideFrom": {
|
||||||
"legend": false,
|
"legend": false,
|
||||||
|
@ -229,9 +229,9 @@
|
||||||
"uid": "${DS_PROMETHEUS}"
|
"uid": "${DS_PROMETHEUS}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum(tclip_paste_views{origin=~\"$origin\"}) by (id, type)",
|
"expr": "sum(tclip_paste_views{origin=~\"$origin\"}) by (id)",
|
||||||
"instant": false,
|
"instant": false,
|
||||||
"legendFormat": "{{id}} ({{type}})",
|
"legendFormat": "{{id}}",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
}
|
}
|
||||||
|
@ -1284,6 +1284,10 @@
|
||||||
{
|
{
|
||||||
"allValue": ".*",
|
"allValue": ".*",
|
||||||
"current": {},
|
"current": {},
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${DS_PROMETHEUS}"
|
||||||
|
},
|
||||||
"definition": "label_values(tclip_paste_views,origin)",
|
"definition": "label_values(tclip_paste_views,origin)",
|
||||||
"hide": 0,
|
"hide": 0,
|
||||||
"includeAll": true,
|
"includeAll": true,
|
||||||
|
@ -1331,6 +1335,6 @@
|
||||||
"timezone": "browser",
|
"timezone": "browser",
|
||||||
"title": "tclip",
|
"title": "tclip",
|
||||||
"uid": "ypFZFgvmz",
|
"uid": "ypFZFgvmz",
|
||||||
"version": 16,
|
"version": 17,
|
||||||
"weekStart": ""
|
"weekStart": ""
|
||||||
}
|
}
|
Loading…
Reference in a new issue