-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
loki.go
47 lines (39 loc) · 899 Bytes
/
loki.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package loki
// Option represents an option that can be used to configure a loki query.
type Option func(target *Loki)
// Loki represents a loki query.
type Loki struct {
Ref string
Hidden bool
Expr string
LegendFormat string
}
// New creates a new prometheus query.
func New(query string, options ...Option) *Loki {
loki := &Loki{
Expr: query,
}
for _, opt := range options {
opt(loki)
}
return loki
}
// Legend sets the legend format.
func Legend(legend string) Option {
return func(loki *Loki) {
loki.LegendFormat = legend
}
}
// Ref sets the reference ID for this query.
func Ref(ref string) Option {
return func(loki *Loki) {
loki.Ref = ref
}
}
// Hide the query. Grafana does not send hidden queries to the data source,
// but they can still be referenced in alerts.
func Hide() Option {
return func(loki *Loki) {
loki.Hidden = true
}
}