Regex to convert a variable for a Dashboard to uppercase

  • What Grafana version and what operating system are you using?
    Windows 2019 Server

  • What are you trying to achieve?
    I have some variables I’ve created that need to be converted to uppercase to be pushed into a query I am doing against Log Analytics Workspace. These are SQL audit logs related, and it unfortunately case sensitive. My current variables are being extracted as lowercase and this breaks the query. I have tested the same query by manually using uppercase and it works fine.

subid / resource / sql variables all need to be uppercase to work, the db variable is fine however.

Query below;

AzureDiagnostics
| where Category == ‘SQLSecurityAuditEvents’
| where ResourceId == ‘/SUBSCRIPTIONS/$subid/RESOURCEGROUPS/$resource/PROVIDERS/MICROSOFT.SQL/SERVERS/$sql/DATABASES/MASTER’ and database_name_s == ‘$db’
| project
event_time_t,
statement_s,
succeeded_s,
affected_rows_d,
server_principal_name_s,
client_ip_s,
application_name_s,
additional_information_s,
data_sensitivity_information_s
| order by event_time_t desc
| take 100

  • How are you trying to achieve it?
    Setting up a Azure SQL Audit Logs Dashboard.

  • What happened?
    All me variables are being extracted as lowercase

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

can you try the upper() function in your sql?

/SUBSCRIPTIONS/upper($subid)/RESOURCEGROUPS/upper($resource)/PROVIDERS/MICROSOFT.SQL/SERVERS/upper($sql)/DATABASES/MASTER’ and database_name_s == ‘$db’

No joy amended the query string to use upper() function, query still fails.
Thanks for your help.

Resource Graph Query works

Resources

| where type == “microsoft.sql/servers” | extend Id=toupper(subscriptionId)

| project toupper(id)

1 Like