Skip to content

Commit

Permalink
Exclude ec2 since it's too generic
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Acosta committed Sep 19, 2016
1 parent f5ad6a8 commit 193bfec
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions render/theinternet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package render

import (
"net"
"strings"
"regexp"

"github.com/weaveworks/scope/probe/host"
"github.com/weaveworks/scope/report"
Expand All @@ -12,22 +12,38 @@ var (
// ServiceNodeIDPrefix is how the ID all service pseudo nodes begin
ServiceNodeIDPrefix = "service-"

// Correspondence between hostnames and the service id they are part of
knownServicesSuffixes = []string{
knownServicesMatchers = []*regexp.Regexp{
// See http://docs.aws.amazon.com/general/latest/gr/rande.html for fainer grained
// details
"amazonaws.com",
"googleapis.com",
regexp.MustCompile(`^.+\.amazonaws\.com$`),
regexp.MustCompile(`^.+\.googleapis\.com$`),
}

knownServicesExcluder = []*regexp.Regexp{
// We exclude ec2 machines because they are too generic
// and having separate nodes for them makes visualizations worse
regexp.MustCompile(`^ec2.*\.amazonaws\.com$`),
}
)

func isKnownService(hostname string) bool {
for _, suffix := range knownServicesSuffixes {
if strings.HasSuffix(hostname, suffix) {
return true
foundMatch := false
for _, matcher := range knownServicesMatchers {
if matcher.MatchString(hostname) {
foundMatch = true
break
}
}
if !foundMatch {
return false
}

for _, excluder := range knownServicesExcluder {
if excluder.MatchString(hostname) {
return false
}
}
return false
return true
}

// LocalNetworks returns a superset of the networks (think: CIDRs) that are
Expand Down

0 comments on commit 193bfec

Please sign in to comment.