PMM add/remove mysql instances

Hello all!

I use PMM version 1.1.1 with percona-server-5.5.
My idea is to make registration and deletion new DB slaves from pmm monitoring automaticly.

With registration no problem. Each time when slave have created I added it to PMM with unique name.

But when I want to terminate some instance, AWS do it, and I see in PMM many ghost instances. Is there any possiable to clean up those ghost instances from server side (instance which was under monitoring terminated already)?

Also when I use pmm-admin remove --all can I cleanup historical metrics?

The option to remove records from Prometheus is:

pmm-admin purge mysql:metrics <instanceName>

Thank you. Can I use this command from another instance where pmm-client instaled?
For example I have instance A and instance B. B was terminated. Can I call from A?

pmm-admin purge mysql:metrics B

Do we speak about query analytics interface or Grafana?

Grafana only

Grafana uses data from Prometheus, Prometheus use Consul to get info about nodes.
Consul developers removed “Deregister” button from Consul interface :frowning:
https://github.com/hashicorp/consul/issues/2541

but it is possible to deregister via Consul API call
to get list of nodes:

curl -s 'http://USER:PASSWORD&#64;PMM-SERVER-IP/v1/internal/ui/nodes?dc=dc1' | python -mjson.tool | less

remove node from consul

curl -s -X PUT -d '{"Datacenter":"dc1","Node":"NODE-NAME"}' 'http://USER:PASSWORD&#64;PMM-SERVER-IP/v1/catalog/deregister?dc=dc1'

after that, it is needed to remove data from Prometheus (or just wait for some time, up to one day)

curl -X DELETE 'http://USER:PASSWORD&#64;PMM-SERVER-IP/prometheus/api/v1/series?match\[\]=\{instance="NODE-NAME"\}'

please note that node names in consul and in prometheus can be different for the one host

NB: we are going to add Deregister button on our interface in PMM-544