grafana icon indicating copy to clipboard operation
grafana copied to clipboard

Add Grafana 7 cell style to show sanitized HTML

Open maemigh opened this issue 4 years ago • 51 comments

What happened: When adding new tables to Grafana 7, many options are missing. "Column Styles" is missing from the panel options. Dashboards migrated from Grafana 6 still include all the options.

What you expected to happen: All options should be available (such as column type, sanitize html, etc) somewhere. Particularly looking for sanitize html.

How to reproduce it (as minimally and precisely as possible): Create a new table in Grafana 7

Anything else we need to know?:

Environment:

  • Grafana version: 7.0-beta3
  • Data source type & version: MySQL
  • OS Grafana is installed on: RedHat 7.8
  • User OS & Browser: Chrome 81.0.4044.129
  • Grafana plugins:
  • Others:

maemigh avatar May 10 '20 06:05 maemigh

We have column styles (available via the overrides tab), to set options per column.

When you say your missing sanitize, do you want to show HTML in a cell?

torkelo avatar May 10 '20 06:05 torkelo

@torkelo Yes, exactly. My Grafana 6 tables show the formatted HTML (with sanitize HTML turned on), but there doesn't seem to be an option to enable this on Grafana 7 tables. The column style setting of "String" in the overrides does not seem to exist.

maemigh avatar May 10 '20 06:05 maemigh

yea, we have not added support for this cell display mode yet.

Just curious what is the value you want to render as html? An anchor link? or something else?

torkelo avatar May 10 '20 07:05 torkelo

Actually it's just simple text. <pre> monospace text with some <br/>s.

maemigh avatar May 10 '20 07:05 maemigh

that won't work, the new table will not support dynamic (different) table cell heights. As rows are virtualized the row height needs to be predefined and cannot differ between rows.

But I plan to add a cell size or height option to support cells with higher content (like images)

torkelo avatar May 10 '20 08:05 torkelo

@torkelo This already works in 6.7.3 as well as in tables migrated from 6.7.3.

maemigh avatar May 10 '20 08:05 maemigh

Yes, but won’t work in 7.0 table as row height, cell height is fixed

torkelo avatar May 11 '20 05:05 torkelo

Personally I use the sanatize html feature of the old table panel for lots of purposes. It's one of the main reasons I started using Grafana. It makes the table panel incredibly flexible/powerful.

  1. to render tags so I can show images in tables. And the Render value as link option allows the images to be clickable to show a full-size version.

  2. to render bold/highlighting/colours/newlines etc. of certain elements within a table.

  3. to show a tables with (clickable) status icons including font awesome icons etc.

therealcodlord avatar May 28 '20 14:05 therealcodlord

We are used to Column Styles feature, but in Grafana 7.0 it's gone. We setting up column display styles very often and now have a problems with it; for example, displaying column value as date.

Temporary solution for returning Column Styles tab: import dashboard with table from old version of Grafana.

Please, add back this tab or add new method of changing column value formatting. Thanks!

SirobbsCrafter avatar May 28 '20 15:05 SirobbsCrafter

You can use the Overrides tab to define something exactly the same as Column styles, where you can define cell styles, thresholds, links etc per column.

We are missing some cell style options but that will come

torkelo avatar May 28 '20 15:05 torkelo

@torkelo we need to format column value as date, but Overrides has not this feature at this time (if i not mistaking). Waiting for updates.

SirobbsCrafter avatar May 28 '20 15:05 SirobbsCrafter

Showing HTML in the table cells was a really powerful feature. Combined with the variables to refer to other cells it was really flexible. Would be nice to have it back.

wyxa avatar Jun 03 '20 08:06 wyxa

Until this is possible:

You can use the old tables instead of the new ones, just change the panel type to "table-old" in the dashboard's JSON.

Breee avatar Jun 30 '20 08:06 Breee

Until this is possible:

You can use the old tables instead of the new ones, just change the panel type to "table-old" in the dashboard's JSON.

Nice tip! thanks

