Change the harness logging format to json in delegate
complete
S
Spotless Woodpecker
We see harness logs are exported as plain text on the delegate pods. Please help us to change the delegate logging format to JSON instead of plain text. This is needed for us create dashboards in ELK based on index.
example logs : 2023-09-04 14:38:50,134 [task-exec-4] INFO io.harness.delegate.task.scm.ScmDelegateClientImpl - scm channel successfully shut down [accountId=<actid>, taskId=a2efLl5kQCOjw_J3ZCitHw-DEL]
10.70.125.125 - - [04/Sep/2023:14:38:55 +0000] "GET /api/health HTTP/1.1" 200 74 "-" "kube-probe/1.24+" 1
2023-09-04 14:39:00,278 [AsyncHttpClient-3-1] INFO io.harness.delegate.service.DelegateAgentServiceImpl - New Task event received: {"eventType":"DelegateTaskEvent","accountId":"<actid>","delegateTaskId":"m6sv67ngT8mcNj67SuV1eQ-DEL","sync":true,"taskType":"CAPABILITY_VALIDATION"}
2023-09-04 14:39:00,311 [task-exec-5] INFO software.wings.delegatetasks.PerpetualTaskCapabilityCheckTask - Checking Capability: HttpConnectionExecutionCapability(capabilityType=HTTP, url=https://github.com/harness.git, headers=null, host=null, scheme=null, port=0, path=null, query=null, ignoreRedirect=false) [accountId=<actid>, taskId=m6sv67ngT8mcNj67SuV1eQ-DEL]
Log In
Canny AI
Merged in a post:
All delegate logs in json
A
Agreed Mockingbird
Hey team,
I've enabled JSON_LOG_FORMAT in the delegate env vars, but still not all logs are printed in json. I see a mix, something like:
{"@timestamp":"2024-11-22T13:27:31.398Z","@version":"1","message":"Checking for old queue files to be deleted","logger_name":"io.harness.event.client.impl.tailer.FileDeletionManager","thread_name":"ChronicleEventTailer RUNNING","level":"INFO","level_value":20000}
10.69.50.215 - - [22/Nov/2024:13:27:37 +0000] "GET /api/health HTTP/1.1" 200 74 "-" "kube-probe/1.24+" 33
So http requests are still logged as previously. Please also log them in json if possible.
Regards,
Andrey
Canny AI
Merged in a post:
Console logs format for Terraform step output
S
Serenity blue Squid
Console logs format for Terraform step output
The console logs on Harness is not properly formatted due to which we find it very difficult to understand the logs. The console log should be in a proper JSON format which should give an overview of the resources getting deployed using Terraform Enterprise in the backend.
It is very important to have a structured console view of the log so that anyone can read the log and troubleshoot the issue in case of any deployment failure. We are looking for a better console view of Harness pipeline execution for our consumers.
Rohan Gupta
Can you please elaborate more? We do support showing in the console logs the a more readable JSON output for the terraform plan
Prateek Mittal
complete
C
Conservation Marlin
Hi, happy to announce that we've added support for formatting delegate logs into JSON using net.logstash.logback.encoder.LogstashEncoder logback encoder.
Delegate will still continue using text format for logs by default, but you can configure it to JSON by following instructions to customize logging
This feature will be available starting with delegate version 824xx
A
Aesthetic Gecko
Conservation Marlin,
Good afternoon,
It would be interesting to add a separate section in the documentation for JSON configurations, so that users with less or no experience in this file would be able to simply instrument the delegate with logs in JSON format.
If possible, could you share what the logback.xml looks like?
C
Conservation Marlin
Thanks for the feedback and sorry for delayed response. I can't attach the sample config here, but you can replace the entire <encoder> ... </encoder> section for stdout appender with the below line (this replaces the default stdout to use json - delegate.log and harness remote appender will still use default logging format.
Meanwhile I will work with our documentation team to update the docs with full json sample and check if we can make this configurable through env variable
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
Prateek Mittal
Thanks for the feedback. Could you tell me more about why this feature is important to you? What is the problem that it is causing around your usage of our product? What benefits would you see from having this built?
T
Tame Flamingo
Prateek Mittal: Parsing for DataDog is much easier for a different customer. Right now the multiline errors come through DD with each as a separate entity providing millions of lines of errors.
The difference between StackDriver and the way DataDog ingests the logs is a huge pain point:
"Hey team! Is there a way we can get the Harness Delegate to output stack traces as a single line? Our Harness Delegates are spitting out a ton of stack traces right now, with each line logged separately. Alternatively, can we get the harness-delegate to log as JSON? Then Datadog would actually be able to parse it haha"
Prateek Mittal
long-term