Merge pull request #1265 from timstclair/docs

Clean up storage driver docs
This commit is contained in:
Phillip Wittrock 2016-05-05 21:54:12 -07:00
commit 8ba1f6d582
8 changed files with 39 additions and 18 deletions

View File

@ -32,15 +32,9 @@ We have detailed [instructions](docs/running.md#standalone) on running cAdvisor
See the more detailed instructions in the [build page](docs/development/build.md). This includes instructions for building and deploying the cAdvisor Docker image.
## InfluxDB and Cluster Monitoring
## Exporting stats
cAdvisor supports exporting stats to [InfluxDB](https://influxdb.com/). See the [documentation](docs/influxdb.md) for more information and examples.
cAdvisor also exposes container stats as [Prometheus](http://prometheus.io) metrics. See the [documentation](docs/prometheus.md) for more information.
cAdvisor also supports exporting stats to [ElasticSearch](https://www.elastic.co/). See the [documentation](docs/elasticsearch.md) for more information.
[Heapster](https://github.com/kubernetes/heapster) enables cluster wide monitoring of containers using cAdvisor.
cAdvisor supports exporting stats to various storage plugins. See the [documentation](docs/storage/README.md) for more details and examples.
## Web UI

View File

@ -39,7 +39,6 @@ var argIp = flag.String("listen_ip", "", "IP to listen on, defaults to all IPs")
var argPort = flag.Int("port", 8080, "port to listen")
var maxProcs = flag.Int("max_procs", 0, "max number of CPUs that can be used simultaneously. Less than 1 for default (number of cores).")
var argDbDriver = flag.String("storage_driver", "", "storage driver to use. Data is always cached shortly in memory, this controls where data is pushed besides the local cache. Empty means none. Options are: <empty> (default), bigquery, influxdb, and kafka")
var versionFlag = flag.Bool("version", false, "print cAdvisor version and exit")
var httpAuthFile = flag.String("http_auth_file", "", "HTTP auth file for the web UI")
@ -109,9 +108,9 @@ func main() {
setMaxProcs()
memoryStorage, err := NewMemoryStorage(*argDbDriver)
memoryStorage, err := NewMemoryStorage()
if err != nil {
glog.Fatalf("Failed to connect to database: %s", err)
glog.Fatalf("Failed to initialize storage driver: %s", err)
}
sysFs, err := sysfs.NewRealSysFs()

14
docs/storage/README.md Normal file
View File

@ -0,0 +1,14 @@
# cAdvisor Storage Plugins
cAdvisor supports exporting stats to various storage driver plugins. To enable a storage driver, set the `-storage_driver` flag.
## Storage drivers
- [BigQuery](https://cloud.google.com/bigquery/). See the [documentation](../../storage/bigquery/README.md) for usage.
- [ElasticSearch](https://www.elastic.co/). See the [documentation](elasticsearch.md) for usage and examples.
- [InfluxDB](https://influxdb.com/). See the [documentation](influxdb.md) for usage and examples.
- [Kafka](http://kafka.apache.org/)
- [Prometheus](http://prometheus.io). See the [documentation](prometheus.md) for usage and examples.
- [Redis](http://redis.io/)
- [StatsD](https://github.com/etsy/statsd)
- `stdout` - write stats to standard output.

View File

@ -16,6 +16,7 @@ package storage
import (
"fmt"
"sort"
info "github.com/google/cadvisor/info/v1"
)
@ -47,3 +48,12 @@ func New(name string) (StorageDriver, error) {
}
return f()
}
func ListDrivers() []string {
drivers := make([]string, 0, len(registeredPlugins))
for name := range registeredPlugins {
drivers = append(drivers, name)
}
sort.Strings(drivers)
return drivers
}

View File

@ -16,6 +16,8 @@ package main
import (
"flag"
"fmt"
"strings"
"time"
"github.com/google/cadvisor/cache/memory"
@ -31,18 +33,20 @@ import (
"github.com/golang/glog"
)
var storageDuration = flag.Duration("storage_duration", 2*time.Minute, "How long to keep data stored (Default: 2min).")
var (
storageDriver = flag.String("storage_driver", "", fmt.Sprintf("Storage `driver` to use. Data is always cached shortly in memory, this controls where data is pushed besides the local cache. Empty means none. Options are: <empty>, %s", strings.Join(storage.ListDrivers(), ", ")))
storageDuration = flag.Duration("storage_duration", 2*time.Minute, "How long to keep data stored (Default: 2min).")
)
// NewMemoryStorage creates a memory storage with an optional backend storage option.
func NewMemoryStorage(backendStorageName string) (*memory.InMemoryCache, error) {
backendStorage, err := storage.New(backendStorageName)
func NewMemoryStorage() (*memory.InMemoryCache, error) {
backendStorage, err := storage.New(*storageDriver)
if err != nil {
return nil, err
}
if backendStorageName != "" {
glog.Infof("Using backend storage type %q", backendStorageName)
if *storageDriver != "" {
glog.Infof("Using backend storage type %q", *storageDriver)
}
glog.Infof("Caching stats in memory for %v", *storageDuration)
storageDriver := memory.New(*storageDuration, backendStorage)
return storageDriver, nil
return memory.New(*storageDuration, backendStorage), nil
}