Files
grafana/pkg/services/dashboards/service/metrics.go
Alexander Zobnin 5d724c2482 Zanzana: Initial dashboard search (#93093)
* Zanzana: Search in a background and compare results

* refactor

* Search with check

* instrument zanzana client

* add single_read option

* refactor

* refactor move check into separate function

* Fix tests

* refactor

* refactor getFindDashboardsFn

* add resource type to span attributes

* run ListObjects concurrently

* Use list and search in less cases

* adjust metrics buckets

* refactor: move Check and ListObjects to AccessControl implementation

* Revert "Fix tests"

This reverts commit b0c2f072a2.

* refactor: use own types for Check and ListObjects inside accesscontrol package

* Fix search scenario with low limit and empty query string

* more accurate search with checks

* revert

* fix linter

* Revert "revert"

This reverts commit ee5f14eea8.

* add search errors metric

* fix query performance under some conditions

* simplify check strategy

* fix pagination

* refactor findDashboardsZanzanaList

* Iterate over multiple pages while making check request

* refactor listUserResources

* avoid unnecessary db call

* remove unused zclient

* Add notes for SkipAccessControlFilter

* use more accurate check loop

* always use check for search with provided UIDs

* rename single_read to zanzana_only_evaluation

* refactor

* update go workspace

* fix linter

* don't use deprecated fields

* refactor

* fail if no org specified

* refactor

* initial integration tests

* Fix tests

* fix linter errors

* fix linter

* Fix tests

* review suggestions

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

* fix limit

* refactor

* refactor tests

* fix db config in tests

* fix migrator (postgres)

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2024-10-04 12:27:10 +02:00

55 lines
1.7 KiB
Go

package service
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
const (
metricsNamespace = "grafana"
metricsSubSystem = "dashboards"
)
var defaultBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25}
type dashboardsMetrics struct {
sharedWithMeFetchDashboardsRequestsDuration *prometheus.HistogramVec
searchRequestsDuration *prometheus.HistogramVec
searchRequestStatusTotal *prometheus.CounterVec
}
func newDashboardsMetrics(r prometheus.Registerer) *dashboardsMetrics {
return &dashboardsMetrics{
sharedWithMeFetchDashboardsRequestsDuration: promauto.With(r).NewHistogramVec(
prometheus.HistogramOpts{
Name: "sharedwithme_fetch_dashboards_duration_seconds",
Help: "Duration of fetching dashboards with permissions directly assigned to user",
Buckets: defaultBuckets,
Namespace: metricsNamespace,
Subsystem: metricsSubSystem,
},
[]string{"status"},
),
searchRequestsDuration: promauto.With(r).NewHistogramVec(
prometheus.HistogramOpts{
Name: "search_dashboards_duration_seconds",
Help: "Duration of dashboards search (by authorization engine)",
Buckets: defaultBuckets,
Namespace: metricsNamespace,
Subsystem: metricsSubSystem,
},
[]string{"engine"},
),
searchRequestStatusTotal: promauto.With(r).NewCounterVec(
prometheus.CounterOpts{
Name: "search_dashboards_status_total",
Help: "Search status (success or error) for zanzana",
Namespace: metricsNamespace,
Subsystem: metricsSubSystem,
},
[]string{"status"},
),
}
}