Annotations Provide Context to Timelines in Percona Monitoring and Management
About the Author – This blog was written as a collaboration with my colleague Jiri Ctvrtka. Jiri is a senior software developer from Brno, Czech Republic, and has been partnering with Percona for almost a year working on various components of our Percona Platform. He’s been programming in Go since 2015 and Jiri’s got a passion for simplicity, speed, and precision of data and has focused that passion on understanding impacts of changes and reimagined the Percona Monitoring and Management (PMM) Annotations functionality.
“Does anyone remember what caused this large spike last Thursday at 2:24 am?”
What are Annotations?
Annotations are a way to provide context to timelines in Percona Monitoring and Management (PMM). For example, in bigger teams, it is a good way to inform others about an event, or important changes that may have occurred. It can contain any kind of information but we see it most commonly used for indicating there was an outage, maintenance window start/end, deployment of new code, security event, etc. Annotations in PMM help provide quick explanations to peaks and valleys in graphs or indicate when something took place on the timeline and create correlations.
Every annotation can be shown/hidden by a simple toggle button presented in the filter options. So you don’t need to be worried about crowded charts of annotations. You can toggle on/off and zoom in or out around events to get better detail.
How Can I Add Annotations?
Annotations can simply be added by the pmm-admin option: annotate. So, let’s try it:
pmm-admin annotate “Deployed web version 2.4.6“
That command will place an annotation on every chart in every node and service…maybe more than you need. What if you only needed to add an annotation for a specific node or service to indicate a broad network outage? Or add specific annotations for specific nodes or services to indicate a software update was applied? This is all possible as pmm-admin provides four flags, which can be used for just this purpose.
--node = annotate the node the pmm-admin command was run on --node-name = annotate node with specified name --service = annotate all services running on the node the pmm-admin command was run on --service-name = annotate service with specified name
All these flags can be combined together for options to annotate more nodes or services by just only one command. The order of flags doesn’t matter. Just imagine how many combinations you have! Even better, imagine how easily this can be integrated into our CI/CD or deploy pipelines!
You can also add annotations via the API with curl commands:
curl 'http://admin:admin@localhost/graph/api/annotations' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"tags": ARRAY OF TAGS,"text":"TEXT"}'
ARRAY OF TAGS = Names of node or service, like for node pmm-server and service pmm-server-mysql it will be “tags: [“pmm-server”, “pmm-server-mysql”]”
Some Examples for Better Understanding
Case 1: We have a DB node we need to take offline for maintenance and want to capture this on all its graphs to explain the gap in reporting data.
pmm-admin annotate "`date` - System is going down for Maintenance - RFC-2232-2020" --node-name=”db1002”
via API:
curl 'http://admin:admin@localhost/graph/api/annotations' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"tags": ["db1002"],"text":"`date` - System is going down for Maintenance - RFC-2232-2020"}'
or if pmm-admin is running on this node then you don’t even need to know the name of this node and can set it as part of the shutdown routine.
pmm-admin annotate "`date` - System is being shut down/rebooted"
Case 2: We have node pmm-server and three services running on the current node (mysql, postgres, mongo). So, yeah, it’s simple right?
pmm-admin annotate “`date` - Apply configuration change - RFC-1009-2020“ –service-name=mysql pmm-admin annotate “Restarting Postgres to apply security patch - “ –service-name=postgres pmm-admin annotate “`date` - Service Disruption Reported via Support - SUP-239“ –service-name=mongo
via API:
curl 'http://admin:admin@localhost/graph/api/annotations' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"tags": ["mysql", "postgresl", "mongo"],"text":"`date` - Apply configuration change - RFC-1009-2020"}'
Or you can do it in one command:
pmm-admin annotate “Services Recycled to pickup config changes“ –service
And that’s it! All services found running on that node will be annotated.
Case 3: We have node “registrationDb” and many services running on the current node. What if we want to annotate that node and also every service running on this node by just one command? Again, no problem:
pmm-admin annotate “`date` - Security alerted to possible event“ –node-name=registrationDb --service
via API:
curl 'http://admin:admin@localhost/graph/api/annotations' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"tags": ["registrationDb", "service1", "service2",...*],"text":"`date` - Security alerted to possible event"}'
* while the PMM admin command –service flag will add to all services, you need to add all services names of the current node to get the same result using the API but you can make an API call to get all services on a given node
That’s it, no matter how many services you are running on node registrationDb the annotations will be presented on all of them and on node graphs as well.
Case 4: We have 100 services running on the current node and also another node named pmm-server2 and we need to annotate all 100 services on the current node (but not the current node) along with node pmm-server2. Simple:
pmm-admin annotate “`date` - Load Test Start“ –node-name=pmm-server2 --service
via API:
curl 'http://admin:admin@localhost/graph/api/annotations' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"tags": ["pmm-server2", "service1", "service2",...*],"text":"`date` - Load Test - Increasing to 100 threads"}'
* while the PMM admin command –service flag will add to all services, you need to add all services names of the current node to get the same result using the API but you can make an API call to get all services on a given node
The current node will not be annotated, but every service on this node will be along with node pmm-server2.
Here’s a little guide to see many of the possible combinations of flags and what will result:
–node = current node
–node-name = node with name
–node –node-name = current node and node with name
–node –service-name = current node and service with name
–node –node-name –service-name = current node, node with name, and service with name
–node –service = current node and all services of current node
–node-name –service = all services of current node, node with name
–node –node-name –service = all services of current node, node with name, and current node
–service = all services of current node
–service-name = service with name
–service –service-name = all services of current node, service with name
–service –node-name = all services of current node and node with name
–service-name –node-name = service with name and node with name
–service –service-name –node-name = service with name, all services on current node, and node with name
So thanks to annotations, correlating events on your servers is now easier than ever. We’d love to hear or even see how you’re using annotations to make your life easier, hopefully, we’ve given you some ideas to get started right away!
Download Percona Monitoring and Management Today
by Steve Hoffman via Percona Database Performance Blog
Comments
Post a Comment