<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Prometheus GORM 提供了 Prometheus 插件來收集 [DBStats](https://pkg.go.dev/database/sql?tab=doc#DBStats) 和用戶自定義指標 https://github.com/go-gorm/prometheus ## 用法 ```go import ( "gorm.io/gorm" "gorm.io/driver/sqlite" "gorm.io/plugin/prometheus" ) db, err := gorm.Open(sqlite.Open("gorm.db"), &gorm.Config{}) db.Use(prometheus.New(prometheus.Config{ DBName: "db1", // 使用 `DBName` 作為指標 label RefreshInterval: 15, // 指標刷新頻率(默認為 15 秒) PushAddr: "prometheus pusher address", // 如果配置了 `PushAddr`,則推送指標 StartServer: true, // 啟用一個 http 服務來暴露指標 HTTPServerPort: 8080, // 配置 http 服務監聽端口,默認端口為 8080 (如果您配置了多個,只有第一個 `HTTPServerPort` 會被使用) MetricsCollector: []prometheus.MetricsCollector { &prometheus.MySQL{ VariableNames: []string{"Threads_running"}, }, }, // 用戶自定義指標 })) ``` ## 用戶自定義指標 您可以通過 GORM Prometheus 插件定義并收集自定義的指標,這需要實現 `MetricCollector` 接口 ```go type MetricsCollector interface { Metrics(*Prometheus) []prometheus.Collector } ``` ### MySQL GORM 提供了一個示例,說明如何收集 MySQL 狀態指標,查看 [prometheus.MySQL](https://github.com/go-gorm/prometheus/blob/master/mysql.go) 獲取詳情 ```go &prometheus.MySQL{ // 指標名前綴,默認為 `gorm_status_` // 例如: Threads_running 的指標名就是 `gorm_status_Threads_running` Prefix: "gorm_status_", // 拉取頻率,默認使用 Prometheus 的 RefreshInterval Interval: 100, // 從 SHOW STATUS 選擇變量變量,如果不設置,則使用全部的狀態變量 VariableNames: []string{"Threads_running"}, } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看