do-agent
do-agent copied to clipboard
do-agent --collector.<name> flags are confusing
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>.
This issue is somewhat related to https://github.com/digitalocean/do-agent/issues/52 too.
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
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.
This issue is not stale and has not received a response from Digital Ocean in 3 months.
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.
still valid
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.
Issue not stale yet, just a bit older.
still valid
I'm facing the same issue