forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scraper.go
65 lines (56 loc) · 1.83 KB
/
scraper.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
package influxdb
import (
"context"
)
// ErrScraperTargetNotFound is the error msg for a missing scraper target.
const ErrScraperTargetNotFound = "scraper target not found"
// ops for ScraperTarget Store
const (
OpListTargets = "ListTargets"
OpAddTarget = "AddTarget"
OpGetTargetByID = "GetTargetByID"
OpRemoveTarget = "RemoveTarget"
OpUpdateTarget = "UpdateTarget"
)
// ScraperTarget is a target to scrape
type ScraperTarget struct {
ID ID `json:"id,omitempty"`
Name string `json:"name"`
Type ScraperType `json:"type"`
URL string `json:"url"`
OrgID ID `json:"orgID,omitempty"`
BucketID ID `json:"bucketID,omitempty"`
}
// ScraperTargetStoreService defines the crud service for ScraperTarget.
type ScraperTargetStoreService interface {
UserResourceMappingService
OrganizationService
ListTargets(ctx context.Context, filter ScraperTargetFilter) ([]ScraperTarget, error)
AddTarget(ctx context.Context, t *ScraperTarget, userID ID) error
GetTargetByID(ctx context.Context, id ID) (*ScraperTarget, error)
RemoveTarget(ctx context.Context, id ID) error
UpdateTarget(ctx context.Context, t *ScraperTarget, userID ID) (*ScraperTarget, error)
}
// ScraperTargetFilter represents a set of filter that restrict the returned results.
type ScraperTargetFilter struct {
IDs map[ID]bool `json:"ids"`
Name *string `json:"name"`
OrgID *ID `json:"orgID"`
Org *string `json:"org"`
}
// ScraperType defines the scraper methods.
type ScraperType string
// Scraper types
const (
// PrometheusScraperType parses metrics from a prometheus endpoint.
PrometheusScraperType = "prometheus"
)
// ValidScraperType returns true is the type string is valid
func ValidScraperType(s string) bool {
switch s {
case PrometheusScraperType:
return true
default:
return false
}
}