How to add HTML Code in Grafana 7

Hello guys!

I have been having trouble upgrading from Grafana 6 to 7! I have currently trying to upgrade to the newer version and I did come up with some issues where I am not able to display any HTML anymore. See the attached image:

<center>
<br />
<table style="border: none;">
    <tr style="border: none;">
        <td style="border: none;">
            <select id="kw-type" name="kw-type" class="btn navbar-button gf-timepicker-nav-btn" style="width: 130px;">
                <option value="positive">POSITIVE</option>
                <option value="negative">NEGATIVE</option>
            </select>
        </td>
        <td style="border: none;">
            <input type="text" id="kw-keyword" name="kw-keyword" class="btn navbar-button gf-timepicker-nav-btn" style="text-align: left;" />
        </td>
    </tr>
    <tr>
        <td colspan="2" style="border: none; text-align: center;">
            <center>
                <button
                    onclick="insertKeywords(1,document.getElementById('kw-type').value,document.getElementById('kw-keyword').value,'popup','refresh');document.getElementById('kw-keyword').value=''"
                    class="btn navbar-button gf-timepicker-nav-btn"
                >
                    Add to watchlist
                </button>
            </center>
        </td>
    </tr>
</table>
</center>

and it worked fine when I had it in Grafana 6 but now as you can see it only displays the code now.

I wonder how I can add HTML Code in grafana like I had it in 6 before :’(

Hi @barryaljawari

This still works. Here is your html code on my local instance running Grafana 8.0.2:

There was a lot of work done on the Text Panel between Grafana 6 and 7.

Have you set disable_sanitize_html to true in your configurations? You need to do that starting with v7:

docker run -d -p 3000:3000 "GF_PANELS_DISABLE_SANITIZE_HTML=true" grafana/grafana:8.0.2

NOTE:

The default is false because this setting leaves you more exposed to XSS attacks (see PR for larger discussion)

This topic was automatically closed after 365 days. New replies are no longer allowed.