mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 06:22:13 +08:00
Backend Plugins: Collect and expose metrics and plugin process health check (#21481)
Adds support for collecting metrics from backend plugins and exposing them thru Grafana's Prometheus metrics endpoint. Enables to check health of backend plugin by using the route `/api/plugins/<plugin id>/health`. Uses sdk v0.6.0. Closes #20984
This commit is contained in:

committed by
GitHub

parent
f56f54b1a3
commit
5c711bfb79
@ -148,6 +148,8 @@ var (
|
||||
|
||||
// grafanaBuildVersion is a metric with a constant '1' value labeled by version, revision, branch, and goversion from which Grafana was built
|
||||
grafanaBuildVersion *prometheus.GaugeVec
|
||||
|
||||
grafanPluginBuildInfoDesc *prometheus.GaugeVec
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -422,6 +424,12 @@ func init() {
|
||||
Help: "A metric with a constant '1' value labeled by version, revision, branch, and goversion from which Grafana was built",
|
||||
Namespace: exporterName,
|
||||
}, []string{"version", "revision", "branch", "goversion", "edition"})
|
||||
|
||||
grafanPluginBuildInfoDesc = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "plugin_build_info",
|
||||
Help: "A metric with a constant '1' value labeled by pluginId, pluginType and version from which Grafana plugin was built",
|
||||
Namespace: exporterName,
|
||||
}, []string{"plugin_id", "plugin_type", "version"})
|
||||
}
|
||||
|
||||
// SetBuildInformation sets the build information for this binary
|
||||
@ -434,6 +442,10 @@ func SetBuildInformation(version, revision, branch string) {
|
||||
grafanaBuildVersion.WithLabelValues(version, revision, branch, runtime.Version(), edition).Set(1)
|
||||
}
|
||||
|
||||
func SetPluginBuildInformation(pluginID, pluginType, version string) {
|
||||
grafanPluginBuildInfoDesc.WithLabelValues(pluginID, pluginType, version).Set(1)
|
||||
}
|
||||
|
||||
func initMetricVars() {
|
||||
prometheus.MustRegister(
|
||||
MInstanceStart,
|
||||
@ -480,6 +492,7 @@ func initMetricVars() {
|
||||
StatsTotalActiveEditors,
|
||||
StatsTotalActiveAdmins,
|
||||
grafanaBuildVersion,
|
||||
grafanPluginBuildInfoDesc,
|
||||
)
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user