do-agent icon indicating copy to clipboard operation
do-agent copied to clipboard

do-agent --collector.<name> flags are confusing

Open alzeih opened this issue 3 years ago • 10 comments

Describe the problem

While experimenting with do-agent, I wanted to see if do-agent could support additional metrics for monitoring, graphing and alerting on DigitalOcean. I ran do-agent --help and saw options for enabling collectors that look familiar from the prometheus node_exporter to me. I tried to enable a collector using command-line flags, and received an error that I had to check the source code to understand.

Steps to reproduce

When I run do-agent --help, I see many --collector.<name> options, e.g.:

      ...
      --collector.arp           Enable the arp collector (default: enabled).
      --collector.bcache        Enable the bcache collector (default: enabled).
      ...

However, if I try to use these flags, e.g.:

# do-agent --collector.arp
do-agent: error: flag 'collector.arp' cannot be repeated, try --help

This didn't make sense to me as I had only specified --collector.arp once.

Also, the help text for --collector.arp says (default: enabled), however the collector is disabled for my platform https://github.com/digitalocean/do-agent/blob/master/cmd/do-agent/config_linux.go because disables arp.

I get the same results with the --no-collector.arp flag too:

# do-agent --no-collector.arp
do-agent: error: flag 'collector.arp' cannot be repeated, try --help

I think that the --no-collector.<name> options should be kept for the enabled collectors, e.g.: --no-collector.cpu.

Expected behavior

  • --collector.arp would enable the arp collector
  • --collector.arp help text would show the default for the current platform

OR

  • The --collector.arp flag would not be valid for do-agent
  • --collector.arp help text including the default would not be shown

System Information

Distribution and version:

Debian GNU/Linux 10 (buster)

do-agent information:


do-agent (DigitalOcean Agent)

Version:     3.9.4
Revision:    766c949
Build Date:  Fri Mar 12 20:37:53 UTC 2021
Go Version:  go1.16.2
Website:     https://github.com/digitalocean/do-agent

Copyright (c) 2021 DigitalOcean, Inc. All rights reserved.

This work is licensed under the terms of the Apache 2.0 license.
For a copy, see <https://www.apache.org/licenses/LICENSE-2.0.html>.

alzeih avatar Apr 27 '21 11:04 alzeih

This issue is somewhat related to https://github.com/digitalocean/do-agent/issues/52 too.

alzeih avatar Apr 27 '21 11:04 alzeih

I'm facing the same issue.

I think the help string containing (default: true) are coming from node_exporter's kingpin flags themselves: https://github.com/prometheus/node_exporter/blob/v1.0.1/collector/collector.go#L67

meanwhile, in do-agent, various collectors are disabled by default as pointed out above: https://github.com/digitalocean/do-agent/blob/a5ad2142ebafb056e916e592e57840fa41d4ce31/cmd/do-agent/config_linux.go#L10

in practice, what this ends up doing is adding --no-collector.arp etc to do-agent's internal cli flag set: https://github.com/digitalocean/do-agent/blob/a5ad2142ebafb056e916e592e57840fa41d4ce31/cmd/do-agent/config.go#L143

and then any subsequent --collector.arp flag is interpreted after that

the exact same issue would occur if running node_exporter directly, fwiw.

# ./node_exporter-1.1.2.linux-amd64/node_exporter --no-collector.arp --collector.arp
node_exporter: error: flag 'collector.arp' cannot be repeated, try --help

in config.go's disableCollectors you could do kingpin.CommandLine.GetFlag(fmt.Sprintf("collector.%s", name)).Default("false"), and then remove the os.Argv modification, but it won't help with the help strings

anitgandhi avatar Apr 28 '21 16:04 anitgandhi

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jul 08 '21 08:07 stale[bot]

This issue is not stale and has not received a response from Digital Ocean in 3 months.

alzeih avatar Jul 08 '21 12:07 alzeih

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Sep 06 '21 20:09 stale[bot]

still valid

bsnyder788 avatar Sep 07 '21 12:09 bsnyder788

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jan 08 '22 22:01 stale[bot]

Issue not stale yet, just a bit older.

alzeih avatar Jan 10 '22 04:01 alzeih

still valid

bsnyder788 avatar Apr 16 '22 07:04 bsnyder788

I'm facing the same issue

gininfra avatar Oct 05 '23 04:10 gininfra