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

Print warnings of scalyr-agent-2-config to stderr #704

Open
schra opened this issue Jan 19, 2021 · 3 comments
Open

Print warnings of scalyr-agent-2-config to stderr #704

schra opened this issue Jan 19, 2021 · 3 comments

Comments

@schra
Copy link

schra commented Jan 19, 2021

What

Following the instructions from https://app.scalyr.com/help/scalyr-agent-k8s#export-config fails

root@scalyr-84g88:/# scalyr-agent-2-config --export-config - | tar -xz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

Why

Warnings are printed to stdout instead of stderr and thus are also piped to tar:

root@scalyr-84g88:/# scalyr-agent-2-config --export-config  -
2021-01-19 15:52:36.895Z WARNING [monitor:__main__] [configuration.py:327] Configured option min_request_spacing_interval is being overridden due to max_send_rate_enforcement setting.
D`�o0���K��JJk��6A߽�T}
�OH�f�\�jF�ߑʪ ͫty͂$͓lF�gv8�d3�p�\+�g�3*%Uhn$N�ޠG+a�^�7�O�Y%⺏gxy߰9�
.az�v��˸���r��g���Fsa���5�_:y{q��ƫ�~NIUR�yEQ�[U�_+i����濦62Z���%��F��>�y�?~ϊ�� 5ǹ(root@scalyr-84g88:/# `��

Manually removing the warning is a workaround that works:

root@scalyr-84g88:/# scalyr-agent-2-config --export-config  - | tail -n +2 | tar -xz
root@scalyr-84g88:/# 

Docker image version: 2.1.15

Definition of done

The logger should print warnings and errors to stderr and not strdout. I think this should probably be done here:

def getLogger(name):
"""Returns a logger instance to use for the given name that implements the Scalyr agent's extra logging features.
This should be used in place of logging.getLogger when trying to retrieve a logging instance that implements
Scalyr agent's extra features.
Note, the logger instance will be configured to emit records at INFO level and above.
@param name: The name of the logger, such as the module name. If this is for a particular monitor instance, then
the monitor id should be appended at the end surrounded by brackets, such as "my_monitor[1]"
@return: A logger instance implementing the extra features.
"""
logging.setLoggerClass(AgentLogger)
result = logging.getLogger(name)
result.setLevel(logging.INFO)
return result

@jmorascalyr
Copy link
Contributor

jmorascalyr commented Jan 19, 2021

Thanks for submitting this. This has been submitted to engineering, and we will let you know when there are any updates on it. Thanks again for such a thorough analysis, troubleshooting, and repro steps.

@jmorascalyr
Copy link
Contributor

Digging into this deeper, can you give me an idea of what you are trying to modify? Or did you just stumble upon this bug? Though this is a way to modify the agent config, it is sort of old. It is still useful, but there are easier ways to make changes.

@schra
Copy link
Author

schra commented Jan 21, 2021

Digging into this deeper, can you give me an idea of what you are trying to modify? Or did you just stumble upon this bug? Though this is a way to modify the agent config, it is sort of old.

I followed the documentation (https://app.scalyr.com/help/scalyr-agent-k8s#export-config) which told me to execute scalyr-agent-2-config --export-config - | tar -xz and so I executed it and it didn't work due to the warning being printed to stdout.

It is still useful, but there are easier ways to make changes.

Maybe updating this paragraph here https://app.scalyr.com/help/scalyr-agent-k8s#export-config and deprecating --export-config would be helpful if there are easier ways to make changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants