-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
target.go
62 lines (50 loc) · 1.4 KB
/
target.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
package targets
import (
"github.com/prometheus/common/model"
)
// TargetType is the type of target
type TargetType string
const (
// FileTargetType is a file target
FileTargetType = TargetType("File")
// JournalTargetType is a journalctl target
JournalTargetType = TargetType("Journal")
// DroppedTargetType is a target that's been dropped.
DroppedTargetType = TargetType("dropped")
)
// Target is a promtail scrape target
type Target interface {
// Type of the target
Type() TargetType
// Ready tells if the targets is ready
Ready() bool
// Details is additional information about this target specific to its type
Details() interface{}
}
// IsDropped tells if a target has been dropped
func IsDropped(t Target) bool {
return t.Type() == DroppedTargetType
}
// droppedTarget is a target that has been dropped
type droppedTarget struct {
discoveredLabels model.LabelSet
reason string
}
func newDroppedTarget(reason string, discoveredLabels model.LabelSet) Target {
return &droppedTarget{
discoveredLabels: discoveredLabels,
reason: reason,
}
}
// Type implements Target
func (d *droppedTarget) Type() TargetType {
return DroppedTargetType
}
// Ready implements Target
func (d *droppedTarget) Ready() bool {
return false
}
// Details implements Target it contains a message explaining the reason for dropping it
func (d *droppedTarget) Details() interface{} {
return d.reason
}