-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Add stackdriver links to logs tab (#383)
* Add stackdriver panel to logs tabs * Add missing stackdriver url util method * Add file ref to point the source of the code to Merlin * Remove leftover print statement * Fix difficult to read alignment of if conditions * Expose appConfigs allow utils to use them
- Loading branch information
1 parent
91e2211
commit 4f1cbd2
Showing
5 changed files
with
192 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// This file in almost an exact copy of this file from Merlin | ||
// Ref: https://github.com/caraml-dev/merlin/blob/8edef22b29d0bfb2728d62b1f880f1f753f9509e/ui/src/utils/createStackdriverUrl.js | ||
import { appConfig } from "../config"; | ||
|
||
const stackdriverAPI = "https://console.cloud.google.com/logs/viewer"; | ||
|
||
const stackdriverFilter = query => { | ||
return `resource.type:"k8s_query" OR "k8s_container" OR "k8s_pod" | ||
resource.labels.project_id:${query.gcp_project} | ||
resource.labels.cluster_name:${query.cluster} | ||
resource.labels.namespace_name:${query.namespace} | ||
resource.labels.pod_name:${query.pod_name} | ||
timestamp>"${query.start_time}" | ||
`; | ||
}; | ||
|
||
const stackdriverImageBuilderFilter = query => { | ||
return `resource.type:"k8s_container" | ||
resource.labels.project_id:${appConfig.imagebuilder.gcp_project} | ||
resource.labels.cluster_name:${appConfig.imagebuilder.cluster} | ||
resource.labels.namespace_name:${appConfig.imagebuilder.namespace} | ||
labels.k8s-pod/job-name:${query.job_name} | ||
timestamp>"${query.start_time}"`; | ||
} | ||
|
||
export const createStackdriverUrl = (query, component) => { | ||
const advanceFilter = component === "ensembler_image_builder" ? stackdriverImageBuilderFilter(query) : stackdriverFilter(query); | ||
|
||
const url = { | ||
project: query.gcp_project || appConfig.imagebuilder.gcp_project, | ||
minLogLevel: 0, | ||
expandAll: false, | ||
advancedFilter: advanceFilter, | ||
}; | ||
|
||
const stackdriverParams = new URLSearchParams(url).toString(); | ||
return stackdriverAPI + "?" + stackdriverParams; | ||
}; | ||
|