Marking deployments and more in SQL Monitor

SQL Monitor is an essential tool for DBA teams worldwide, providing real-time monitoring of SQL Server and PostgreSQL performance. With SQL Monitor, you can easily track deployments, errors, and other events on the timeline. This feature, called annotations, allows you to quickly identify the root cause of performance issues and take corrective action. SQL Monitor’s timeline is a powerful tool that helps you stay on top of your database performance and keep your systems running smoothly.  SQL Monitor timeline

You’ll use a PowerShell script to add the annotations to the timeline with just a handful of lines of code.

The PowerShell module

To get started using the SQL Monitor PowerShell module, navigate to your configurations page and look for the PowerShell API section. You’ll find links to the API documentation, the module, authentication token, and example scripts. Take a look at the example scripts, because there is an annotate example in the Monitored servers section.

Using PowerShell with SQL Monitor

Be sure to always download a new copy of the module after every SQL Monitor upgrade because the module must match the version of SQL Monitor that you are running. You’ll also need an authentication token to connect to SQL Monitor.

The example script

The first step is to connect to SQL Monitor after importing the module.

Next, you must grab the specific monitored server where you want the annotation.

Note that Get-SqlMonitorMonitoredObject  requires a Type  parameter. The documentation lists these types:

  • SqlServerInstance
  • AzureManagedInstance
  • AzureSqlServer
  • PostgresInstance
  • AmazonRdsHost
  • AmazonAuroraCluster
  • Cluster
  • Machine

Finally, run the Add-SqlMonitorAnnotation  command to create the annotation.

This example specifies the target or monitored object, a description for the annotation, and a date. That was just five lines of code – including connecting to SQL Monitor. It’s that easy!

Here’s the entire script:

You can also monitor your PostgreSQL servers with SQL Monitor. Here’s an example:

But wait…there’s more!

There are several other options you can use to provide even more information that are not used in the example. See this documentation page to learn more about these parameters.

  • Source: Use this parameter to specify the type of event. The Source  parameter also controls the icon you’ll see on the timeline. (See the first image in this article for examples.) Choices are
    • Flyway
    • Octopus
    • Deployment
    • Permissions Change
    • Configuration Change
    • SQL Update
  • SpecificInfo: This parameter allows you to include more information about the event, such as an error number or SQL Server version. It’s supported for all the sources except for the Flyway, Octopus, and Permissions Change sources.
  • URL: You can also include a clickable URL along with the annotation. Use this to link to direct to more information about the event, documentation, or anything you want.

Conclusion

It’s easy to send annotations to SQL Monitor, especially if you are already familiar with using the PowerShell module. If you haven’t tried the module for its many other uses, this is a great opportunity to try it out!

Tools in this post

SQL Monitor

Real-time SQL Server and PostgreSQL performance monitoring, with alerts and diagnostics

Find out more