Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshAccessLogs: Multiple lines of logs are consumed as single line by Dynatrace #11143

Closed
lukidzi opened this issue Aug 19, 2024 · 8 comments
Closed
Assignees
Labels
kind/feature New feature triage/needs-information Reviewed and some extra information was asked to the reporter

Comments

@lukidzi
Copy link
Contributor

lukidzi commented Aug 19, 2024

What happened?

Dynatrace requires [timestamp] [logLevel] {json_data} to correlate data as a single log. Because JSON format produced by Envoy is a full json string without these prefixes, logs are not properly indexed by Dynatrace. It would be nice to support this format or HTTP backend

type: MeshAccessLog
name: accesslogs
mesh: default
spec:
 targetRef:
   kind: Mesh
 from:
   - targetRef:
       kind: Mesh
     default:
       backends:
         - type: File
           file:
             path: /dev/stdout
             format:
               type: Json
                 json:
                   - key: "start_time"
                      value: "%START_TIME%"
                   - key: "bytes_received"
                      value: "%BYTES_RECEIVED%"
@lukidzi lukidzi added triage/pending This issue will be looked at on the next triage meeting kind/feature New feature labels Aug 19, 2024
@bartsmykla bartsmykla added triage/needs-information Reviewed and some extra information was asked to the reporter and removed triage/pending This issue will be looked at on the next triage meeting labels Aug 26, 2024
@bartsmykla
Copy link
Contributor

triage: it's possible that Dynatrace support OTEL gRPC endpoints, which should solve this issue. We need to check if that's possible

@Icarus9913
Copy link
Contributor

I found the way to handle with the stdout in json type.
Use the MeshProxyPatch to supplement the JsonFormatOptions sort_properties (The output JSON string properties will be sorted.)
In this way, each log would be single one that was analyzed by Dynatrace

apiVersion: kuma.io/v1alpha1
kind: MeshAccessLog
metadata:
  name: default
  namespace: kuma-system
  labels:
    kuma.io/mesh: default
spec:
  targetRef:
    kind: Mesh
  from:
    - targetRef:
        kind: Mesh
      default:
        backends:
          - type: File
            file:
              path: /dev/stdout
              format:
                type: Json
                json:
                - key: "data_set"
                  value: "kuma"
                - key: "start_time"
                  value: "%START_TIME(%Y-%m-%d %H:%M:%S %s)%"
                - key: "kuma_mesh"
                  value: "%KUMA_MESH%"
                - key: "kuma_source_address_without_port"
                  value: "%KUMA_SOURCE_ADDRESS_WITHOUT_PORT%"
                - key: "kuma_source_service"
                  value: "%KUMA_SOURCE_SERVICE%"
                - key: "upstream_host"
                  value: "%UPSTREAM_HOST%"
                - key: "kuma_destination_service"
                  value: "%KUMA_DESTINATION_SERVICE%"
                - key: "duration_ms"
                  value: "%DURATION%"
                - key: "bytes_sent"
                  value: "%BYTES_SENT%"
                - key: "bytes_received"
                  value: "%BYTES_RECEIVED%" 
---
apiVersion: kuma.io/v1alpha1
kind: MeshProxyPatch
metadata:
  name: accesslog
  namespace: kuma-system
spec:
  targetRef:
    kind: Mesh
  default:
    appendModifications:
      - listener:
          operation: Patch
          match:
            origin: inbound
            tags:
              k8s.kuma.io/service-name: httpbin-1
          jsonPatches:
            - op: add
              path: /filterChains/0/filters/0/typedConfig/accessLog/0/typedConfig/logFormat/jsonFormatOptions
              value: {"sort_properties": true}

@Icarus9913
Copy link
Contributor

Maybe we should also add that jsonFormatOptions property in our MeshAccessLog policy configuration

func (c *Configurer) sfsJSON(fields map[string]*structpb.Value, omitEmpty bool) *envoy_core.SubstitutionFormatString {
return &envoy_core.SubstitutionFormatString{
Format: &envoy_core.SubstitutionFormatString_JsonFormat{
JsonFormat: &structpb.Struct{
Fields: fields,
},
},
OmitEmptyValues: omitEmpty,
}
}

@michaelbeaumont
Copy link
Contributor

Waiting on feedback from user on MeshProxyPatch

@slonka
Copy link
Contributor

slonka commented Sep 16, 2024

Still waiting, pinged on slack.

@jakubdyszkiewicz
Copy link
Contributor

@Icarus9913 did you try this with Dynatrace?

@Icarus9913
Copy link
Contributor

Yeah, I did a test from my side with Dynatrace and it works in my case.

image
image


However, it seems that not works for the user. Maybe we should suggest the user to switch to OTEL way and get a try

@lobkovilya
Copy link
Contributor

Triage: seems like it's not an issue. Closing the issue.

@lobkovilya lobkovilya closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature triage/needs-information Reviewed and some extra information was asked to the reporter
Projects
None yet
Development

No branches or pull requests

7 participants