db.Use(prometheus.New(prometheus.Config{ DBName: "db1", // use `DBName` as metrics label RefreshInterval: 15, // Refresh metrics interval (default 15 seconds) PushAddr: "prometheus pusher address", // push metrics if `PushAddr` configured StartServer: true, // start http server to expose metrics HTTPServerPort: 8080, // configure http server port, default port 8080 (if you have configured multiple instances, only the first `HTTPServerPort` will be used to start server) MetricsCollector: []prometheus.MetricsCollector { &prometheus.MySQL{ VariableNames: []string{"Threads_running"}, }, }, // user defined metrics }))
&prometheus.MySQL{ Prefix: "gorm_status_", // Metrics name prefix, default is `gorm_status_` // For example, Threads_running's metric name is `gorm_status_Threads_running` Interval: 100, // Fetch interval, default use Prometheus's RefreshInterval VariableNames: []string{"Threads_running"}, // Select variables from SHOW STATUS, if not set, uses all status variables }