fix: v1.86 (#9)
This commit is contained in:
parent
e78aad9501
commit
e9d70573a7
7 changed files with 43 additions and 50 deletions
2
go.mod
2
go.mod
|
@ -15,6 +15,6 @@ require (
|
|||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.45.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
)
|
||||
|
|
5
go.sum
5
go.sum
|
@ -8,6 +8,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
|||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
|
||||
|
@ -28,8 +29,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"type": "grafana",
|
||||
"id": "grafana",
|
||||
"name": "Grafana",
|
||||
"version": "10.1.5"
|
||||
"version": "10.2.0"
|
||||
},
|
||||
{
|
||||
"type": "panel",
|
||||
|
@ -137,7 +137,7 @@
|
|||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "10.1.5",
|
||||
"pluginVersion": "10.2.0",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
|
@ -206,7 +206,7 @@
|
|||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "10.1.5",
|
||||
"pluginVersion": "10.2.0",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
|
@ -275,7 +275,7 @@
|
|||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "10.1.5",
|
||||
"pluginVersion": "10.2.0",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
|
@ -344,7 +344,7 @@
|
|||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "10.1.5",
|
||||
"pluginVersion": "10.2.0",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
|
@ -521,7 +521,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"pluginVersion": "10.1.5",
|
||||
"pluginVersion": "10.2.0",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
|
@ -552,6 +552,7 @@
|
|||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
|
@ -632,7 +633,7 @@
|
|||
"exemplar": false,
|
||||
"expr": "immich_user_usage",
|
||||
"instant": false,
|
||||
"legendFormat": "{{firstname}} {{lastname}}",
|
||||
"legendFormat": "{{name}}",
|
||||
"range": true,
|
||||
"refId": "A"
|
||||
}
|
||||
|
@ -651,6 +652,7 @@
|
|||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
|
@ -865,7 +867,7 @@
|
|||
"exemplar": false,
|
||||
"expr": "immich_user_usage",
|
||||
"instant": true,
|
||||
"legendFormat": "{{firstname}} {{lastname}}",
|
||||
"legendFormat": "{{name}}",
|
||||
"range": false,
|
||||
"refId": "A"
|
||||
}
|
||||
|
@ -874,9 +876,8 @@
|
|||
"type": "piechart"
|
||||
}
|
||||
],
|
||||
"refresh": "5m",
|
||||
"refresh": "auto",
|
||||
"schemaVersion": 38,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
|
@ -889,6 +890,6 @@
|
|||
"timezone": "",
|
||||
"title": "Immich Go",
|
||||
"uid": "9QXCv3AVk",
|
||||
"version": 4,
|
||||
"version": 5,
|
||||
"weekStart": ""
|
||||
}
|
|
@ -28,9 +28,7 @@ func main() {
|
|||
log.Info("Started")
|
||||
http.HandleFunc("/metrics", metrics)
|
||||
addr := ":" + strconv.Itoa(models.GetPort())
|
||||
if models.GetPort() != DEFAULTPORT {
|
||||
log.Info("Listening on port ", models.GetPort())
|
||||
}
|
||||
http.ListenAndServe(addr, nil)
|
||||
}
|
||||
|
||||
|
@ -40,7 +38,6 @@ func metrics(w http.ResponseWriter, r *http.Request) {
|
|||
immich.Allrequests(registry)
|
||||
h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
|
||||
h.ServeHTTP(w, r)
|
||||
|
||||
}
|
||||
|
||||
func projectinfo() {
|
||||
|
|
|
@ -6,8 +6,7 @@ type StructLogin struct {
|
|||
AccessToken string `json:"accessToken"`
|
||||
UserID string `json:"userId"`
|
||||
UserEmail string `json:"userEmail"`
|
||||
FirstName string `json:"firstName"`
|
||||
LastName string `json:"lastName"`
|
||||
Name string `json:"name"`
|
||||
IsAdmin bool `json:"isAdmin"`
|
||||
ShouldChangePassword bool `json:"shouldChangePassword"`
|
||||
}
|
||||
|
@ -18,8 +17,7 @@ type StructServerInfo struct {
|
|||
Usage int64 `json:"usage"`
|
||||
UsageByUser []struct {
|
||||
UserID string `json:"userId"`
|
||||
UserFirstName string `json:"userFirstName"`
|
||||
UserLastName string `json:"userLastName"`
|
||||
UserName string `json:"userName"`
|
||||
Photos int `json:"photos"`
|
||||
Videos int `json:"videos"`
|
||||
Usage int `json:"usage"`
|
||||
|
@ -45,8 +43,7 @@ type StructServerVersion struct {
|
|||
type StructAllUsers []struct {
|
||||
ID string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
FirstName string `json:"firstName"`
|
||||
LastName string `json:"lastName"`
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
ProfileImagePath string `json:"profileImagePath"`
|
||||
ShouldChangePassword bool `json:"shouldChangePassword"`
|
||||
|
@ -58,7 +55,6 @@ type StructAllUsers []struct {
|
|||
type StructCustomUser struct {
|
||||
Email string
|
||||
ID string
|
||||
FirstName string
|
||||
LastName string
|
||||
Name string
|
||||
IsAdmin bool
|
||||
}
|
||||
|
|
|
@ -28,20 +28,20 @@ func SendBackMessagePreference(result *models.StructServerInfo, result2 *models.
|
|||
user_info := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "immich_user_info",
|
||||
Help: "All infos about users",
|
||||
}, []string{"videos", "photos", "uid", "usage", "firstname", "lastname"})
|
||||
}, []string{"videos", "photos", "uid", "usage", "name"})
|
||||
|
||||
user_usage := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "immich_user_usage",
|
||||
Help: "The usage of the user",
|
||||
}, []string{"uid", "firstname", "lastname"})
|
||||
}, []string{"uid", "name"})
|
||||
user_photos := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "immich_user_photos",
|
||||
Help: "The number of photo of the user",
|
||||
}, []string{"uid", "firstname", "lastname"})
|
||||
}, []string{"uid", "name"})
|
||||
user_videos := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "immich_user_videos",
|
||||
Help: "The number of videos of the user",
|
||||
}, []string{"uid", "firstname", "lastname"})
|
||||
}, []string{"uid", "name"})
|
||||
|
||||
r.MustRegister(user_info)
|
||||
r.MustRegister(user_usage)
|
||||
|
@ -50,10 +50,10 @@ func SendBackMessagePreference(result *models.StructServerInfo, result2 *models.
|
|||
|
||||
for i := 0; i < len((*result).UsageByUser); i++ {
|
||||
var myuser = GetName((*result).UsageByUser[i].UserID, result2)
|
||||
user_info.With(prometheus.Labels{"videos": strconv.Itoa((*result).UsageByUser[i].Videos), "photos": strconv.Itoa((*result).UsageByUser[i].Photos), "uid": (*result).UsageByUser[i].UserID, "usage": strconv.Itoa(int((*result).UsageByUser[i].Usage)), "firstname": myuser.FirstName, "lastname": myuser.LastName}).Inc()
|
||||
user_photos.With(prometheus.Labels{"uid": (*result).UsageByUser[i].UserID, "firstname": myuser.FirstName, "lastname": myuser.LastName}).Set(float64((*result).UsageByUser[i].Photos))
|
||||
user_usage.With(prometheus.Labels{"uid": (*result).UsageByUser[i].UserID, "firstname": myuser.FirstName, "lastname": myuser.LastName}).Set(float64((*result).UsageByUser[i].Usage))
|
||||
user_videos.With(prometheus.Labels{"uid": (*result).UsageByUser[i].UserID, "firstname": myuser.FirstName, "lastname": myuser.LastName}).Set(float64((*result).UsageByUser[i].Videos))
|
||||
user_info.With(prometheus.Labels{"videos": strconv.Itoa((*result).UsageByUser[i].Videos), "photos": strconv.Itoa((*result).UsageByUser[i].Photos), "uid": (*result).UsageByUser[i].UserID, "usage": strconv.Itoa(int((*result).UsageByUser[i].Usage)), "name": myuser.Name}).Inc()
|
||||
user_photos.With(prometheus.Labels{"uid": (*result).UsageByUser[i].UserID, "name": myuser.Name}).Set(float64((*result).UsageByUser[i].Photos))
|
||||
user_usage.With(prometheus.Labels{"uid": (*result).UsageByUser[i].UserID, "name": myuser.Name}).Set(float64((*result).UsageByUser[i].Usage))
|
||||
user_videos.With(prometheus.Labels{"uid": (*result).UsageByUser[i].UserID, "name": myuser.Name}).Set(float64((*result).UsageByUser[i].Videos))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,8 +78,7 @@ func GetName(result string, result2 *models.StructAllUsers) models.StructCustomU
|
|||
if (*result2)[i].ID == result {
|
||||
|
||||
myuser.ID = (*result2)[i].ID
|
||||
myuser.FirstName = (*result2)[i].FirstName
|
||||
myuser.LastName = (*result2)[i].LastName
|
||||
myuser.Name = (*result2)[i].Name
|
||||
myuser.Email = (*result2)[i].Email
|
||||
myuser.IsAdmin = (*result2)[i].IsAdmin
|
||||
}
|
||||
|
|
|
@ -9,15 +9,14 @@ import (
|
|||
|
||||
func TestGetName(t *testing.T) {
|
||||
result2 := &models.StructAllUsers{
|
||||
{ID: "1", FirstName: "John", LastName: "Doe", Email: "john@example.com", IsAdmin: true},
|
||||
{ID: "2", FirstName: "Jane", LastName: "Smith", Email: "jane@example.com", IsAdmin: false},
|
||||
{ID: "1", Name: "John", Email: "john@example.com", IsAdmin: true},
|
||||
{ID: "2", Name: "Jane", Email: "jane@example.com", IsAdmin: false},
|
||||
}
|
||||
|
||||
result := "1"
|
||||
expected := models.StructCustomUser{
|
||||
ID: "1",
|
||||
FirstName: "John",
|
||||
LastName: "Doe",
|
||||
Name: "John",
|
||||
Email: "john@example.com",
|
||||
IsAdmin: true,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue