mirror of
https://github.com/FlipsideCrypto/convox.git
synced 2026-02-06 10:56:56 +00:00
gcp: update logging reader for new kubernetes format (#87)
This commit is contained in:
parent
981cfc00e0
commit
14afc2dae0
@ -101,19 +101,13 @@ Iteration:
|
||||
|
||||
prefix := ""
|
||||
|
||||
pod := entry.Labels["container.googleapis.com/pod_name"]
|
||||
service := "unknown"
|
||||
labels := entry.Resource.GetLabels()
|
||||
|
||||
if pp := strings.Split(pod, "-"); len(pp) > 2 {
|
||||
service = strings.Join(pp[0:len(pp)-2], "-")
|
||||
}
|
||||
typ := common.CoalesceString(entry.Labels["k8s-pod/type"], "unknown")
|
||||
name := common.CoalesceString(entry.Labels["k8s-pod/name"], "unknown")
|
||||
|
||||
if common.DefaultBool(opts.Prefix, false) {
|
||||
if strings.HasSuffix(entry.LogName, "/main") {
|
||||
prefix = fmt.Sprintf("%s service/%s/%s ", entry.Timestamp.Format(time.RFC3339), service, pod)
|
||||
} else {
|
||||
prefix = fmt.Sprintf("%s %s ", entry.Timestamp.Format(time.RFC3339), entry.Labels["stream"])
|
||||
}
|
||||
prefix = fmt.Sprintf("%s %s/%s/%s ", entry.Timestamp.Format(time.RFC3339), typ, name, labels["pod_name"])
|
||||
}
|
||||
|
||||
switch t := entry.Payload.(type) {
|
||||
@ -132,5 +126,11 @@ Iteration:
|
||||
}
|
||||
|
||||
func (p *Provider) logFilters(app string) string {
|
||||
return fmt.Sprintf(`labels."container.googleapis.com/namespace_name" = %q`, p.AppNamespace(app))
|
||||
filters := []string{
|
||||
`resource.type="k8s_container"`,
|
||||
fmt.Sprintf(`resource.labels.cluster_name=%q`, p.Name),
|
||||
fmt.Sprintf(`resource.labels.namespace_name=%q`, p.AppNamespace(app)),
|
||||
}
|
||||
|
||||
return strings.Join(filters, " AND ")
|
||||
}
|
||||
|
||||
@ -6,13 +6,8 @@ resource "google_service_account_key" "api" {
|
||||
service_account_id = google_service_account.api.name
|
||||
}
|
||||
|
||||
resource "google_project_iam_member" "api-logging-viewer" {
|
||||
role = "roles/logging.viewer"
|
||||
member = "serviceAccount:${google_service_account.api.email}"
|
||||
}
|
||||
|
||||
resource "google_project_iam_member" "api-logging-writer" {
|
||||
role = "roles/logging.logWriter"
|
||||
resource "google_project_iam_member" "api-logging-admin" {
|
||||
role = "roles/logging.admin"
|
||||
member = "serviceAccount:${google_service_account.api.email}"
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user