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

newlines in processes name (cmdline) aren't escaped #175

Closed
billux opened this issue May 17, 2022 · 5 comments
Closed

newlines in processes name (cmdline) aren't escaped #175

billux opened this issue May 17, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@billux
Copy link

billux commented May 17, 2022

Bug description

Newlines in process' cmdline aren't escaped and break Prometheus output format.

To Reproduce

  1. start a process containing a newline in its command line:
    # bash -c 'sleep infinity;
    > echo plop'
    
  2. query metrics endpoint. The response looks like this:
    […]
    # HELP scaph_process_power_consumption_microwatts Power consumption due to the process, measured on at the topology level, in microwatts
    # TYPE scaph_process_power_consumption_microwatts gauge
    scaph_process_power_consumption_microwatts{cmdline="bash-csleep infinity;
    echo plop",exe="bash",pid="2786006"} 0
    […]
    
    Prometheus fails to parse scaphandre's output and ignore all metrics from scaphandre job.

2022-05-17-182811_1777x101_scrot

Expected behavior

newlines should be either escaped or replaced by spaces like in ps.

Environment

  • Debian buster
  • Kernel version: 5.10.0-9-amd64

Thanks!

@billux billux added the bug Something isn't working label May 17, 2022
@uggla uggla self-assigned this Jul 17, 2022
uggla added a commit to uggla/scaphandre that referenced this issue Jul 17, 2022
- Remove carriage return in process cmdline.
@bpetit bpetit added this to the Release v0.5.0 milestone Jul 21, 2022
@bpetit
Copy link
Contributor

bpetit commented Oct 7, 2022

@uggla did you open a PR on this ? I see the commit but I cannot find the related PR, did I miss something ?

@uggla
Copy link
Collaborator

uggla commented Oct 7, 2022

@bpetit yes I wrote a PR to fix this bug. I'm looking for it.

@uggla
Copy link
Collaborator

uggla commented Oct 7, 2022

#195 this is the PR fixing the issue.
It seems that setting the issue fixed in the title does not cross-link the PR number in the issue. So I changed the title as well.
Sorry for the inconvenience.

@bpetit
Copy link
Contributor

bpetit commented Oct 8, 2022

Thanks a lot ! I lost it for a moment.

@bpetit
Copy link
Contributor

bpetit commented Oct 28, 2022

Applied changes from @uggla in aa15ae2

It is fixed, thanks a lot @billux for raising the issue and @uggla for fixing it !

@bpetit bpetit closed this as completed Oct 28, 2022
@bpetit bpetit added this to General Jun 19, 2024
@bpetit bpetit moved this to Previous releases in General Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Previous releases
Development

Successfully merging a pull request may close this issue.

3 participants