cloudability / metrics-agent

From the cloud optimization professionals
https://www.cloudability.com/
Apache License 2.0
39 stars 35 forks source link

All the logs generated by the metrics-agent seem to be written to stderr #48

Closed JonathanLachapelle closed 5 years ago

JonathanLachapelle commented 5 years ago

I'm testing the metrics-agent on a GKE cluster and all the logs are reported as severity : ERROR.

It's a bit confusing because when you see an error log like this : "2019/09/13 19:41:10 Uploading Metrics", you might think the metric agent is not working when it's actually working.

Since it takes up to 48 hours to know if the metrics are reaching cloudability, it's important to have the right severity for the logs.

From what I can see, 100% of the logs are written to STDERR

JonathanLachapelle commented 5 years ago

I have looked a bit at the code and the issue is that you are using log from go which default to stderr.

So when you write a line like this in kubernetes.go line 121 : log.Printf("Cloudability Metrics Agent successfully started."), the end-user will see in its log ERROR : Cloudability Metrics Agent successfully started.

This type of behavior is quite confusing and if we want to monitor the health of the container, it's a bit difficult to determine if it's a real issue or not.

you can look at this old exchange : https://stackoverflow.com/questions/23554647/where-does-go-log-the-errors

https://stackoverflow.com/questions/30697694/how-to-set-golangs-log-output-back-to-console

DavidXArnold commented 5 years ago

@JonathanLachapelle Thank you for raising this issue. We have had a couple of requests to improve the logging facilities of the metrics-agent. I have created issue #49 which encompasses this and others requests around improving the agents' logging facilities.