Documentation forSolarWinds Observability

Query tags

Query tags are name-value pairs embedded in query comments. Adding query tags to your queries gives you visibility into your query workload in several ways:

  • You can see the total contributions to total response time for tagged queries in the Response Time by tag widget on the Database Area overview

  • You can sort by query tag using the Profiler, seeing tagged queries by a specified category such as Total time

  • You can filter by tag using the Profiler, seeing only query families where an execution had the specified tag name or value

For example, let's say that you’re considering allocating a dedicated database server to interact exclusively with requests coming from your mobile app, because you suspect traffic coming from it to be significant. You could create a query tag called app, with an application name as the value, to rank applications by the workload they send to the database and thus be able to differentiate them. Or, perhaps the queries the database executes varies considerably between clients. Tagging your queries with client will let you filter down to queries for that specific client.

Add query tags to queries

Associate a tag to a query by including a comment within your query that contains key-value pairs that SolarWinds Observability can parse into a tag. This allows for both filtering digests in the Profiler as well as seeing query data (such as count, total time, etc.) grouped by tag.

Alter your queries to include the tag embedded in a comment to identify its source. For example, we could differentiate queries coming from the mobile-dedicated infrastructure, which we’ll tag as app=mobile, from the ones originating from other sources, which we’ll simply tag as app=desktop, by using tags. The exact syntax for query comments is database specific: MySQL and PostgreSQL implement nested block comments while MongoDB employs a $comment meta-operator.

See the table below for an example for each of those databases:

Database Example
MySQL SELECT /* app=mobile */ ...
PostgreSQL SELECT /* app=mobile */ ...
MongoDB db.collection.find( { <query> } ).comment('app=mobile' )
Currently, SolarWinds Observability does not parse comments using the - - comment syntax.

The default delimiters for query tags are = and a space, but this is configurable through the tag-delimiters agent option: you can use a different 2-character string for representing the delimiters between name-value pairs and tags, respectively.There’s also a tag-blacklist agent option that includes a comma-separated list of tags that will be ignored. SolarWinds Observability automatically blacklists tags whose values have extremely high cardinality because that data is typically too granular to be useful and does not provide meaningful statistics.

MySQL and PostgreSQL command line tools will strip comments. If you are looking at testing this functionality you will need to use a different client to the native ones (or, in the case of MySQL, use option --comments to prevent the client from discarding comments and sending them to the server with the query).