Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to forward logs only from specific spaces #215

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Flags:
'--extra-fields=env:dev,something:other
--orgs="" Forwarded on the app logs from theses
organisations' example: --orgs=org1,org2
--space="" Forwarded on the app logs from a specific
space' example: --space=org1:space1.
Specify multiple times for multiple spaces.
--mode-prof="" Enable profiling mode, one of [cpu, mem,
block]
--path-prof="" Set the Path to write profiling file
Expand Down
8 changes: 5 additions & 3 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package main
import (
"context"
"fmt"
"github.com/cloudfoundry-community/firehose-to-syslog/authclient"
"github.com/cloudfoundry-incubator/uaago"
"log"
"os"
"os/signal"
"strings"
"time"

"github.com/cloudfoundry-community/firehose-to-syslog/authclient"
"github.com/cloudfoundry-incubator/uaago"

"github.com/cloudfoundry-community/firehose-to-syslog/caching"
"github.com/cloudfoundry-community/firehose-to-syslog/eventRouting"
"github.com/cloudfoundry-community/firehose-to-syslog/firehoseclient"
Expand Down Expand Up @@ -43,6 +44,7 @@ var (
requestLimit = kingpin.Flag("cc-rps", "CloudController Polling request by second (IGNORED)").Default("50").Envar("CF_RPS").Int()
extraFields = kingpin.Flag("extra-fields", "Extra fields you want to annotate your events with, example: '--extra-fields=env:dev,something:other ").Default("").Envar("EXTRA_FIELDS").String()
orgs = kingpin.Flag("orgs", "Forwarded on the app logs from theses organisations' example: --orgs=org1,org2").Default("").Envar("ORGS").String()
spaces = kingpin.Flag("space", "Forwarded on the app logs from a specific space' example: --space=org1:space1. Specify multiple times for multiple spaces.").Envar("SPACES").StringMap()
modeProf = kingpin.Flag("mode-prof", "Enable profiling mode, one of [cpu, mem, block]").Default("").Envar("MODE_PROF").String()
pathProf = kingpin.Flag("path-prof", "Set the Path to write profiling file").Default("").Envar("PATH_PROF").String()
logFormatterType = kingpin.Flag("log-formatter-type", "Log formatter type to use. Valid options are text, json, json-cee. If none provided, defaults to json.").Envar("LOG_FORMATTER_TYPE").String()
Expand Down Expand Up @@ -159,7 +161,7 @@ func (cli *CLI) Run(args []string) int {
}

//Creating Events
eventFilters := []eventRouting.EventFilter{eventRouting.HasIgnoreField, eventRouting.NotInCertainOrgs(*orgs)}
eventFilters := []eventRouting.EventFilter{eventRouting.HasIgnoreField, eventRouting.NotInCertainOrgs(*orgs), eventRouting.NotInCertainSpaces(*spaces)}
events := eventRouting.NewEventRouting(cachingClient, loggingClient, statistic, eventFilters)
err = events.SetupEventRouting(*wantedEvents)
if err != nil {
Expand Down
19 changes: 19 additions & 0 deletions eventRouting/event_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,22 @@ func NotInCertainOrgs(orgFilters string) EventFilter {
return true
}
}

//NotInCertainSpaces Filter out events not in certain spaces
func NotInCertainSpaces(spaceFilters map[string]string) EventFilter {
return func(event *fevents.Event) bool {
if len(spaceFilters) == 0 {
return false
}
orgName := event.Fields["cf_org_name"]
spaceName := event.Fields["cf_space_name"]
for org, space := range spaceFilters {
if org == "" || orgName == nil || space == "" || spaceName == "" {
return false
} else if org == orgName && space == spaceName {
return false
}
}
return true
}
}
1 change: 1 addition & 0 deletions vendor/code.cloudfoundry.org/go-loggregator/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/code.cloudfoundry.org/go-loggregator/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

176 changes: 176 additions & 0 deletions vendor/code.cloudfoundry.org/go-loggregator/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions vendor/code.cloudfoundry.org/go-loggregator/NOTICE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions vendor/code.cloudfoundry.org/go-loggregator/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading