Skip to content

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

@billux

Description

@billux

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!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Previous releases

Relationships

None yet

Development

No branches or pull requests

Issue actions