pmm-agent
pmm-agent copied to clipboard
PMM-9993 Add support to set web.listen-address
Build: SUBMODULES-0
- Added
--exporter-listen-address
option - Added
config.ExporterAddress
, stored in the config underexporter-listen-address
- Added
supervisor.Supervisor.exporterAddress
to refer toconfig.ExporterAddress
- Dynamically rewrite any
web.listen-address
that do not have a specified address (=:
)
Hi @cezmunsta, it's better to implement it on pmm-managed side since it controls what flags are passed and knows metrics mode of exporter.
@BupycHuk I think that you will need to clarify those points, as:
- This is under user control, unless they set the option then behaviour doesn't change
- I don't see the relevance of the mode. You may still want to set the address when pulling, e.g. multiple interfaces
we also should take care of users who might want to collect metrics from exporters directly by external prometheus.
Well, they will struggle to do that as the port can change across service restarts :)
$ cat ~/.config/pmm/pmm-agent-flags.txt
--metrics-mode=push
--server-address=127.0.0.1:28443
--server-username=admin
--server-password=admin
--server-insecure-tls
--ports-min=41000
--ports-max=41100
10.0.20.1
generic
test
$ pmm-admin inventory list nodes --json | jq '.nodes[] | select(.node_name == "test")'
{
"node_type": "GENERIC_NODE",
"node_name": "test",
"address": "10.0.20.1",
"node_id": "/node_id/06bf1d1a-5113-46fd-bf82-070cd062fb6a"
}
$ pmm-admin list --json | jq '.agent[] | select(.agent_type == "NODE_EXPORTER")'
{
"agent_type": "NODE_EXPORTER",
"agent_id": "/agent_id/86f7ea27-65d5-4f92-a94e-2e71cbaaccbc",
"service_id": "",
"status": "RUNNING",
"disabled": false,
"push_metrics_enabled": "push"
}
$ podman exec --user postgres pmm-server psql -d pmm-managed -c "select listen_port from agents where agent_id = '/agent_id/86f7ea27-65d5-4f92-a94e-2e71cbaaccbc'"
listen_port
-------------
41001
(1 row)
$ pkill -TERM -x pmm-agent.prod
$ ( nc -lk 41001 | tee ) &
$ /usr/local/percona/pmm2/bin/pmm-agent.prod run --config-file /usr/local/percona/pmm2/config/pmm-agent.yaml &
$ podman exec --user postgres pmm-server psql -d pmm-managed -c "select listen_port from agents where agent_id = '/agent_id/86f7ea27-65d5-4f92-a94e-2e71cbaaccbc'"
listen_port
-------------
41002
(1 row)
If we let users set a listen-address on pmm-agent side it won't support both metrics modes at the same time. Because part of them will be pulled by victoria metrics on PMM Server and part of them by vm-agent on the same machine. So we should make it on pmm-managed side. Based on metrics mode we can set node address or localhost as listen-address. To control it we can store new value like restrict-listen-address
in DB.