-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
targets.go
77 lines (62 loc) · 2 KB
/
targets.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package timeseries
import (
"github.com/K-Phoen/grabana/target/graphite"
"github.com/K-Phoen/grabana/target/influxdb"
"github.com/K-Phoen/grabana/target/loki"
"github.com/K-Phoen/grabana/target/prometheus"
"github.com/K-Phoen/grabana/target/stackdriver"
"github.com/K-Phoen/sdk"
)
// WithPrometheusTarget adds a prometheus query to the graph.
func WithPrometheusTarget(query string, options ...prometheus.Option) Option {
target := prometheus.New(query, options...)
return func(graph *TimeSeries) error {
graph.Builder.AddTarget(&sdk.Target{
RefID: target.Ref,
Hide: target.Hidden,
Expr: target.Expr,
IntervalFactor: target.IntervalFactor,
Interval: target.Interval,
Step: target.Step,
LegendFormat: target.LegendFormat,
Instant: target.Instant,
Format: target.Format,
})
return nil
}
}
// WithGraphiteTarget adds a Graphite target to the table.
func WithGraphiteTarget(query string, options ...graphite.Option) Option {
target := graphite.New(query, options...)
return func(graph *TimeSeries) error {
graph.Builder.AddTarget(target.Builder)
return nil
}
}
// WithInfluxDBTarget adds an InfluxDB target to the graph.
func WithInfluxDBTarget(query string, options ...influxdb.Option) Option {
target := influxdb.New(query, options...)
return func(graph *TimeSeries) error {
graph.Builder.AddTarget(target.Builder)
return nil
}
}
// WithStackdriverTarget adds a stackdriver query to the graph.
func WithStackdriverTarget(target *stackdriver.Stackdriver) Option {
return func(graph *TimeSeries) error {
graph.Builder.AddTarget(target.Builder)
return nil
}
}
// WithLokiTarget adds a loki query to the graph.
func WithLokiTarget(query string, options ...loki.Option) Option {
target := loki.New(query, options...)
return func(graph *TimeSeries) error {
graph.Builder.AddTarget(&sdk.Target{
Hide: target.Hidden,
Expr: target.Expr,
LegendFormat: target.LegendFormat,
})
return nil
}
}