mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
gcplogging driver MRPB set
Signed-off-by: Grzegorz Jaśkiewicz <gj.jaskiewicz@gmail.com>
This commit is contained in:
parent
30221cc521
commit
d925e50470
1 changed files with 32 additions and 13 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
"cloud.google.com/go/logging"
|
"cloud.google.com/go/logging"
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
mrpb "google.golang.org/genproto/googleapis/api/monitoredres"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -128,7 +129,35 @@ func New(info logger.Info) (logger.Logger, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
lg := c.Logger("gcplogs-docker-driver")
|
var instanceResource *instanceInfo
|
||||||
|
if onGCE {
|
||||||
|
instanceResource = &instanceInfo{
|
||||||
|
Zone: zone,
|
||||||
|
Name: instanceName,
|
||||||
|
ID: instanceID,
|
||||||
|
}
|
||||||
|
} else if info.Config[logZoneKey] != "" || info.Config[logNameKey] != "" || info.Config[logIDKey] != "" {
|
||||||
|
instanceResource = &instanceInfo{
|
||||||
|
Zone: info.Config[logZoneKey],
|
||||||
|
Name: info.Config[logNameKey],
|
||||||
|
ID: info.Config[logIDKey],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
options := []logging.LoggerOption{}
|
||||||
|
if instanceResource != nil {
|
||||||
|
vmMrpb := logging.CommonResource(
|
||||||
|
&mrpb.MonitoredResource{
|
||||||
|
Type: "gce_instance",
|
||||||
|
Labels: map[string]string{
|
||||||
|
"instance_id": instanceResource.ID,
|
||||||
|
"zone": instanceResource.Zone,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
options = []logging.LoggerOption{vmMrpb}
|
||||||
|
}
|
||||||
|
lg := c.Logger("gcplogs-docker-driver", options...)
|
||||||
|
|
||||||
if err := c.Ping(context.Background()); err != nil {
|
if err := c.Ping(context.Background()); err != nil {
|
||||||
return nil, fmt.Errorf("unable to connect or authenticate with Google Cloud Logging: %v", err)
|
return nil, fmt.Errorf("unable to connect or authenticate with Google Cloud Logging: %v", err)
|
||||||
|
@ -155,18 +184,8 @@ func New(info logger.Info) (logger.Logger, error) {
|
||||||
l.container.Command = info.Command()
|
l.container.Command = info.Command()
|
||||||
}
|
}
|
||||||
|
|
||||||
if onGCE {
|
if instanceResource != nil {
|
||||||
l.instance = &instanceInfo{
|
l.instance = instanceResource
|
||||||
Zone: zone,
|
|
||||||
Name: instanceName,
|
|
||||||
ID: instanceID,
|
|
||||||
}
|
|
||||||
} else if info.Config[logZoneKey] != "" || info.Config[logNameKey] != "" || info.Config[logIDKey] != "" {
|
|
||||||
l.instance = &instanceInfo{
|
|
||||||
Zone: info.Config[logZoneKey],
|
|
||||||
Name: info.Config[logNameKey],
|
|
||||||
ID: info.Config[logIDKey],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The logger "overflows" at a rate of 10,000 logs per second and this
|
// The logger "overflows" at a rate of 10,000 logs per second and this
|
||||||
|
|
Loading…
Reference in a new issue