maxgodsk avatar Jun 30 '20 09:06 maxgodsk

Yes, Please add this feature back. Use cases for me: Links, Icons etc... sample use

merryllem-zz avatar Jul 03 '20 02:07 merryllem-zz

I also have an issue, which also related to cell height and was possible before 7 and now it's gone.

Before 7 it was possible with "Preserve Fromatting" to display a multiline String in a cell. Now line breaks are igonred and there is no comparable option in the new override tab. So basically now i have to decide whether to have horizontal scrollable headers (new table) or to have multiline Strings in the cells (old table).

If dynamic row heights are not possible, i would a appreciate it to have an option to preserve line breaks and set a fixed height for rows.

patrikTSS avatar Jul 03 '20 12:07 patrikTSS

i have many use cases for this feature, also it will be great if we can change the style (if i want to change the colors of the links based on my own logic ). grafana 6 sanitize is removing "style" labels.

meitar11 avatar Jul 16 '20 09:07 meitar11

@torkelo Is there a solution to display an image as the cell display mode? Screenshot from 2020-09-22 11-03-41 The column would contain a public URL of an image, that would get displayed in the table. Would be very useful...

waterdrop01 avatar Sep 22 '20 09:09 waterdrop01

image cell mode you ask for? well had a bit of fun this weekend https://github.com/grafana/grafana/pull/27669

torkelo avatar Sep 22 '20 09:09 torkelo

@torkelo wow, looks insane!! Can't wait for it :)

waterdrop01 avatar Sep 22 '20 10:09 waterdrop01

@torkelo I was using the "Preserve Formatting" options which is not present in v7.2

Basically, my use case was to use the table as a huge cell to show formatted text. Is this going to be supported somehow in the new table?

image

Trovalo avatar Oct 14 '20 07:10 Trovalo

Don't think so, maybe in the text panel?

torkelo avatar Oct 14 '20 07:10 torkelo

I can't use a query in the text panel, that's why I'm using the table (the "Statement Text" is the result of a query, I ensure it returns only one row)

Trovalo avatar Oct 14 '20 08:10 Trovalo

but what if you could?

torkelo avatar Oct 14 '20 14:10 torkelo

Oh well, that would be amazing, I'll switch to the Text Panel if that was the case.

It would be handy to have some basic transformation, in my case just the "Organize Fields" suffice. I'm using InfluxDB, and the time column is always returned even if you don't need it, so I usually set it as hidden.

In general, I think being able to fetch text using a query would be really handy, I'm thinking about getting log details and similar use cases.

Trovalo avatar Oct 14 '20 15:10 Trovalo

Showing HTML in the table cells was a really powerful feature. Combined with the variables to refer to other cells it was really flexible. Would be nice to have it back.

News about this feature ??

cicciopizza avatar Oct 15 '20 09:10 cicciopizza

@torkelo this was one of the most powerful features of the old table I was really surprised that it wasn't included in the new table

wyxa avatar Oct 15 '20 16:10 wyxa

Preserve formatting is also one that is missing from the V7 Table, even in the overrides.

havedill avatar Nov 13 '20 11:11 havedill

I have a lot of dashes where i use html in cells. the HTML is generated directly from the output of the query (I created some views in mysql where some columns have the html ready to be displayed) For example, based on the name I get the color of the text that I see in the table: in the view I already have the html ready

<span><b><font color="#0082F6">ntcy_raspicy_plc</font></b></span>
<span><b><font color="#FF8A00">ntcy-raspicy-pro4</font></b></span>
.....
.....

and in grafana table I just need to view that column of the DB to get the text with the font / color etc. that I want.

Selezione_037

how could i get this in grafana 7.x ?

cicciopizza avatar Nov 14 '20 16:11 cicciopizza

My example would be with the Zabbix plugin. The text metrics it pulls, (SNMP Traps for example) are multiline, and using the new table converts it all into a single line, making it unreadable.

I also just tried out the 7.3 grafana, and that appears to break table-old entirely for me

havedill avatar Nov 14 '20 16:11 havedill