Hello
The Problem
I’ve got some data from the Telegraf sql_server input plugin, it saves the query text as a tag (“statement_text”) and encodes some chars of the query text, like tab as “\t” and new line “\n”.
(sample data below)
I need to show this query text, in a properly formatted way, but in Grafana I’ve not found anything to display it correctly.
The only panel that allows you to visualize something like this is the table, which (as any other component) is not able to interpret those chars (\t and \n), therefore the result is a huge and not so readable string.
Questions
- Is it possible to interpret special chars like /n in Grafana to show an actual “New Line” in the panel text?
- Is there any custom made object that does this? (I’ve looked for it… but didn’t find anything)
Sample Data
When I query the Influx, from Grafana, Chronograf or using the CLI I get the following (sample) value in the “statement_text” tag. Note the \t and \n
INSERT INTO @sys_info ( cpu_count, server_memory, sku, engine_edition, hardware_type, total_storage_mb, available_storage_mb, uptime )\n\tSELECT\tcpu_count,\n\t\t\t(SELECT total_physical_memory_kb FROM sys.dm_os_sys_memory) AS server_memory,\n\t\t\tCAST(SERVERPROPERTY('Edition') AS NVARCHAR(64)) as sku,\n\t\t\tCAST(SERVERPROPERTY('EngineEdition') as smallint) as engine_edition,\n\t\t\tCASE virtual_machine_type_desc\n\t\t\t\tWHEN 'NONE' THEN 'PHYSICAL Machine'\n\t\t\t\tELSE virtual_machine_type_desc\n\t\t\tEND AS hardware_type,\n\t\t\tNULL,\n\t\t\tNULL,\n\t\t\t DATEDIFF(MINUTE,sqlserver_start_time,GETDATE())\n\tFROM\tsys.dm_os_sys_inf
The original query and also what I want to show should look like this one:
INSERT INTO @sys_info ( cpu_count, server_memory, sku, engine_edition, hardware_type, total_storage_mb, available_storage_mb, uptime )
SELECT cpu_count,
(SELECT total_physical_memory_kb FROM sys.dm_os_sys_memory) AS server_memory,
CAST(SERVERPROPERTY('Edition') AS NVARCHAR(64)) as sku,
CAST(SERVERPROPERTY('EngineEdition') as smallint) as engine_edition,
CASE virtual_machine_type_desc
WHEN 'NONE' THEN 'PHYSICAL Machine'
ELSE virtual_machine_type_desc
END AS hardware_type,
NULL,
NULL,
DATEDIFF(MINUTE,sqlserver_start_time,GETDATE())
FROM sys.dm_os_sys_inf
thank you for reading thus far