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"
|
||||
"github.com/Sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
mrpb "google.golang.org/genproto/googleapis/api/monitoredres"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -128,7 +129,35 @@ func New(info logger.Info) (logger.Logger, error) {
|
|||
if err != nil {
|
||||
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 {
|
||||
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()
|
||||
}
|
||||
|
||||
if onGCE {
|
||||
l.instance = &instanceInfo{
|
||||
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],
|
||||
}
|
||||
if instanceResource != nil {
|
||||
l.instance = instanceResource
|
||||
}
|
||||
|
||||
// The logger "overflows" at a rate of 10,000 logs per second and this
|
||||
|
|
Loading…
Add table
Reference in a new issue