Skip to content

Commit

Permalink
Fix Stackdriver log link (#79)
Browse files Browse the repository at this point in the history
This PR fixes Stackdriver log link using `resource.labels.pod_name` as `advancedFilter` instead of `logName`.
  • Loading branch information
honnix authored Aug 25, 2020
1 parent f2542b4 commit dd03881
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions flyteidl/clients/go/coreutils/logs/stackdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"github.com/lyft/flyteidl/gen/pb-go/flyteidl/core"
)

// TL;DR Log links in Stackdriver for configured GCP project and log Resource - Assumption: logName = podName
// TL;DR Log links in Stackdriver for configured GCP project and log Resource
//
// This is a simple stackdriver log plugin that creates a preformatted log link for a given project and logResource
// assuming that the logName is the name of the pod in kubernetes
// using resource.labels.pod_name as advancedFilter
type stackdriverLogPlugin struct {
// the name of the project in GCP that the logs are being published under
gcpProject string
Expand All @@ -20,7 +20,7 @@ type stackdriverLogPlugin struct {
func (s *stackdriverLogPlugin) GetTaskLog(podName, namespace, containerName, containerID, logName string) (core.TaskLog, error) {
return core.TaskLog{
Uri: fmt.Sprintf(
"https://console.cloud.google.com/logs/viewer?project=%s&angularJsUrl=%%2Flogs%%2Fviewer%%3Fproject%%3D%s&resource=%s&advancedFilter=logName:%s",
"https://console.cloud.google.com/logs/viewer?project=%s&angularJsUrl=%%2Flogs%%2Fviewer%%3Fproject%%3D%s&resource=%s&advancedFilter=resource.labels.pod_name%%3D%s",
s.gcpProject,
s.gcpProject,
s.logResource,
Expand Down
4 changes: 2 additions & 2 deletions flyteidl/clients/go/coreutils/logs/stackdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ func Test_stackdriverLogPlugin_GetTaskLog(t *testing.T) {
"podName-proj1",
fields{gcpProject: "test-gcp-project", logResource: "aws_ec2_instance"},
args{podName: "podName"},
core.TaskLog{Uri: "https://console.cloud.google.com/logs/viewer?project=test-gcp-project&angularJsUrl=%2Flogs%2Fviewer%3Fproject%3Dtest-gcp-project&resource=aws_ec2_instance&advancedFilter=logName:podName", MessageFormat: core.TaskLog_JSON}, false,
core.TaskLog{Uri: "https://console.cloud.google.com/logs/viewer?project=test-gcp-project&angularJsUrl=%2Flogs%2Fviewer%3Fproject%3Dtest-gcp-project&resource=aws_ec2_instance&advancedFilter=resource.labels.pod_name%3DpodName", MessageFormat: core.TaskLog_JSON}, false,
},
{
"podName2-proj2",
fields{gcpProject: "proj2", logResource: "res1"},
args{podName: "long-pod-name-xyyyx"},
core.TaskLog{Uri: "https://console.cloud.google.com/logs/viewer?project=proj2&angularJsUrl=%2Flogs%2Fviewer%3Fproject%3Dproj2&resource=res1&advancedFilter=logName:long-pod-name-xyyyx", MessageFormat: core.TaskLog_JSON}, false,
core.TaskLog{Uri: "https://console.cloud.google.com/logs/viewer?project=proj2&angularJsUrl=%2Flogs%2Fviewer%3Fproject%3Dproj2&resource=res1&advancedFilter=resource.labels.pod_name%3Dlong-pod-name-xyyyx", MessageFormat: core.TaskLog_JSON}, false,
},
}
for _, tt := range tests {
Expand Down

0 comments on commit dd03881

Please sign in to comment.