Skip to content

Commit c772517

Browse files
gmlltbenjaminguttmann-avtq
authored andcommitted
add filters and complete readme
1 parent 9b95442 commit c772517

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ usage: cf_exporter --cf.api_url=CF.API_URL --cf.deployment-name=CF.DEPLOYMENT-NA
7979
8080
Flags:
8181
-h, --help Show context-sensitive help (also try --help-long and --help-man).
82+
--bbs.api_url=BBS.API_URL BBS API URL ($CF_EXPORTER_BBS_API_URL)
83+
--bbs.ca_file=BBS.CA_FILE BBS CA File ($CF_EXPORTER_BBS_CA_FILE)
84+
--bbs.cert_file=BBS.CERT_FILE
85+
BBS Cert File ($CF_EXPORTER_BBS_CERT_FILE)
86+
--bbs.key_file=BBS.KEY_FILE
87+
BBS Key File ($CF_EXPORTER_BBS_KEY_FILE)
88+
--bbs.skip_ssl_verify Disable SSL Verify for BBS ($CF_EXPORTER_BBS_SKIP_SSL_VERIFY)
89+
--bbs.timeout=5 BBS API Timeout ($CF_EXPORTER_BBS_TIMEOUT)
8290
--cf.api_url=CF.API_URL Cloud Foundry API URL ($CF_EXPORTER_CF_API_URL)
8391
--cf.username=CF.USERNAME Cloud Foundry Username ($CF_EXPORTER_CF_USERNAME)
8492
--cf.password=CF.PASSWORD Cloud Foundry Password ($CF_EXPORTER_CF_PASSWORD)

fetcher/fetcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (c *Fetcher) workInit() {
8585
c.worker.PushIf("service_route_bindings", c.fetchServiceRouteBindings, filters.ServiceRouteBindings)
8686
c.worker.PushIf("users", c.fetchUsers, filters.Events)
8787
c.worker.PushIf("events", c.fetchEvents, filters.Events)
88-
c.worker.Push("actual_lrps", c.fetchActualLRPs)
88+
c.worker.PushIf("actual_lrps", c.fetchActualLRPs, filters.ActualLRPs)
8989
}
9090

9191
func (c *Fetcher) fetch() *models.CFObjects {

fetcher/fetcher_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var _ = ginkgo.Describe("Fetcher", func() {
4040
"spaces",
4141
"space_quotas",
4242
"applications",
43+
"droplets",
4344
"domains",
4445
"process",
4546
"routes",
@@ -54,6 +55,7 @@ var _ = ginkgo.Describe("Fetcher", func() {
5455
"service_bindings",
5556
"service_route_bindings",
5657
"segments",
58+
"actual_lrps",
5759
}
5860
})
5961
ginkgo.It("plans all jobs", func() {
@@ -71,6 +73,7 @@ var _ = ginkgo.Describe("Fetcher", func() {
7173
"spaces",
7274
"space_quotas",
7375
"applications",
76+
"droplets",
7477
"domains",
7578
"process",
7679
"routes",
@@ -88,6 +91,7 @@ var _ = ginkgo.Describe("Fetcher", func() {
8891
"segments",
8992
"users",
9093
"events",
94+
"actual_lrps",
9195
}
9296
})
9397
ginkgo.It("plans all jobs", func() {
@@ -225,5 +229,25 @@ var _ = ginkgo.Describe("Fetcher", func() {
225229
})
226230
})
227231

232+
ginkgo.When("droplets filter is set", func() {
233+
ginkgo.BeforeEach(func() {
234+
active = []string{filters.Droplets}
235+
expected = []string{"info", "droplets"}
236+
})
237+
ginkgo.It("plans only specific jobs", func() {
238+
gomega.Ω(jobs).Should(gomega.ConsistOf(expected))
239+
})
240+
})
241+
242+
ginkgo.When("actual_lrps filter is set", func() {
243+
ginkgo.BeforeEach(func() {
244+
active = []string{filters.ActualLRPs}
245+
expected = []string{"info", "actual_lrps"}
246+
})
247+
ginkgo.It("plans only specific jobs", func() {
248+
gomega.Ω(jobs).Should(gomega.ConsistOf(expected))
249+
})
250+
})
251+
228252
})
229253
})

filters/filters.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
)
77

88
const (
9+
ActualLRPs = "actual_lrps"
910
Applications = "applications"
1011
Droplets = "droplets"
1112
Buildpacks = "buildpacks"
@@ -27,6 +28,7 @@ const (
2728

2829
var (
2930
All = []string{
31+
ActualLRPs,
3032
Applications,
3133
Droplets,
3234
Buildpacks,
@@ -54,6 +56,7 @@ type Filter struct {
5456
func NewFilter(active ...string) (*Filter, error) {
5557
filter := &Filter{
5658
activated: map[string]bool{
59+
ActualLRPs: true,
5760
Applications: true,
5861
Droplets: true,
5962
Buildpacks: true,
@@ -86,6 +89,7 @@ func NewFilter(active ...string) (*Filter, error) {
8689
func (f *Filter) setActive(active []string) error {
8790
// override default states with all disabled
8891
f.activated = map[string]bool{
92+
ActualLRPs: false,
8993
Applications: false,
9094
Droplets: false,
9195
Buildpacks: false,

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ var (
6767
).Envar("CF_EXPORTER_CF_DEPLOYMENT_NAME").Required().String()
6868

6969
filterCollectors = kingpin.Flag(
70-
"filter.collectors", "Comma separated collectors to filter (Applications,Buildpacks,Events,IsolationSegments,Organizations,Routes,SecurityGroups,ServiceBindings,ServiceInstances,ServicePlans,Services,Spaces,Stacks,Tasks,ActualLRPs). If not set, all collectors except Events and Tasks are enabled ($CF_EXPORTER_FILTER_COLLECTORS)",
70+
"filter.collectors", "Comma separated collectors to filter (ActualLRPs,Applications,Buildpacks,Events,IsolationSegments,Organizations,Routes,SecurityGroups,ServiceBindings,ServiceInstances,ServicePlans,Services,Spaces,Stacks,Tasks,ActualLRPs). If not set, all collectors except Events and Tasks are enabled ($CF_EXPORTER_FILTER_COLLECTORS)",
7171
).Envar("CF_EXPORTER_FILTER_COLLECTORS").Default("").String()
7272

7373
metricsNamespace = kingpin.Flag(

0 commit comments

Comments
 (0)